Skip to content

Commit 6483080

Browse files
authored
Merge pull request #13228 from jcogs33/jcogs33/deprecated-sink-error-message
Java: add error message for outdated sink kinds in `getInvalidModelKind`
2 parents c95cf5a + b8cedfa commit 6483080

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

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

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

268+
private class OutdatedSinkKind extends string {
269+
OutdatedSinkKind() {
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", "xpath", "groovy", "jexl", "mvel", "xslt", "ldap"] and
281+
result = this + "-injection"
282+
or
283+
this = "url-redirect" and result = "url-redirection"
284+
or
285+
this = "ssti" and result = "template-injection"
286+
or
287+
this = "logging" and result = "log-injection"
288+
or
289+
this = "pending-intent-sent" and result = "pending-intents"
290+
or
291+
this = "intent-start" and result = "intent-redirection"
292+
or
293+
this = "set-hostname-verifier" and result = "hostname-verification"
294+
or
295+
this = "header-splitting" and result = "response-splitting"
296+
or
297+
this = "xss" and result = "html-injection\" or \"js-injection"
298+
or
299+
this = "write-file" and result = "file-content-store"
300+
or
301+
this = ["create-file", "read-file"] and result = "path-injection"
302+
or
303+
this = ["open-url", "jdbc-url"] and result = "request-forgery"
304+
}
305+
306+
string outdatedMessage() {
307+
result =
308+
"The kind \"" + this + "\" is outdated. Use \"" + this.replacementKind() + "\" instead."
309+
}
310+
}
311+
268312
private string getInvalidModelKind() {
269313
exists(string kind | summaryModel(_, _, _, _, _, _, _, _, kind, _) |
270314
not kind = ["taint", "value"] and
271315
result = "Invalid kind \"" + kind + "\" in summary model."
272316
)
273317
or
274-
exists(string kind | sinkModel(_, _, _, _, _, _, _, kind, _) |
318+
exists(string kind, string msg | sinkModel(_, _, _, _, _, _, _, kind, _) |
275319
not kind =
276320
[
277321
"request-forgery", "jndi-injection", "ldap-injection", "sql-injection", "log-injection",
@@ -283,7 +327,11 @@ module ModelValidation {
283327
] and
284328
not kind.matches("regex-use%") and
285329
not kind.matches("qltest%") and
286-
result = "Invalid kind \"" + kind + "\" in sink model."
330+
msg = "Invalid kind \"" + kind + "\" in sink model." and
331+
// The part of this message that refers to outdated sink kinds can be deleted after June 1st, 2024.
332+
if kind instanceof OutdatedSinkKind
333+
then result = msg + " " + kind.(OutdatedSinkKind).outdatedMessage()
334+
else result = msg
287335
)
288336
or
289337
exists(string kind | sourceModel(_, _, _, _, _, _, _, kind, _) |

0 commit comments

Comments
 (0)