Skip to content

Commit b3de5d9

Browse files
committed
move PrefixStringSanitizer to the Query.qll file, and have it extend LabeledSanitizerGuardNode
1 parent 562dce5 commit b3de5d9

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,4 @@ module DomBasedXss {
2222

2323
/** Gets the flow-label representing tainted values where the prefix is attacker controlled. */
2424
PrefixString prefixLabel() { any() }
25-
26-
/**
27-
* A sanitizer that blocks the `PrefixString` label when the start of the string is being tested as being of a particular prefix.
28-
*/
29-
class PrefixStringSanitizer extends SanitizerGuard instanceof StringOps::StartsWith {
30-
override predicate sanitizes(boolean outcome, Expr e) { none() }
31-
32-
override predicate blocks(boolean outcome, Expr e, DataFlow::FlowLabel label) {
33-
super.blocks(outcome, e, label)
34-
or
35-
e = super.getBaseString().asExpr() and
36-
label = prefixLabel() and
37-
outcome = super.getPolarity()
38-
}
39-
}
4025
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,14 @@ class Configuration extends TaintTracking::Configuration {
123123
outlbl = prefixLabel()
124124
}
125125
}
126+
127+
/**
128+
* A sanitizer that blocks the `PrefixString` label when the start of the string is being tested as being of a particular prefix.
129+
*/
130+
class PrefixStringSanitizer extends SanitizerGuard, TaintTracking::LabeledSanitizerGuardNode instanceof StringOps::StartsWith {
131+
override predicate sanitizes(boolean outcome, Expr e, DataFlow::FlowLabel label) {
132+
e = super.getBaseString().asExpr() and
133+
label = prefixLabel() and
134+
outcome = super.getPolarity()
135+
}
136+
}

0 commit comments

Comments
 (0)