-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathSimplejson.qll
More file actions
84 lines (65 loc) · 2.74 KB
/
Simplejson.qll
File metadata and controls
84 lines (65 loc) · 2.74 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Provides classes modeling security-relevant aspects of the `simplejson` PyPI package.
* See https://simplejson.readthedocs.io/en/latest/.
*/
private import python
private import semmle.python.dataflow.new.DataFlow
private import semmle.python.dataflow.new.TaintTracking
private import semmle.python.Concepts
private import semmle.python.ApiGraphs
/**
* Provides models for the `simplejson` PyPI package.
* See https://simplejson.readthedocs.io/en/latest/.
*/
private module SimplejsonModel {
/**
* A call to `simplejson.dumps`.
*
* See https://simplejson.readthedocs.io/en/latest/#simplejson.dumps
*/
private class SimplejsonDumpsCall extends Encoding::Range, DataFlow::CallCfgNode {
SimplejsonDumpsCall() { this = API::moduleImport("simplejson").getMember("dumps").getACall() }
override DataFlow::Node getAnInput() { result in [this.getArg(0), this.getArgByName("obj")] }
override DataFlow::Node getOutput() { result = this }
override string getFormat() { result = "JSON" }
}
/**
* A call to `simplejson.dump`.
*
* See https://simplejson.readthedocs.io/en/latest/#simplejson.dump
*/
private class SimplejsonDumpCall extends Encoding::Range, DataFlow::CallCfgNode {
SimplejsonDumpCall() { this = API::moduleImport("simplejson").getMember("dump").getACall() }
override DataFlow::Node getAnInput() { result in [this.getArg(0), this.getArgByName("obj")] }
override DataFlow::Node getOutput() {
result.(DataFlow::PostUpdateNode).getPreUpdateNode() in [
this.getArg(1), this.getArgByName("fp")
]
}
override string getFormat() { result = "JSON" }
}
/**
* A call to `simplejson.loads`.
*
* See https://simplejson.readthedocs.io/en/latest/#simplejson.loads
*/
private class SimplejsonLoadsCall extends Decoding::Range, DataFlow::CallCfgNode {
SimplejsonLoadsCall() { this = API::moduleImport("simplejson").getMember("loads").getACall() }
override DataFlow::Node getAnInput() { result in [this.getArg(0), this.getArgByName("s")] }
override DataFlow::Node getOutput() { result = this }
override string getFormat() { result = "JSON" }
override predicate mayExecuteInput() { none() }
}
/**
* A call to `simplejson.load`.
*
* See https://simplejson.readthedocs.io/en/latest/#simplejson.load
*/
private class SimplejsonLoadCall extends Decoding::Range, DataFlow::CallCfgNode {
SimplejsonLoadCall() { this = API::moduleImport("simplejson").getMember("load").getACall() }
override DataFlow::Node getAnInput() { result in [this.getArg(0), this.getArgByName("fp")] }
override DataFlow::Node getOutput() { result = this }
override string getFormat() { result = "JSON" }
override predicate mayExecuteInput() { none() }
}
}