Skip to content

Commit a81d359

Browse files
committed
Python: Model marshal.load
1 parent 1b61296 commit a81d359

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,22 @@ private module StdlibPrivate {
428428
// ---------------------------------------------------------------------------
429429
// marshal
430430
// ---------------------------------------------------------------------------
431+
/**
432+
* A call to `marshal.load`
433+
* See https://docs.python.org/3/library/marshal.html#marshal.load
434+
*/
435+
private class MarshalLoadCall extends Decoding::Range, DataFlow::CallCfgNode {
436+
MarshalLoadCall() { this = API::moduleImport("marshal").getMember("load").getACall() }
437+
438+
override predicate mayExecuteInput() { any() }
439+
440+
override DataFlow::Node getAnInput() { result = this.getArg(0) }
441+
442+
override DataFlow::Node getOutput() { result = this }
443+
444+
override string getFormat() { result = "marshal" }
445+
}
446+
431447
/**
432448
* A call to `marshal.loads`
433449
* See https://docs.python.org/3/library/marshal.html#marshal.loads

python/ql/test/library-tests/frameworks/stdlib/Decoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# using this keyword argument is disallowed from Python 3.9
1010
pickle.loads(data=payload) # $ decodeInput=payload decodeOutput=pickle.loads(..) decodeFormat=pickle decodeMayExecuteInput
1111

12-
marshal.load(file_) # $ MISSING: decodeInput=file_ decodeOutput=marshal.load(..) decodeFormat=marshal decodeMayExecuteInput
12+
marshal.load(file_) # $ decodeInput=file_ decodeOutput=marshal.load(..) decodeFormat=marshal decodeMayExecuteInput
1313
marshal.loads(payload) # $ decodeInput=payload decodeOutput=marshal.loads(..) decodeFormat=marshal decodeMayExecuteInput
1414

1515

0 commit comments

Comments
 (0)