Merge pull request #7516 from michaelnebel/csharp/improve-csv-validation

C#: Introduce Csv validation on kind.
This commit is contained in:
Michael Nebel
2022-01-06 14:31:26 +01:00
committed by GitHub
5 changed files with 58 additions and 45 deletions

View File

@@ -349,6 +349,24 @@ module CsvValidation {
msg = "Invalid boolean \"" + b + "\" in " + pred + " model."
)
)
or
exists(string row, string kind | summaryModel(row) |
kind = row.splitAt(";", 8) and
not kind = ["taint", "value"] and
msg = "Invalid kind \"" + kind + "\" in summary model."
)
or
exists(string row, string kind | sinkModel(row) |
kind = row.splitAt(";", 7) and
not kind = ["code", "sql", "xss", "remote", "html"] and
msg = "Invalid kind \"" + kind + "\" in sink model."
)
or
exists(string row, string kind | sourceModel(row) |
kind = row.splitAt(";", 7) and
not kind = "local" and
msg = "Invalid kind \"" + kind + "\" in source model."
)
}
}

View File

@@ -1,8 +1,8 @@
invalidModelRow
#select
| Sinks.cs:8:19:8:22 | access to local variable arg1 | qltest |
| Sinks.cs:11:13:11:41 | this access | qltest-arg |
| Sinks.cs:11:30:11:40 | access to local variable argToTagged | qltest-arg |
| Sinks.cs:14:27:14:36 | access to local variable fieldWrite | qltest-nospec |
| Sinks.cs:20:20:20:22 | access to local variable res | qltest |
| Sinks.cs:27:20:27:25 | access to local variable resTag | qltest-retval |
| Sinks.cs:8:19:8:22 | access to local variable arg1 | code |
| Sinks.cs:11:13:11:41 | this access | remote |
| Sinks.cs:11:30:11:40 | access to local variable argToTagged | remote |
| Sinks.cs:14:27:14:36 | access to local variable fieldWrite | sql |
| Sinks.cs:20:20:20:22 | access to local variable res | xss |
| Sinks.cs:27:20:27:25 | access to local variable resTag | html |

View File

@@ -9,11 +9,11 @@ class SinkModelTest extends SinkModelCsv {
row =
[
//"namespace;type;overrides;name;signature;ext;spec;kind",
"My.Qltest;B;false;Sink1;(System.Object);;Argument[0];qltest",
"My.Qltest;B;false;SinkMethod;();;ReturnValue;qltest",
"My.Qltest;SinkAttribute;false;;;Attribute;ReturnValue;qltest-retval",
"My.Qltest;SinkAttribute;false;;;Attribute;Argument;qltest-arg",
"My.Qltest;SinkAttribute;false;;;Attribute;;qltest-nospec"
"My.Qltest;B;false;Sink1;(System.Object);;Argument[0];code",
"My.Qltest;B;false;SinkMethod;();;ReturnValue;xss",
"My.Qltest;SinkAttribute;false;;;Attribute;ReturnValue;html",
"My.Qltest;SinkAttribute;false;;;Attribute;Argument;remote",
"My.Qltest;SinkAttribute;false;;;Attribute;;sql"
]
}
}

View File

