mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Python: Model json load/dump
This commit is contained in:
@@ -518,6 +518,22 @@ private module Stdlib {
|
||||
override string getFormat() { result = "JSON" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `json.load`
|
||||
* See https://docs.python.org/3/library/json.html#json.load
|
||||
*/
|
||||
private class JsonLoadCall extends Decoding::Range, DataFlow::CallCfgNode {
|
||||
JsonLoadCall() { this = json().getMember("load").getACall() }
|
||||
|
||||
override predicate mayExecuteInput() { none() }
|
||||
|
||||
override DataFlow::Node getAnInput() { result in [this.getArg(0), this.getArgByName("fp")] }
|
||||
|
||||
override DataFlow::Node getOutput() { result = this }
|
||||
|
||||
override string getFormat() { result = "JSON" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `json.dumps`
|
||||
* See https://docs.python.org/3/library/json.html#json.dumps
|
||||
@@ -532,6 +548,24 @@ private module Stdlib {
|
||||
override string getFormat() { result = "JSON" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to `json.dump`
|
||||
* See https://docs.python.org/3/library/json.html#json.dump
|
||||
*/
|
||||
private class JsonDumpCall extends Encoding::Range, DataFlow::CallCfgNode {
|
||||
JsonDumpCall() { this = json().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" }
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// cgi
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user