Skip to content

Commit 46bd3e5

Browse files
committed
JS: Switch to instanceof base type
1 parent 5f4c1dd commit 46bd3e5

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -445,35 +445,29 @@ module TaintedPath {
445445
/**
446446
* An expression of form `x.includes("..")` or similar.
447447
*/
448-
class ContainsDotDotSanitizer extends BarrierGuardNode {
449-
StringOps::Includes contains;
450-
448+
class ContainsDotDotSanitizer extends BarrierGuardNode instanceof StringOps::Includes {
451449
ContainsDotDotSanitizer() {
452-
this = contains and
453-
isDotDotSlashPrefix(contains.getSubstring())
450+
isDotDotSlashPrefix(super.getSubstring())
454451
}
455452

456453
override predicate blocks(boolean outcome, Expr e, DataFlow::FlowLabel label) {
457-
e = contains.getBaseString().asExpr() and
458-
outcome = contains.getPolarity().booleanNot() and
454+
e = super.getBaseString().asExpr() and
455+
outcome = super.getPolarity().booleanNot() and
459456
label.(Label::PosixPath).canContainDotDotSlash() // can still be bypassed by normalized absolute path
460457
}
461458
}
462459

463460
/**
464461
* An expression of form `x.matches(/\.\./)` or similar.
465462
*/
466-
class ContainsDotDotRegExpSanitizer extends BarrierGuardNode {
467-
StringOps::RegExpTest test;
468-
463+
class ContainsDotDotRegExpSanitizer extends BarrierGuardNode instanceof StringOps::RegExpTest {
469464
ContainsDotDotRegExpSanitizer() {
470-
this = test and
471-
test.getRegExp().getConstantValue() = [".", "..", "../"]
465+
super.getRegExp().getConstantValue() = [".", "..", "../"]
472466
}
473467

474468
override predicate blocks(boolean outcome, Expr e, DataFlow::FlowLabel label) {
475-
e = test.getStringOperand().asExpr() and
476-
outcome = test.getPolarity().booleanNot() and
469+
e = super.getStringOperand().asExpr() and
470+
outcome = super.getPolarity().booleanNot() and
477471
label.(Label::PosixPath).canContainDotDotSlash() // can still be bypassed by normalized absolute path
478472
}
479473
}

0 commit comments

Comments
 (0)