Skip to content

Commit 75b06d8

Browse files
committed
Python: Model dill.load
1 parent 4820be3 commit 75b06d8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ private import semmle.python.ApiGraphs
1414
* See https://pypi.org/project/dill/.
1515
*/
1616
private module Dill {
17+
/**
18+
* A call to `dill.load`
19+
* See https://pypi.org/project/dill/ (which currently refers you
20+
* to https://docs.python.org/3/library/pickle.html#pickle.load)
21+
*/
22+
private class DillLoadCall extends Decoding::Range, DataFlow::CallCfgNode {
23+
DillLoadCall() { this = API::moduleImport("dill").getMember("load").getACall() }
24+
25+
override predicate mayExecuteInput() { any() }
26+
27+
override DataFlow::Node getAnInput() { result in [this.getArg(0), this.getArgByName("file")] }
28+
29+
override DataFlow::Node getOutput() { result = this }
30+
31+
override string getFormat() { result = "dill" }
32+
}
33+
1734
/**
1835
* A call to `dill.loads`
1936
* See https://pypi.org/project/dill/ (which currently refers you
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dill
22

3-
dill.load(file_) # $ MISSING: decodeInput=file_ decodeOutput=dill.loads(..) decodeFormat=dill decodeMayExecuteInput
4-
dill.load(file=file_) # $ MISSING: decodeInput=file_ decodeOutput=dill.loads(..) decodeFormat=dill decodeMayExecuteInput
3+
dill.load(file_) # $ decodeInput=file_ decodeOutput=dill.load(..) decodeFormat=dill decodeMayExecuteInput
4+
dill.load(file=file_) # $ decodeInput=file_ decodeOutput=dill.load(..) decodeFormat=dill decodeMayExecuteInput
55
dill.loads(payload) # $ decodeInput=payload decodeOutput=dill.loads(..) decodeFormat=dill decodeMayExecuteInput
66
dill.loads(str=payload) # $ decodeInput=payload decodeOutput=dill.loads(..) decodeFormat=dill decodeMayExecuteInput

0 commit comments

Comments
 (0)