Skip to content

Commit 0979272

Browse files
committed
Improved heuristics to increase precision
1 parent f8d1e2a commit 0979272

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ predicate conditionControlsMethod(MethodAccess ma, Expr e) {
1515
exists(ConditionBlock cb, SensitiveExecutionMethod m, boolean cond |
1616
ma.getMethod() = m and
1717
cb.controls(ma.getBasicBlock(), cond) and
18-
not cb.controls(m.getAReference().getBasicBlock(), cond.booleanNot()) and
18+
not cb.controls(any(SensitiveExecutionMethod sem).getAReference().getBasicBlock(),
19+
cond.booleanNot()) and
20+
not cb.controls(any(ThrowStmt t).getBasicBlock(), _) and
21+
not cb.controls(any(ReturnStmt r).getBasicBlock(), _) and
1922
e = cb.getCondition()
2023
)
2124
}

java/ql/lib/semmle/code/java/security/SensitiveActions.qll

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,12 @@ abstract class SensitiveExecutionMethod extends Method { }
8080
class AuthMethod extends SensitiveExecutionMethod {
8181
AuthMethod() {
8282
exists(string s | s = this.getName().toLowerCase() |
83-
(
84-
s.matches("%login%") or
85-
s.matches("%auth%")
86-
) and
87-
not (
88-
s.matches("get%") or
89-
s.matches("set%") or
90-
s.matches("parse%") or
91-
s.matches("%loginfo%")
92-
)
93-
)
83+
s.matches(["%login%", "%auth%"]) and
84+
not s.matches([
85+
"get%", "set%", "parse%", "%loginfo%", "remove%", "clean%", "%unauth%", "%author%"
86+
])
87+
) and
88+
not this.getDeclaringType().getASupertype*() instanceof TypeException
9489
}
9590
}
9691

0 commit comments

Comments
 (0)