-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathargumentRouting2.ql
More file actions
38 lines (32 loc) · 1.21 KB
/
argumentRouting2.ql
File metadata and controls
38 lines (32 loc) · 1.21 KB
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
30
31
32
33
34
35
36
37
38
/**
* @kind path-problem
*/
import python
import experimental.dataflow.DataFlow
import DataFlow::PathGraph
/**
* A configuration to check routing of arguments through magic methods.
*/
class ArgumentRoutingConfig extends DataFlow::Configuration {
ArgumentRoutingConfig() { this = "ArgumentRoutingConfig" }
override predicate isSource(DataFlow::Node node) {
node.(DataFlow::CfgNode).getNode().(NameNode).getId() = "arg2"
}
override predicate isSink(DataFlow::Node node) {
exists(CallNode call |
call.getFunction().(NameNode).getId() = "SINK2" and
node.(DataFlow::CfgNode).getNode() = call.getAnArg()
)
}
/**
* This prevents the argument from one call to reach the sink
* via a different call, by flowing to an argument of that.
*/
override predicate isBarrierIn(DataFlow::Node node) { isSource(node) }
}
from DataFlow::PathNode source, DataFlow::PathNode sink
where
source.getNode().getLocation().getFile().getBaseName() in ["classes.py", "argumentPassing.py"] and
sink.getNode().getLocation().getFile().getBaseName() in ["classes.py", "argumentPassing.py"] and
exists(ArgumentRoutingConfig cfg | cfg.hasFlowPath(source, sink))
select source.getNode(), source, sink, "Flow found"