== How to fix it in .NET === Code examples include::../../common/fix/code-rationale.adoc[] ==== Noncompliant code example [source,csharp,diff-id=1,diff-type=noncompliant] ---- using System.Diagnostics; public class ExampleController : Controller { public void Example(string name, string value) { Process proc = new Process(); proc.StartInfo.FileName = "path/to/executable"; proc.StartInfo.EnvironmentVariables.Add(name, value); // Noncompliant proc.Start(); } } ---- ==== Compliant solution [source,csharp,diff-id=1,diff-type=compliant] ---- using System.Diagnostics; using System.Text.RegularExpressions; public class ExampleController : Controller { public void Example(string value) { Process proc = new Process(); proc.StartInfo.FileName = "path/to/executable"; string pattern = "^[a-zA-Z0-9]*$"; Match m = Regex.Match(value, pattern); if (m.Success) { proc.StartInfo.EnvironmentVariables.Add("ENV_VAR", value); } proc.Start(); } } ---- === How does this work? include::../../common/fix/pre-approved-list.adoc[]