Skip to content

Commit 2d0c9b6

Browse files
authored
Merge pull request github#5670 from tausbn/python-use-api-graphs-in-dill
Python: Use API graphs in Dill model
2 parents 419d25c + 079c7e0 commit 2d0c9b6

File tree

1 file changed

+4
-35
lines changed
  • python/ql/src/semmle/python/frameworks

1 file changed

+4
-35
lines changed

python/ql/src/semmle/python/frameworks/Dill.qll

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,19 @@ private import python
77
private import semmle.python.dataflow.new.DataFlow
88
private import semmle.python.dataflow.new.RemoteFlowSources
99
private import semmle.python.Concepts
10-
11-
private module Dill {
12-
/** Gets a reference to the `dill` module. */
13-
private DataFlow::Node dill(DataFlow::TypeTracker t) {
14-
t.start() and
15-
result = DataFlow::importNode("dill")
16-
or
17-
exists(DataFlow::TypeTracker t2 | result = dill(t2).track(t2, t))
18-
}
19-
20-
/** Gets a reference to the `dill` module. */
21-
DataFlow::Node dill() { result = dill(DataFlow::TypeTracker::end()) }
22-
23-
/** Provides models for the `dill` module. */
24-
module dill {
25-
/** Gets a reference to the `dill.loads` function. */
26-
private DataFlow::Node loads(DataFlow::TypeTracker t) {
27-
t.start() and
28-
result = DataFlow::importNode("dill.loads")
29-
or
30-
t.startInAttr("loads") and
31-
result = dill()
32-
or
33-
exists(DataFlow::TypeTracker t2 | result = loads(t2).track(t2, t))
34-
}
35-
36-
/** Gets a reference to the `dill.loads` function. */
37-
DataFlow::Node loads() { result = loads(DataFlow::TypeTracker::end()) }
38-
}
39-
}
10+
private import semmle.python.ApiGraphs
4011

4112
/**
4213
* A call to `dill.loads`
4314
* See https://pypi.org/project/dill/ (which currently refers you
4415
* to https://docs.python.org/3/library/pickle.html#pickle.loads)
4516
*/
46-
private class DillLoadsCall extends Decoding::Range, DataFlow::CfgNode {
47-
override CallNode node;
48-
49-
DillLoadsCall() { node.getFunction() = Dill::dill::loads().asCfgNode() }
17+
private class DillLoadsCall extends Decoding::Range, DataFlow::CallCfgNode {
18+
DillLoadsCall() { this = API::moduleImport("dill").getMember("loads").getACall() }
5019

5120
override predicate mayExecuteInput() { any() }
5221

53-
override DataFlow::Node getAnInput() { result.asCfgNode() = node.getArg(0) }
22+
override DataFlow::Node getAnInput() { result = this.getArg(0) }
5423

5524
override DataFlow::Node getOutput() { result = this }
5625

0 commit comments

Comments
 (0)