publicclassExampleController:Controller{privatestaticreadonlystring[]EFFECT_ALLOW_LIST={"SepiaEffect","BlackAndWhiteEffect","WaterColorEffect","OilPaintingEffect"};publicIActionResultApply(stringEffectName){if(!EFFECT_ALLOW_LIST.Contains(EffectName)){returnBadRequest("Invalid effect name. The effect is not allowed.");}varEffectInstance=Activator.CreateInstance(null,EffectName);objectEffectPlugin=EffectInstance.Unwrap();if(((IEffect)EffectPlugin).ApplyFilter()){returnOk();}else{returnProblem();}}}publicinterfaceIEffect{boolApplyFilter();}
Seamless integrations. Try Datadog Code Security
Datadog Code Security
Try this rule and analyze your code with Datadog Code Security
How to use this rule
1
2
rulesets:- csharp-security # Rules to enforce C# security.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Security scans to your CI pipelines