Skip to content

Commit 06c83ee

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: add error message for deprecated sink kinds to 'getInvalidModelKind'
1 parent 617107d commit 06c83ee

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

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

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,72 @@ module ModelValidation {
265265
)
266266
}
267267

268+
private class DeprecatedSinkKind extends string {
269+
DeprecatedSinkKind() {
270+
this =
271+
[
272+
"sql", "url-redirect", "xpath", "ssti", "logging", "groovy", "jexl", "mvel", "xslt",
273+
"ldap", "pending-intent-sent", "intent-start", "set-hostname-verifier",
274+
"header-splitting", "xss", "write-file", "create-file", "read-file", "open-url",
275+
"jdbc-url"
276+
]
277+
}
278+
279+
private string replacementKind() {
280+
this = "sql" and result = "\"sql-injection\""
281+
or
282+
this = "url-redirect" and result = "\"url-redirection\""
283+
or
284+
this = "xpath" and result = "\"xpath-injection\""
285+
or
286+
this = "ssti" and result = "\"template-injection\""
287+
or
288+
this = "logging" and result = "\"log-injection\""
289+
or
290+
this = "groovy" and result = "\"groovy-injection\""
291+
or
292+
this = "jexl" and result = "\"jexl-injection\""
293+
or
294+
this = "mvel" and result = "\"mvel-injection\""
295+
or
296+
this = "xslt" and result = "\"xslt-injection\""
297+
or
298+
this = "ldap" and result = "\"ldap-injection\""
299+
or
300+
this = "pending-intent-sent" and result = "\"pending-intents\""
301+
or
302+
this = "intent-start" and result = "\"intent-redirection\""
303+
or
304+
this = "set-hostname-verifier" and result = "\"hostname-verification\""
305+
or
306+
this = "header-splitting" and result = "\"response-splitting\""
307+
or
308+
this = "xss" and result = "\"html-injection\" or \"js-injection\""
309+
or
310+
this = "write-file" and result = "\"file-content-store\""
311+
or
312+
this = "create-file" and result = "\"path-injection\""
313+
or
314+
this = "read-file" and result = "\"path-injection\""
315+
or
316+
this = "open-url" and result = "\"request-forgery\""
317+
or
318+
this = "jdbc-url" and result = "\"request-forgery\""
319+
}
320+
321+
string deprecationMessage() {
322+
result =
323+
"The kind \"" + this + "\" is deprecated. Use " + this.replacementKind() + " instead."
324+
}
325+
}
326+
268327
private string getInvalidModelKind() {
269328
exists(string kind | summaryModel(_, _, _, _, _, _, _, _, kind, _) |
270329
not kind = ["taint", "value"] and
271330
result = "Invalid kind \"" + kind + "\" in summary model."
272331
)
273332
or
274-
exists(string kind | sinkModel(_, _, _, _, _, _, _, kind, _) |
333+
exists(string kind, string msg | sinkModel(_, _, _, _, _, _, _, kind, _) |
275334
not kind =
276335
[
277336
"request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
@@ -283,7 +342,10 @@ module ModelValidation {
283342
] and
284343
not kind.matches("regex-use%") and
285344
not kind.matches("qltest%") and
286-
result = "Invalid kind \"" + kind + "\" in sink model."
345+
msg = "Invalid kind \"" + kind + "\" in sink model." and
346+
if kind instanceof DeprecatedSinkKind
347+
then result = msg + " " + kind.(DeprecatedSinkKind).deprecationMessage()
348+
else result = msg
287349
)
288350
or
289351
exists(string kind | sourceModel(_, _, _, _, _, _, _, kind, _) |

0 commit comments

Comments
 (0)