forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionReachabilityTest.ql
More file actions
29 lines (25 loc) · 989 Bytes
/
Copy pathExceptionReachabilityTest.ql
File metadata and controls
29 lines (25 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* Inline-expectations test for exception-handler reachability in the shared CFG.
*/
import python
import semmle.python.controlflow.internal.AstNodeImpl as CfgImpl
import semmle.python.controlflow.internal.Cfg as Cfg
import utils.test.InlineExpectationsTest
module ExceptionReachabilityTest implements TestSig {
string getARelevantTag() { result = "exception-handler" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(
Expr source, ExceptStmt handler, Cfg::ControlFlowNode sourceCfg,
Cfg::ControlFlowNode handlerEntry
|
sourceCfg.getNode() = source and
handlerEntry = sourceCfg.getAnExceptionalSuccessor() and
CfgImpl::astNodeToPyNode(handlerEntry.getAstNode()) = handler and
location = source.getLocation() and
element = source.toString() and
tag = "exception-handler" and
value = handler.getType().toString()
)
}
}
import MakeTest<ExceptionReachabilityTest>