C#: Restrict FormatInvalid.ql and UncontrolledFormatString.ql to calls with insertions

This commit is contained in:
Tom Hvitved
2020-12-18 10:53:11 +01:00
parent 7a132149a2
commit d53faa86dc
9 changed files with 18 additions and 7 deletions

View File

@@ -14,5 +14,7 @@ import semmle.code.csharp.frameworks.Format
import FormatFlow
from FormatCall s, InvalidFormatString src, PathNode source, PathNode sink
where hasFlowPath(src, source, s, sink)
where
hasFlowPath(src, source, s, sink) and
s.hasInsertions()
select src, source, sink, "Invalid format string used in $@ formatting call.", s, "this"

View File

@@ -4,6 +4,6 @@ class Bad
{
string GenerateEmptyClass(string c)
{
return string.Format("class {0} { }");
return string.Format("class {0} { }", "C");
}
}