@@ -79,15 +79,29 @@ module Shared {
7979 * Holds if this node acts as a barrier for data flow, blocking further flow from `e` if `this` evaluates to `outcome`.
8080 */
8181 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 ) }
8285 }
8386
8487 /**
8588 * A barrier guard that applies to multiple XSS queries.
8689 */
8790 module BarrierGuard = DataFlow:: MakeBarrierGuard< BarrierGuard > ;
8891
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 ( ) {
91105 this .getSubstring ( ) .mayHaveStringValue ( "\"" ) and
92106 this .getBaseString ( )
93107 .getALocalSource ( )
@@ -100,14 +114,11 @@ module Shared {
100114 }
101115
102116 /**
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)`.
104119 */
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 ( ) {
111122 exists ( RegExpCharacterClass regExp |
112123 regExp = this .getRegExp ( ) and
113124 forall ( string s | s = [ "\"" , "&" , "<" , ">" ] | regExp .getAMatchedString ( ) = s )
@@ -119,15 +130,6 @@ module Shared {
119130 }
120131 }
121132
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-
131133 /**
132134 * Holds if `str` is used in a switch-case that has cases matching HTML escaping.
133135 */
0 commit comments