Skip to content

Commit 79f61cc

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java/C#/Go/Swift: use 'SharedModelValidation' file
1 parent 0ab1848 commit 79f61cc

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ private import internal.DataFlowPublic
9595
private import internal.FlowSummaryImpl::Public
9696
private import internal.FlowSummaryImpl::Private::External
9797
private import internal.FlowSummaryImplSpecific
98+
private import SharedModelValidation
9899

99100
/** Holds if a source model exists for the given parameters. */
100101
predicate sourceModel = Extensions::sourceModel/9;
@@ -206,24 +207,28 @@ module ModelValidation {
206207

207208
private string getInvalidModelKind() {
208209
exists(string kind | summaryModel(_, _, _, _, _, _, _, _, kind, _) |
209-
not kind = ["taint", "value"] and
210+
not kind instanceof ValidSummaryKind and
211+
//not kind = ["taint", "value"] and
210212
result = "Invalid kind \"" + kind + "\" in summary model."
211213
)
212214
or
213215
exists(string kind | sinkModel(_, _, _, _, _, _, _, kind, _) |
214-
not kind =
215-
["code-injection", "sql-injection", "js-injection", "html-injection", "file-content-store"] and
216+
not kind instanceof ValidSinkKind and
217+
// not kind =
218+
// ["code-injection", "sql-injection", "js-injection", "html-injection", "file-content-store"] and
216219
not kind.matches("encryption-%") and
217220
result = "Invalid kind \"" + kind + "\" in sink model."
218221
)
219222
or
220223
exists(string kind | sourceModel(_, _, _, _, _, _, _, kind, _) |
221-
not kind = ["local", "remote", "file", "file-write"] and
224+
not kind instanceof ValidSourceKind and
225+
//not kind = ["local", "remote", "file", "file-write"] and
222226
result = "Invalid kind \"" + kind + "\" in source model."
223227
)
224228
or
225229
exists(string kind | neutralModel(_, _, _, _, kind, _) |
226-
not kind = ["summary", "source", "sink"] and
230+
not kind instanceof ValidNeutralKind and
231+
//not kind = ["summary", "source", "sink"] and
227232
result = "Invalid kind \"" + kind + "\" in neutral model."
228233
)
229234
}

go/ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private import internal.FlowSummaryImpl::Private::External
6868
private import internal.FlowSummaryImplSpecific
6969
private import internal.AccessPathSyntax
7070
private import FlowSummary
71+
private import SharedModelValidation
7172

7273
/**
7374
* A module importing the frameworks that provide external flow data,
@@ -190,7 +191,8 @@ module ModelValidation {
190191

191192
private string getInvalidModelKind() {
192193
exists(string kind | summaryModel(_, _, _, _, _, _, _, _, kind, _) |
193-
not kind = ["taint", "value"] and
194+
not kind instanceof ValidSummaryKind and
195+
//not kind = ["taint", "value"] and
194196
result = "Invalid kind \"" + kind + "\" in summary model."
195197
)
196198
}

java/ql/lib/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ private import internal.FlowSummaryImplSpecific as FlowSummaryImplSpecific
8787
private import internal.AccessPathSyntax
8888
private import ExternalFlowExtensions as Extensions
8989
private import FlowSummary
90+
private import SharedModelValidation
9091

9192
/**
9293
* A class for activating additional model rows.
@@ -311,20 +312,22 @@ module ModelValidation {
311312

312313
private string getInvalidModelKind() {
313314
exists(string kind | summaryModel(_, _, _, _, _, _, _, _, kind, _) |
314-
not kind = ["taint", "value"] and
315+
not kind instanceof ValidSummaryKind and
316+
//not kind = ["taint", "value"] and
315317
result = "Invalid kind \"" + kind + "\" in summary model."
316318
)
317319
or
318320
exists(string kind, string msg | sinkModel(_, _, _, _, _, _, _, kind, _) |
319-
not kind =
320-
[
321-
"request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
322-
"mvel-injection", "xpath-injection", "groovy-injection", "html-injection", "js-injection",
323-
"ognl-injection", "intent-redirection", "pending-intents", "url-redirection",
324-
"path-injection", "file-content-store", "hostname-verification", "response-splitting",
325-
"information-leak", "xslt-injection", "jexl-injection", "bean-validation",
326-
"template-injection", "fragment-injection", "command-injection"
327-
] and
321+
not kind instanceof ValidSinkKind and
322+
// not kind =
323+
// [
324+
// "request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
325+
// "mvel-injection", "xpath-injection", "groovy-injection", "html-injection", "js-injection",
326+
// "ognl-injection", "intent-redirection", "pending-intents", "url-redirection",
327+
// "path-injection", "file-content-store", "hostname-verification", "response-splitting",
328+
// "information-leak", "xslt-injection", "jexl-injection", "bean-validation",
329+
// "template-injection", "fragment-injection", "command-injection"
330+
// ] and
328331
not kind.matches("regex-use%") and
329332
not kind.matches("qltest%") and
330333
msg = "Invalid kind \"" + kind + "\" in sink model." and
@@ -335,13 +338,15 @@ module ModelValidation {
335338
)
336339
or
337340
exists(string kind | sourceModel(_, _, _, _, _, _, _, kind, _) |
338-
not kind = ["remote", "contentprovider", "android-external-storage-dir"] and
341+
not kind instanceof ValidSourceKind and
342+
// not kind = ["remote", "contentprovider", "android-widget", "android-external-storage-dir"] and
339343
not kind.matches("qltest%") and
340344
result = "Invalid kind \"" + kind + "\" in source model."
341345
)
342346
or
343347
exists(string kind | neutralModel(_, _, _, _, kind, _) |
344-
not kind = ["summary", "source", "sink"] and
348+
not kind instanceof ValidNeutralKind and
349+
//not kind = ["summary", "source", "sink"] and
345350
result = "Invalid kind \"" + kind + "\" in neutral model."
346351
)
347352
}

swift/ql/lib/codeql/swift/dataflow/ExternalFlow.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private import internal.FlowSummaryImpl::Public
7474
private import internal.FlowSummaryImpl::Private::External
7575
private import internal.FlowSummaryImplSpecific
7676
private import FlowSummary as FlowSummary
77+
private import SharedModelValidation
7778

7879
/**
7980
* A unit class for adding additional source model rows.
@@ -266,7 +267,8 @@ module CsvValidation {
266267
private string getInvalidModelKind() {
267268
exists(string row, string kind | summaryModel(row) |
268269
kind = row.splitAt(";", 8) and
269-
not kind = ["taint", "value"] and
270+
not kind instanceof ValidSummaryKind and
271+
//not kind = ["taint", "value"] and
270272
result = "Invalid kind \"" + kind + "\" in summary model."
271273
)
272274
}

0 commit comments

Comments
 (0)