Skip to content

Commit 4a631b4

Browse files
author
Esben Sparre Andreasen
committed
JS: use .lastIndexOf in js/incomplete-url-substring-sanitization
1 parent 7adf1d9 commit 4a631b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

javascript/ql/src/Security/CWE-020/IncompleteUrlSubstringSanitization.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private import semmle.javascript.dataflow.InferredTypes
1515

1616
from DataFlow::MethodCallNode call, string name, DataFlow::Node substring, string target
1717
where
18-
(name = "indexOf" or name = "includes" or name = "startsWith" or name = "endsWith") and
18+
(name = "indexOf" or name = "lastIndexOf" or name = "includes" or name = "startsWith" or name = "endsWith") and
1919
call.getMethodName() = name and
2020
substring = call.getArgument(0) and
2121
substring.mayHaveStringValue(target) and
@@ -27,7 +27,7 @@ where
2727
) and
2828
// whitelist
2929
not (
30-
name = "indexOf" and
30+
(name = "indexOf" or name = "lastIndexOf") and
3131
(
3232
// arithmetic on the indexOf-result
3333
any(ArithmeticExpr e).getAnOperand().getUnderlyingValue() = call.asExpr()

0 commit comments

Comments
 (0)