Ce produit n'est pas pris en charge par le site Datadog que vous avez sélectionné. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
usingSystem.Diagnostics;publicclassController{}publicclassExampleController:Controller{publicvoidExample(stringname,stringvalue){Processproc=newProcess();proc.StartInfo.FileName="path/to/executable";proc.StartInfo.EnvironmentVariables.Add(name,value);// Noncompliant: name is a variableproc.Start();}}
Compliant Code Examples
usingSystem.Diagnostics;usingSystem.Text.RegularExpressions;publicclassController{}publicclassExampleController:Controller{publicvoidExample(stringvalue){Processproc=newProcess();proc.StartInfo.FileName="path/to/executable";stringpattern="^*$";Matchm=Regex.Match(value,pattern);if(m.Success){// Name "ENV_VAR" is not in the sensitive list, so value being dynamic is ok here.proc.StartInfo.EnvironmentVariables.Add("ENV_VAR",value);}proc.Start();}}
1
2
rulesets:- csharp-security # Rules to enforce C# security.