Python: Move concept tests out

These tests should be fleshed out at some point, but currently
they test all that we model.
This commit is contained in:
Rasmus Lerchedahl Petersen
2020-10-13 13:06:47 +02:00
parent 4685f2d5f2
commit b7e8b48e9e
11 changed files with 62 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ private module Dill {
/** Gets a reference to the `dill` module. */
DataFlow::Node dill() { result = dill(DataFlow::TypeTracker::end()) }
/** Provides models for the `dill` module. */
module dill {
/** Gets a reference to the `dill.loads` function. */
private DataFlow::Node loads(DataFlow::TypeTracker t) {
@@ -55,5 +56,10 @@ private class DillDeserialization extends UnmarshalingFunction::Range {
override DataFlow::Node getOutput() { result = this }
override string getFormat() { none() }
override string getFormat() {
result = this.asCfgNode().(CallNode).getArgByName("encoding").(NameNode).getId()
or
not exists(this.asCfgNode().(CallNode).getArgByName("encoding")) and
result = "ASCII"
}
}

View File

@@ -342,6 +342,7 @@ private module Stdlib {
/** Gets a reference to the `marshal` module. */
DataFlow::Node marshal() { result = marshal(DataFlow::TypeTracker::end()) }
/** Provides models for the `marshal` module. */
module marshal {
/** Gets a reference to the `marshal.loads` function. */
private DataFlow::Node loads(DataFlow::TypeTracker t) {
@@ -394,6 +395,7 @@ private module Stdlib {
/** Gets a reference to the `pickle` module. */
DataFlow::Node pickle() { result = pickle(DataFlow::TypeTracker::end()) }
/** Provides models for the `pickle` module. */
module pickle {
/** Gets a reference to the `pickle.loads` function. */
private DataFlow::Node loads(DataFlow::TypeTracker t) {
@@ -429,6 +431,9 @@ private module Stdlib {
override string getFormat() {
result = this.asCfgNode().(CallNode).getArgByName("encoding").(NameNode).getId()
or
not exists(this.asCfgNode().(CallNode).getArgByName("encoding")) and
result = "ASCII"
}
}
}

View File

@@ -20,6 +20,7 @@ private module Yaml {
/** Gets a reference to the `yaml` module. */
DataFlow::Node yaml() { result = yaml(DataFlow::TypeTracker::end()) }
/** Provides models for the `yaml` module. */
module yaml {
/** Gets a reference to the `yaml.load` function. */
private DataFlow::Node load(DataFlow::TypeTracker t) {