mirror of
https://github.com/github/codeql.git
synced 2026-02-27 20:33:42 +01:00
Java: Add some more exception edges to the CFG to facilitate guard wrappers.
This commit is contained in:
@@ -347,12 +347,28 @@ private module ControlFlowGraphImpl {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate methodMayThrow(Method m, ThrowableType t) {
|
||||
exists(AstNode n |
|
||||
t = n.(ThrowStmt).getThrownExceptionType() and
|
||||
not n.(ThrowStmt).getParent() = any(Method m0).getBody()
|
||||
or
|
||||
uncheckedExceptionFromMethod(n, t)
|
||||
|
|
||||
n.getEnclosingStmt().getEnclosingCallable() = m and
|
||||
not exists(TryStmt try |
|
||||
exists(try.getACatchClause()) and try.getBlock() = n.getEnclosingStmt().getEnclosingStmt*()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind `t` to an unchecked exception that may occur in a precondition check.
|
||||
* Bind `t` to an unchecked exception that may occur in a precondition check or guard wrapper.
|
||||
*/
|
||||
private predicate uncheckedExceptionFromMethod(MethodCall ma, ThrowableType t) {
|
||||
conditionCheckArgument(ma, _, _) and
|
||||
(t instanceof TypeError or t instanceof TypeRuntimeException)
|
||||
or
|
||||
methodMayThrow(ma.getMethod(), t)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user