@@ -1,22 +1,17 @@
invalidModelRow
#select
| Sources.cs:8:17:8:22 | call to method Src1 | qltest |
| Sources.cs:8:17:8:22 | call to method Src1 | qltest-all-overloads |
| Sources.cs:9:17:9:24 | call to method Src1 | qltest |
| Sources.cs:9:17:9:24 | call to method Src1 | qltest-all-overloads |
| Sources.cs:12:17:12:26 | call to method Src2 | qltest |
| Sources.cs:12:17:12:26 | call to method Src2 | qltest-w-subtypes |
| Sources.cs:13:17:13:26 | call to method Src3 | qltest-w-subtypes |
| Sources.cs:15:13:15:21 | [post] this access | qltest-argany |
| Sources.cs:15:20:15:20 | [post] access to local variable x | qltest-argany |
| Sources.cs:15:20:15:20 | [post] access to local variable x | qltest-argnum |
| Sources.cs:17:17:17:33 | call to method TaggedSrcMethod | qltest-retval |
| Sources.cs:18:17:18:30 | access to field TaggedSrcField | qltest-nospec |
| Sources.cs:20:17:20:33 | call to method SrcTwoArg | qltest |
| Sources.cs:24:14:24:20 | this | qltest-param |
| Sources.cs:24:29:24:45 | taggedMethodParam | qltest-param |
| Sources.cs:28:49:28:62 | taggedSrcParam | qltest-nospec |
| Sources.cs:28:49:28:62 | taggedSrcParam | qltest-param |
| Sources.cs:40:45:40:45 | p | qltest-param-override |
| Sources.cs:47:50:47:50 | p | qltest-param-override |
| Sources.cs:53:16:53:30 | this | qltest-param |
| Sources.cs:8:17:8:22 | call to method Src1 | local |
| Sources.cs:9:17:9:24 | call to method Src1 | local |
| Sources.cs:12:17:12:26 | call to method Src2 | local |
| Sources.cs:13:17:13:26 | call to method Src3 | local |
| Sources.cs:15:13:15:21 | [post] this access | local |
| Sources.cs:15:20:15:20 | [post] access to local variable x | local |
| Sources.cs:17:17:17:33 | call to method TaggedSrcMethod | local |
| Sources.cs:18:17:18:30 | access to field TaggedSrcField | local |
| Sources.cs:20:17:20:33 | call to method SrcTwoArg | local |
| Sources.cs:24:14:24:20 | this | local |
| Sources.cs:24:29:24:45 | taggedMethodParam | local |
| Sources.cs:28:49:28:62 | taggedSrcParam | local |
| Sources.cs:40:45:40:45 | p | local |
| Sources.cs:47:50:47:50 | p | local |
| Sources.cs:53:16:53:30 | this | local |

View File

@@ -9,20 +9,20 @@ class SourceModelTest extends SourceModelCsv {
row =
[
//"namespace;type;overrides;name;signature;ext;spec;kind",
"My.Qltest;A;false;Src1;();;ReturnValue;qltest",
"My.Qltest;A;false;Src1;(System.String);;ReturnValue;qltest",
"My.Qltest;A;false;Src1;;;ReturnValue;qltest-all-overloads",
"My.Qltest;A;false;Src2;();;ReturnValue;qltest",
"My.Qltest;A;false;Src3;();;ReturnValue;qltest",
"My.Qltest;A;true;Src2;();;ReturnValue;qltest-w-subtypes",
"My.Qltest;A;true;Src3;();;ReturnValue;qltest-w-subtypes",
"My.Qltest;A;false;SrcArg;(System.Object);;Argument[0];qltest-argnum",
"My.Qltest;A;false;SrcArg;(System.Object);;Argument;qltest-argany",
"My.Qltest;A;true;SrcParam;(System.Object);;Parameter[0];qltest-param-override",
"My.Qltest;SourceAttribute;false;;;Attribute;ReturnValue;qltest-retval",
"My.Qltest;SourceAttribute;false;;;Attribute;Parameter;qltest-param",
"My.Qltest;SourceAttribute;false;;;Attribute;;qltest-nospec",
"My.Qltest;A;false;SrcTwoArg;(System.String,System.String);;ReturnValue;qltest"
"My.Qltest;A;false;Src1;();;ReturnValue;local",
"My.Qltest;A;false;Src1;(System.String);;ReturnValue;local",
"My.Qltest;A;false;Src1;;;ReturnValue;local",
"My.Qltest;A;false;Src2;();;ReturnValue;local",
"My.Qltest;A;false;Src3;();;ReturnValue;local",
"My.Qltest;A;true;Src2;();;ReturnValue;local",
"My.Qltest;A;true;Src3;();;ReturnValue;local",
"My.Qltest;A;false;SrcArg;(System.Object);;Argument[0];local",
"My.Qltest;A;false;SrcArg;(System.Object);;Argument;local",
"My.Qltest;A;true;SrcParam;(System.Object);;Parameter[0];local",
"My.Qltest;SourceAttribute;false;;;Attribute;ReturnValue;local",
"My.Qltest;SourceAttribute;false;;;Attribute;Parameter;local",
"My.Qltest;SourceAttribute;false;;;Attribute;;local",
"My.Qltest;A;false;SrcTwoArg;(System.String,System.String);;ReturnValue;local"
]
}
}