NEVER MERGE: Ensure we don't use site-packages stuff

This commit is contained in:
Rasmus Wriedt Larsen
2023-12-18 22:38:26 +01:00
parent de2a563a8e
commit ca7b69ec1f
2 changed files with 3 additions and 0 deletions

View File

@@ -838,6 +838,7 @@ module API {
// Subclassing a node
lbl = Label::subclass() and
exists(PY::ClassExpr clsExpr, DataFlow::Node superclass | pred.flowsTo(superclass) |
exists(clsExpr.getLocation().getFile().getRelativePath()) and
clsExpr.getABase() = superclass.asExpr() and
// Potentially a class decorator could do anything, but we assume they are
// "benign" and let subclasses edges flow through anyway.

View File

@@ -36,6 +36,7 @@ private import semmle.python.dataflow.new.internal.ImportStar
class LocalSourceNode extends Node {
cached
LocalSourceNode() {
exists(this.getLocation().getFile().getRelativePath()) and (
Stages::DataFlow::ref() and
this instanceof ExprNode and
not simpleLocalFlowStepForTypetracking(_, this)
@@ -72,6 +73,7 @@ class LocalSourceNode extends Node {
// We include all scope entry definitions, as these act as the local source within the scope they
// enter.
this.asCfgNode() = any(ScopeEntryDefinition def).getDefiningNode()
)
}
/** Holds if this `LocalSourceNode` can flow to `nodeTo` in one or more local flow steps. */