usingSystem.Xml;classMyClass{publicstaticvoiddoQuery(Int32userId){using(SqlConnectionconnection=newSqlConnection(connectionString)){SqlCommandcommand=newSqlCommand("SELECT attr FROM table WHERE id="+userID,connection);}}}
usingSystem.Xml;classMyClass{publicstaticvoidgoQuery(Int32userID){Stringquery1="SELECT attr FROM table WHERE id="+userID;}}
Compliant Code Examples
usingSystem.Xml;classMyClass{publicstaticvoiddoQuery(Int32userID){using(SqlConnectionconnection=newSqlConnection(connectionString)){SqlCommandcommand=newSqlCommand("SELECT attr FROM table WHERE id=@ID",connection);command.Parameters.Add("@ID",SqlDbType.Int);command.Parameters["@ID"].Value=userID;}}}
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
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 Analysis scans to your CI pipelines