@@ -21,12 +21,12 @@ private class ExactStringPathMatchGuard extends PathTraversalBarrierGuard instan
21
21
}
22
22
23
23
/**
24
- * Returns the qualifier of a method call if it's a variable access, or the qualifier of the qualifier
25
- * if the qualifier itself is a method call, which helps to reduce FPs by handling scenarios such as
26
- * `! uri.getPath().contains(".." )`.
24
+ * Given input `e` = `v.method1(...).method2(...)...`, returns `v` where `v` is a `VarAccess`.
25
+ *
26
+ * This is used to look through field accessors such as ` uri.getPath()`.
27
27
*/
28
- private Expr getRealQualifier ( Expr e ) {
29
- result = getRealQualifier ( e .( MethodAccess ) .getQualifier ( ) )
28
+ private Expr getUnderlyingVarAccess ( Expr e ) {
29
+ result = getUnderlyingVarAccess ( e .( MethodAccess ) .getQualifier ( ) )
30
30
or
31
31
result = e .( VarAccess )
32
32
}
@@ -37,7 +37,7 @@ private class AllowListGuard extends Guard instanceof MethodAccess {
37
37
not isDisallowedWord ( super .getAnArgument ( ) )
38
38
}
39
39
40
- Expr getCheckedExpr ( ) { result = getRealQualifier ( super .getQualifier ( ) ) }
40
+ Expr getCheckedExpr ( ) { result = getUnderlyingVarAccess ( super .getQualifier ( ) ) }
41
41
}
42
42
43
43
/**
@@ -84,7 +84,7 @@ private class BlockListGuard extends Guard instanceof MethodAccess {
84
84
isDisallowedWord ( super .getAnArgument ( ) )
85
85
}
86
86
87
- Expr getCheckedExpr ( ) { result = getRealQualifier ( super .getQualifier ( ) ) }
87
+ Expr getCheckedExpr ( ) { result = getUnderlyingVarAccess ( super .getQualifier ( ) ) }
88
88
}
89
89
90
90
/**
@@ -155,7 +155,7 @@ class PathTraversalGuard extends Guard instanceof MethodAccess {
155
155
super .getAnArgument ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = ".."
156
156
}
157
157
158
- Expr getCheckedExpr ( ) { result = getRealQualifier ( super .getQualifier ( ) ) }
158
+ Expr getCheckedExpr ( ) { result = getUnderlyingVarAccess ( super .getQualifier ( ) ) }
159
159
}
160
160
161
161
/** A complementary sanitizer that protects against path traversal using path normalization. */
0 commit comments