Skip to content

Commit f14f944

Browse files
committed
JS: Use getAMatchedString instead of getConstantString
1 parent b3e64f1 commit f14f944

File tree

3 files changed

+1
-10
lines changed

3 files changed

+1
-10
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/TaintedPathCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ module TaintedPath {
459459
* An expression of form `x.matches(/\.\./)` or similar.
460460
*/
461461
class ContainsDotDotRegExpSanitizer extends BarrierGuardNode instanceof StringOps::RegExpTest {
462-
ContainsDotDotRegExpSanitizer() { super.getRegExp().getConstantValue() = [".", "..", "../"] }
462+
ContainsDotDotRegExpSanitizer() { super.getRegExp().getAMatchedString() = [".", "..", "../"] }
463463

464464
override predicate blocks(boolean outcome, Expr e, DataFlow::FlowLabel label) {
465465
e = super.getStringOperand().asExpr() and
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| query-tests/Security/CWE-022/TaintedPath/normalizedPaths.js:402 | did not expect an alert, but found an alert for TaintedPath | OK | |

javascript/ql/test/query-tests/Security/CWE-022/TaintedPath/TaintedPath.expected

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,9 +2129,6 @@ nodes
21292129
| normalizedPaths.js:399:21:399:24 | path |
21302130
| normalizedPaths.js:399:21:399:24 | path |
21312131
| normalizedPaths.js:399:21:399:24 | path |
2132-
| normalizedPaths.js:402:21:402:24 | path |
2133-
| normalizedPaths.js:402:21:402:24 | path |
2134-
| normalizedPaths.js:402:21:402:24 | path |
21352132
| other-fs-libraries.js:9:7:9:48 | path |
21362133
| other-fs-libraries.js:9:7:9:48 | path |
21372134
| other-fs-libraries.js:9:7:9:48 | path |
@@ -7022,10 +7019,6 @@ edges
70227019
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:399:21:399:24 | path |
70237020
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:399:21:399:24 | path |
70247021
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:399:21:399:24 | path |
7025-
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
7026-
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
7027-
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
7028-
| normalizedPaths.js:385:7:385:46 | path | normalizedPaths.js:402:21:402:24 | path |
70297022
| normalizedPaths.js:385:14:385:46 | pathMod ... uery.x) | normalizedPaths.js:385:7:385:46 | path |
70307023
| normalizedPaths.js:385:14:385:46 | pathMod ... uery.x) | normalizedPaths.js:385:7:385:46 | path |
70317024
| normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:385:14:385:46 | pathMod ... uery.x) |
@@ -9706,7 +9699,6 @@ edges
97069699
| normalizedPaths.js:381:19:381:29 | slash(path) | normalizedPaths.js:377:14:377:27 | req.query.path | normalizedPaths.js:381:19:381:29 | slash(path) | This path depends on $@. | normalizedPaths.js:377:14:377:27 | req.query.path | a user-provided value |
97079700
| normalizedPaths.js:388:19:388:22 | path | normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:388:19:388:22 | path | This path depends on $@. | normalizedPaths.js:385:35:385:45 | req.query.x | a user-provided value |
97089701
| normalizedPaths.js:399:21:399:24 | path | normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:399:21:399:24 | path | This path depends on $@. | normalizedPaths.js:385:35:385:45 | req.query.x | a user-provided value |
9709-
| normalizedPaths.js:402:21:402:24 | path | normalizedPaths.js:385:35:385:45 | req.query.x | normalizedPaths.js:402:21:402:24 | path | This path depends on $@. | normalizedPaths.js:385:35:385:45 | req.query.x | a user-provided value |
97109702
| other-fs-libraries.js:11:19:11:22 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:11:19:11:22 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |
97119703
| other-fs-libraries.js:12:27:12:30 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:12:27:12:30 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |
97129704
| other-fs-libraries.js:13:24:13:27 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:13:24:13:27 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |

0 commit comments

Comments
 (0)