@@ -79,15 +79,29 @@ module Shared {
79
79
* Holds if this node acts as a barrier for data flow, blocking further flow from `e` if `this` evaluates to `outcome`.
80
80
*/
81
81
predicate blocksExpr ( boolean outcome , Expr e ) { none ( ) }
82
+
83
+ /** DEPRECATED. Use `blocksExpr` instead. */
84
+ deprecated predicate sanitizes ( boolean outcome , Expr e ) { this .blocksExpr ( outcome , e ) }
82
85
}
83
86
84
87
/**
85
88
* A barrier guard that applies to multiple XSS queries.
86
89
*/
87
90
module BarrierGuard = DataFlow:: MakeBarrierGuard< BarrierGuard > ;
88
91
89
- private class QuoteGuard2 extends BarrierGuard , StringOps:: Includes {
90
- QuoteGuard2 ( ) {
92
+ /** A subclass of `BarrierGuard` that is used for backward compatibility with the old data flow library. */
93
+ deprecated final private class BarrierGuardLegacy extends TaintTracking:: SanitizerGuardNode instanceof BarrierGuard
94
+ {
95
+ override predicate sanitizes ( boolean outcome , Expr e ) {
96
+ BarrierGuard .super .sanitizes ( outcome , e )
97
+ }
98
+ }
99
+
100
+ /**
101
+ * A guard that checks if a string can contain quotes, which is a guard for strings that are inside an HTML attribute.
102
+ */
103
+ class QuoteGuard extends BarrierGuard , StringOps:: Includes {
104
+ QuoteGuard ( ) {
91
105
this .getSubstring ( ) .mayHaveStringValue ( "\"" ) and
92
106
this .getBaseString ( )
93
107
.getALocalSource ( )
@@ -100,14 +114,11 @@ module Shared {
100
114
}
101
115
102
116
/**
103
- * A guard that checks if a string can contain quotes, which is a guard for strings that are inside an HTML attribute.
117
+ * A sanitizer guard that checks for the existence of HTML chars in a string.
118
+ * E.g. `/["'&<>]/.exec(str)`.
104
119
*/
105
- abstract class QuoteGuard extends TaintTracking:: SanitizerGuardNode instanceof QuoteGuard2 {
106
- override predicate sanitizes ( boolean outcome , Expr e ) { super .blocksExpr ( outcome , e ) }
107
- }
108
-
109
- private class ContainsHtmlGuard2 extends BarrierGuard , StringOps:: RegExpTest {
110
- ContainsHtmlGuard2 ( ) {
120
+ class ContainsHtmlGuard extends BarrierGuard , StringOps:: RegExpTest {
121
+ ContainsHtmlGuard ( ) {
111
122
exists ( RegExpCharacterClass regExp |
112
123
regExp = this .getRegExp ( ) and
113
124
forall ( string s | s = [ "\"" , "&" , "<" , ">" ] | regExp .getAMatchedString ( ) = s )
@@ -119,15 +130,6 @@ module Shared {
119
130
}
120
131
}
121
132
122
- /**
123
- * A sanitizer guard that checks for the existence of HTML chars in a string.
124
- * E.g. `/["'&<>]/.exec(str)`.
125
- */
126
- abstract class ContainsHtmlGuard extends TaintTracking:: SanitizerGuardNode instanceof ContainsHtmlGuard2
127
- {
128
- override predicate sanitizes ( boolean outcome , Expr e ) { super .blocksExpr ( outcome , e ) }
129
- }
130
-
131
133
/**
132
134
* Holds if `str` is used in a switch-case that has cases matching HTML escaping.
133
135
*/
0 commit comments