mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Improved heuristics to increase precision
This commit is contained in:
@@ -15,7 +15,10 @@ predicate conditionControlsMethod(MethodAccess ma, Expr e) {
|
||||
exists(ConditionBlock cb, SensitiveExecutionMethod m, boolean cond |
|
||||
ma.getMethod() = m and
|
||||
cb.controls(ma.getBasicBlock(), cond) and
|
||||
not cb.controls(m.getAReference().getBasicBlock(), cond.booleanNot()) and
|
||||
not cb.controls(any(SensitiveExecutionMethod sem).getAReference().getBasicBlock(),
|
||||
cond.booleanNot()) and
|
||||
not cb.controls(any(ThrowStmt t).getBasicBlock(), _) and
|
||||
not cb.controls(any(ReturnStmt r).getBasicBlock(), _) and
|
||||
e = cb.getCondition()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -80,17 +80,12 @@ abstract class SensitiveExecutionMethod extends Method { }
|
||||
class AuthMethod extends SensitiveExecutionMethod {
|
||||
AuthMethod() {
|
||||
exists(string s | s = this.getName().toLowerCase() |
|
||||
(
|
||||
s.matches("%login%") or
|
||||
s.matches("%auth%")
|
||||
) and
|
||||
not (
|
||||
s.matches("get%") or
|
||||
s.matches("set%") or
|
||||
s.matches("parse%") or
|
||||
s.matches("%loginfo%")
|
||||
)
|
||||
)
|
||||
s.matches(["%login%", "%auth%"]) and
|
||||
not s.matches([
|
||||
"get%", "set%", "parse%", "%loginfo%", "remove%", "clean%", "%unauth%", "%author%"
|
||||
])
|
||||
) and
|
||||
not this.getDeclaringType().getASupertype*() instanceof TypeException
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user