Remove unnecessary taint step and update qldoc

This commit is contained in:
luchua-bc
2022-03-29 17:52:49 +00:00
parent e564481e9f
commit fa2a6a7da3
3 changed files with 11 additions and 12 deletions

View File

@@ -21,12 +21,12 @@ private class ExactStringPathMatchGuard extends PathTraversalBarrierGuard instan
}
/**
* Returns the qualifier of a method call if it's a variable access, or the qualifier of the qualifier
* if the qualifier itself is a method call, which helps to reduce FPs by handling scenarios such as
* `!uri.getPath().contains("..")`.
* Given input `e` = `v.method1(...).method2(...)...`, returns `v` where `v` is a `VarAccess`.
*
* This is used to look through field accessors such as `uri.getPath()`.
*/
private Expr getRealQualifier(Expr e) {
result = getRealQualifier(e.(MethodAccess).getQualifier())
private Expr getUnderlyingVarAccess(Expr e) {
result = getUnderlyingVarAccess(e.(MethodAccess).getQualifier())
or
result = e.(VarAccess)
}
@@ -37,7 +37,7 @@ private class AllowListGuard extends Guard instanceof MethodAccess {
not isDisallowedWord(super.getAnArgument())
}
Expr getCheckedExpr() { result = getRealQualifier(super.getQualifier()) }
Expr getCheckedExpr() { result = getUnderlyingVarAccess(super.getQualifier()) }
}
/**
@@ -84,7 +84,7 @@ private class BlockListGuard extends Guard instanceof MethodAccess {
isDisallowedWord(super.getAnArgument())
}
Expr getCheckedExpr() { result = getRealQualifier(super.getQualifier()) }
Expr getCheckedExpr() { result = getUnderlyingVarAccess(super.getQualifier()) }
}
/**
@@ -155,7 +155,7 @@ class PathTraversalGuard extends Guard instanceof MethodAccess {
super.getAnArgument().(CompileTimeConstantExpr).getStringValue() = ".."
}
Expr getCheckedExpr() { result = getRealQualifier(super.getQualifier()) }
Expr getCheckedExpr() { result = getUnderlyingVarAccess(super.getQualifier()) }
}
/** A complementary sanitizer that protects against path traversal using path normalization. */