Skip to content

Commit aa5eee1

Browse files
committed
Python: Revert manual pickle modeling
This reverts commit 62910f0. This reverts commit 75a8197. We don't find `kombu.serialization.pickle_load` since we respect `__all__`. I think that was an attempt to not flood the captured modeling with useless re-exports, but I think we've ended up doing that anyway... we should consider to remove that restriction! see https://github.com/celery/kombu/blob/21d7df29c7d4a1dfb8586f24ca6eaf65b9c8cc16/kombu/serialization.py#L29
1 parent f74581a commit aa5eee1

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,20 +1299,35 @@ module StdlibPrivate {
12991299
// ---------------------------------------------------------------------------
13001300
/** Gets a reference to any of the `pickle` modules. */
13011301
API::Node pickle() {
1302-
result = API::moduleImport(["pickle", "cPickle", "_pickle", "cloudpickle"]) or
1303-
result = API::moduleImport("kombu").getMember("serialization").getMember("pickle")
1302+
result = API::moduleImport(["pickle", "cPickle", "_pickle"])
1303+
or
1304+
result = ModelOutput::getATypeNode("pickle~Alias")
1305+
}
1306+
1307+
/**
1308+
* A reference to `pickle.load`
1309+
*/
1310+
API::Node pickle_load() {
1311+
result = pickle().getMember("load")
1312+
or
1313+
result = ModelOutput::getATypeNode("pickle.load~Alias")
1314+
}
1315+
1316+
/**
1317+
* A reference to `pickle.loads`
1318+
*/
1319+
API::Node pickle_loads() {
1320+
result = pickle().getMember("loads")
1321+
or
1322+
result = ModelOutput::getATypeNode("pickle.loads~Alias")
13041323
}
13051324

13061325
/**
13071326
* A call to `pickle.load`
13081327
* See https://docs.python.org/3/library/pickle.html#pickle.load
13091328
*/
1310-
private class PickleLoadCall extends Decoding::Range, DataFlow::CallCfgNode {
1311-
PickleLoadCall() {
1312-
this = pickle().getMember("load").getACall() or
1313-
this =
1314-
API::moduleImport("kombu").getMember("serialization").getMember("pickle_load").getACall()
1315-
}
1329+
private class PickleLoadCall extends Decoding::Range, API::CallNode {
1330+
PickleLoadCall() { this = pickle_load().getACall() }
13161331

13171332
override predicate mayExecuteInput() { any() }
13181333

@@ -1327,8 +1342,8 @@ module StdlibPrivate {
13271342
* A call to `pickle.loads`
13281343
* See https://docs.python.org/3/library/pickle.html#pickle.loads
13291344
*/
1330-
private class PickleLoadsCall extends Decoding::Range, DataFlow::CallCfgNode {
1331-
PickleLoadsCall() { this = pickle().getMember("loads").getACall() }
1345+
private class PickleLoadsCall extends Decoding::Range, API::CallNode {
1346+
PickleLoadsCall() { this = pickle_loads().getACall() }
13321347

13331348
override predicate mayExecuteInput() { any() }
13341349

python/ql/src/meta/ClassHierarchy/Find.ql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,24 @@ class LxmlETreeAlias extends FindSubclassesSpec {
464464
override API::Node getAlreadyModeledClass() { result = Lxml::etreeRef() }
465465
}
466466

467+
class PickleAlias extends FindSubclassesSpec {
468+
PickleAlias() { this = "pickle~Alias" }
469+
470+
override API::Node getAlreadyModeledClass() { result = StdlibPrivate::pickle() }
471+
}
472+
473+
class PickleLoadAlias extends FindSubclassesSpec {
474+
PickleLoadAlias() { this = "pickle.load~Alias" }
475+
476+
override API::Node getAlreadyModeledClass() { result = StdlibPrivate::pickle_load() }
477+
}
478+
479+
class PickleLoadsAlias extends FindSubclassesSpec {
480+
PickleLoadsAlias() { this = "pickle.loads~Alias" }
481+
482+
override API::Node getAlreadyModeledClass() { result = StdlibPrivate::pickle_loads() }
483+
}
484+
467485
bindingset[fullyQualified]
468486
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
469487
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |

0 commit comments

Comments
 (0)