@@ -140,20 +140,24 @@ class LocalUrlSanitizer extends Sanitizer {
140140}
141141
142142/**
143- * A argument to a call to `List.Contains()` that is a sanitizer for URL redirects.
143+ * An argument to a call to `List.Contains()` that is a sanitizer for URL redirects.
144144 */
145145private predicate isContainsUrlSanitizer ( Guard guard , Expr e , AbstractValue v ) {
146- exists ( MethodCall method | method = guard |
147- exists ( Method m | m = method .getTarget ( ) |
148- m .hasName ( "Contains" ) and
149- e = method .getArgument ( 0 )
150- ) and
151- v .( AbstractValues:: BooleanValue ) .getValue ( ) = true
152- )
146+ guard =
147+ any ( MethodCall method |
148+ exists ( Method m | m = method .getTarget ( ) |
149+ m .hasName ( "Contains" ) and
150+ e = method .getArgument ( 0 )
151+ ) and
152+ v .( AbstractValues:: BooleanValue ) .getValue ( ) = true
153+ )
153154}
154155
155156/**
156- * A URL argument to a call to `List.Contains()` that is a sanitizer for URL redirects.
157+ * An URL argument to a call to `.Contains()` that is a sanitizer for URL redirects.
158+ *
159+ * This `Contains` method is usually called on a list, but the sanitizer matches any call to a method
160+ * called `Contains`, so other methods with the same name will also be considered sanitizers.
157161 */
158162class ContainsUrlSanitizer extends Sanitizer {
159163 ContainsUrlSanitizer ( ) {
@@ -165,12 +169,12 @@ class ContainsUrlSanitizer extends Sanitizer {
165169 * A check that the URL is relative, and therefore safe for URL redirects.
166170 */
167171private predicate isRelativeUrlSanitizer ( Guard guard , Expr e , AbstractValue v ) {
168- exists ( PropertyAccess access | access = guard |
169- access . getProperty ( ) . getName ( ) = "IsAbsoluteUri" and
170- access .getQualifier ( ) .getType ( ) . getFullyQualifiedName ( ) = "System. Uri" and
171- e = access .getQualifier ( ) and
172- v .( AbstractValues:: BooleanValue ) .getValue ( ) = false
173- )
172+ guard =
173+ any ( PropertyAccess access |
174+ access .getProperty ( ) .hasFullyQualifiedName ( "System" , " Uri", "IsAbsoluteUri" ) and
175+ e = access .getQualifier ( ) and
176+ v .( AbstractValues:: BooleanValue ) .getValue ( ) = false
177+ )
174178}
175179
176180/**
@@ -187,16 +191,16 @@ class RelativeUrlSanitizer extends Sanitizer {
187191 * E.g. `url.Host == "example.org"`
188192 */
189193private predicate isHostComparisonSanitizer ( Guard guard , Expr e , AbstractValue v ) {
190- exists ( EqualityOperation comparison | comparison = guard |
191- exists ( PropertyAccess access | access = comparison . getAnOperand ( ) |
192- access . getProperty ( ) . getName ( ) = "Host" and
193- access .getQualifier ( ) .getType ( ) . getFullyQualifiedName ( ) = "System. Uri" and
194- e = access .getQualifier ( )
195- ) and
196- if comparison instanceof EQExpr
197- then v .( AbstractValues:: BooleanValue ) .getValue ( ) = true
198- else v .( AbstractValues:: BooleanValue ) .getValue ( ) = false
199- )
194+ guard =
195+ any ( EqualityOperation comparison |
196+ exists ( PropertyAccess access | access = comparison . getAnOperand ( ) |
197+ access .getProperty ( ) .hasFullyQualifiedName ( "System" , " Uri", "Host" ) and
198+ e = access .getQualifier ( )
199+ ) and
200+ if comparison instanceof EQExpr
201+ then v .( AbstractValues:: BooleanValue ) .getValue ( ) = true
202+ else v .( AbstractValues:: BooleanValue ) .getValue ( ) = false
203+ )
200204}
201205
202206/**
0 commit comments