From 78c33ab55a2c9fbb8a26c0cf313d878fc64a2eb5 Mon Sep 17 00:00:00 2001 From: Taus Date: Thu, 30 Oct 2025 16:37:28 +0000 Subject: [PATCH] Python: Remove points-to references from `python.qll` For now, these have just been made into `private` imports. After doing this, I went through all of the (now not compiling) files and added in private imports to the modules that they actually depended on. I also added an explicit import of `LegacyPointsTo` (even though it may be unnecessary) in cases where the points-to dependency was somewhat surprising (and one we want to get rid of). This was primarily inside the various SSA layers. For modules inside `semmle.python.{types, objects, pointsto}` I did not bother, as these are fairly clearly related to points-to. --- python/ql/lib/LegacyPointsTo.qll | 17 ++++++++++-- python/ql/lib/analysis/DefinitionTracking.qll | 1 - python/ql/lib/python.qll | 26 +++++++++---------- python/ql/lib/semmle/python/Flow.qll | 1 + python/ql/lib/semmle/python/SSA.qll | 1 + python/ql/lib/semmle/python/SelfAttribute.qll | 1 + .../new/internal/ImportResolution.qll | 1 + .../python/dataflow/old/Configuration.qll | 2 +- .../lib/semmle/python/dataflow/old/Files.qll | 1 + .../python/dataflow/old/Implementation.qll | 1 - .../python/dataflow/old/StateTracking.qll | 4 +-- .../python/dataflow/old/TaintTracking.qll | 1 - .../python/dependencies/DependencyKind.qll | 1 + .../python/dependencies/TechInventory.qll | 1 + .../ql/lib/semmle/python/essa/Definitions.qll | 4 ++- python/ql/lib/semmle/python/essa/Essa.qll | 2 ++ .../lib/semmle/python/essa/SsaDefinitions.qll | 1 + .../ql/lib/semmle/python/libraries/Zope.qll | 2 +- .../lib/semmle/python/objects/Constants.qll | 1 + .../lib/semmle/python/objects/Descriptors.qll | 1 + .../lib/semmle/python/objects/Instances.qll | 2 ++ .../ql/lib/semmle/python/objects/Modules.qll | 1 + .../lib/semmle/python/objects/ObjectAPI.qll | 3 --- .../ql/lib/semmle/python/objects/TObject.qll | 1 + python/ql/lib/semmle/python/pointsto/Base.qll | 2 ++ .../lib/semmle/python/pointsto/CallGraph.qll | 2 ++ .../lib/semmle/python/pointsto/PointsTo.qll | 5 ++++ .../python/pointsto/PointsToContext.qll | 2 ++ .../ql/lib/semmle/python/types/Builtins.qll | 1 + .../lib/semmle/python/types/ClassObject.qll | 1 + .../lib/semmle/python/types/Descriptors.qll | 3 +++ .../ql/lib/semmle/python/types/Extensions.qll | 1 + .../semmle/python/types/FunctionObject.qll | 3 --- .../ql/lib/semmle/python/types/ModuleKind.qll | 1 + .../lib/semmle/python/types/ModuleObject.qll | 3 +++ python/ql/lib/semmle/python/types/Object.qll | 1 - .../semmle/python/values/StringAttributes.qll | 3 --- .../src/Expressions/ContainsNonContainer.ql | 1 - python/ql/src/Expressions/IsComparisons.qll | 1 + .../ql/src/Statements/RedundantAssignment.ql | 1 + python/ql/src/Variables/UndefinedGlobal.ql | 1 - python/ql/src/Variables/UninitializedLocal.ql | 1 - python/ql/src/analysis/Efficiency.ql | 2 -- 43 files changed, 73 insertions(+), 39 deletions(-) diff --git a/python/ql/lib/LegacyPointsTo.qll b/python/ql/lib/LegacyPointsTo.qll index 3e675854601..bc2a6b7804a 100644 --- a/python/ql/lib/LegacyPointsTo.qll +++ b/python/ql/lib/LegacyPointsTo.qll @@ -20,8 +20,21 @@ */ private import python -private import semmle.python.pointsto.PointsTo -private import semmle.python.objects.Modules +import semmle.python.pointsto.Base +import semmle.python.pointsto.Context +import semmle.python.pointsto.PointsTo +import semmle.python.pointsto.PointsToContext +import semmle.python.objects.ObjectAPI +import semmle.python.objects.ObjectInternal +import semmle.python.types.Object +import semmle.python.types.ClassObject +import semmle.python.types.FunctionObject +import semmle.python.types.ModuleObject +import semmle.python.types.Exceptions +import semmle.python.types.Properties +import semmle.python.types.ImportTime +import semmle.python.types.Descriptors +import semmle.python.SelfAttribute /** * An extension of `ControlFlowNode` that provides points-to predicates. diff --git a/python/ql/lib/analysis/DefinitionTracking.qll b/python/ql/lib/analysis/DefinitionTracking.qll index 53f8e791cd8..c019e92c0ca 100644 --- a/python/ql/lib/analysis/DefinitionTracking.qll +++ b/python/ql/lib/analysis/DefinitionTracking.qll @@ -4,7 +4,6 @@ import python private import LegacyPointsTo -import semmle.python.pointsto.PointsTo import IDEContextual private newtype TDefinition = diff --git a/python/ql/lib/python.qll b/python/ql/lib/python.qll index b08f0ae35bb..d127e297dbb 100644 --- a/python/ql/lib/python.qll +++ b/python/ql/lib/python.qll @@ -19,22 +19,22 @@ import semmle.python.Constants import semmle.python.Scope import semmle.python.Comment import semmle.python.GuardedControlFlow -import semmle.python.types.ImportTime -import semmle.python.types.Object -import semmle.python.types.ClassObject -import semmle.python.types.FunctionObject -import semmle.python.types.ModuleObject -import semmle.python.types.Version -import semmle.python.types.Descriptors +private import semmle.python.types.ImportTime +private import semmle.python.types.Object +private import semmle.python.types.ClassObject +private import semmle.python.types.FunctionObject +private import semmle.python.types.ModuleObject +private import semmle.python.types.Version +private import semmle.python.types.Descriptors import semmle.python.SSA -import semmle.python.SelfAttribute -import semmle.python.types.Properties +private import semmle.python.SelfAttribute +private import semmle.python.types.Properties import semmle.python.xml.XML import semmle.python.essa.Essa -import semmle.python.pointsto.Base -import semmle.python.pointsto.Context -import semmle.python.pointsto.CallGraph -import semmle.python.objects.ObjectAPI +private import semmle.python.pointsto.Base +private import semmle.python.pointsto.Context +private import semmle.python.pointsto.CallGraph +private import semmle.python.objects.ObjectAPI import semmle.python.Unit import site private import semmle.python.Overlay diff --git a/python/ql/lib/semmle/python/Flow.qll b/python/ql/lib/semmle/python/Flow.qll index 496c1abc52a..6574979f9c8 100644 --- a/python/ql/lib/semmle/python/Flow.qll +++ b/python/ql/lib/semmle/python/Flow.qll @@ -1,6 +1,7 @@ import python private import semmle.python.internal.CachedStages private import codeql.controlflow.BasicBlock as BB +private import LegacyPointsTo /* * Note about matching parent and child nodes and CFG splitting: diff --git a/python/ql/lib/semmle/python/SSA.qll b/python/ql/lib/semmle/python/SSA.qll index 98cd39a4c43..a139f22dfc6 100644 --- a/python/ql/lib/semmle/python/SSA.qll +++ b/python/ql/lib/semmle/python/SSA.qll @@ -1,6 +1,7 @@ /** SSA library */ import python +private import LegacyPointsTo /** * A single static assignment variable. diff --git a/python/ql/lib/semmle/python/SelfAttribute.qll b/python/ql/lib/semmle/python/SelfAttribute.qll index 01a110999ba..90ef2b38401 100644 --- a/python/ql/lib/semmle/python/SelfAttribute.qll +++ b/python/ql/lib/semmle/python/SelfAttribute.qll @@ -5,6 +5,7 @@ import python private import semmle.python.pointsto.Filters +private import LegacyPointsTo /** * An attribute access where the left hand side of the attribute expression diff --git a/python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll b/python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll index e1290b7758c..f3943f53f86 100644 --- a/python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll +++ b/python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll @@ -9,6 +9,7 @@ private import semmle.python.dataflow.new.DataFlow private import semmle.python.dataflow.new.internal.ImportStar private import semmle.python.dataflow.new.TypeTracking private import semmle.python.dataflow.new.internal.DataFlowPrivate +private import semmle.python.essa.SsaDefinitions /** * Python modules and the way imports are resolved are... complicated. Here's a crash course in how diff --git a/python/ql/lib/semmle/python/dataflow/old/Configuration.qll b/python/ql/lib/semmle/python/dataflow/old/Configuration.qll index 7d03e6c562f..f0e33169cf2 100644 --- a/python/ql/lib/semmle/python/dataflow/old/Configuration.qll +++ b/python/ql/lib/semmle/python/dataflow/old/Configuration.qll @@ -1,6 +1,6 @@ import python import semmle.python.dataflow.TaintTracking -private import semmle.python.objects.ObjectInternal +private import LegacyPointsTo private import semmle.python.dataflow.Implementation module TaintTracking { diff --git a/python/ql/lib/semmle/python/dataflow/old/Files.qll b/python/ql/lib/semmle/python/dataflow/old/Files.qll index 3439e559efa..18537768445 100644 --- a/python/ql/lib/semmle/python/dataflow/old/Files.qll +++ b/python/ql/lib/semmle/python/dataflow/old/Files.qll @@ -1,4 +1,5 @@ import python +private import LegacyPointsTo import semmle.python.dataflow.TaintTracking class OpenFile extends TaintKind { diff --git a/python/ql/lib/semmle/python/dataflow/old/Implementation.qll b/python/ql/lib/semmle/python/dataflow/old/Implementation.qll index 83476db803c..eb7e5fdc9a5 100644 --- a/python/ql/lib/semmle/python/dataflow/old/Implementation.qll +++ b/python/ql/lib/semmle/python/dataflow/old/Implementation.qll @@ -1,7 +1,6 @@ import python private import LegacyPointsTo import semmle.python.dataflow.TaintTracking -private import semmle.python.objects.ObjectInternal private import semmle.python.pointsto.Filters as Filters import semmle.python.dataflow.Legacy diff --git a/python/ql/lib/semmle/python/dataflow/old/StateTracking.qll b/python/ql/lib/semmle/python/dataflow/old/StateTracking.qll index 2ca9be0dfb9..0eeb103ee55 100644 --- a/python/ql/lib/semmle/python/dataflow/old/StateTracking.qll +++ b/python/ql/lib/semmle/python/dataflow/old/StateTracking.qll @@ -9,9 +9,7 @@ */ import python -private import semmle.python.pointsto.PointsTo -private import semmle.python.pointsto.PointsToContext -private import semmle.python.objects.ObjectInternal +private import LegacyPointsTo /** A state that should be tracked. */ abstract class TrackableState extends string { diff --git a/python/ql/lib/semmle/python/dataflow/old/TaintTracking.qll b/python/ql/lib/semmle/python/dataflow/old/TaintTracking.qll index 15459a31043..8dfa344f458 100644 --- a/python/ql/lib/semmle/python/dataflow/old/TaintTracking.qll +++ b/python/ql/lib/semmle/python/dataflow/old/TaintTracking.qll @@ -89,7 +89,6 @@ import python private import LegacyPointsTo private import semmle.python.pointsto.Filters as Filters -private import semmle.python.objects.ObjectInternal private import semmle.python.dataflow.Implementation import semmle.python.dataflow.Configuration diff --git a/python/ql/lib/semmle/python/dependencies/DependencyKind.qll b/python/ql/lib/semmle/python/dependencies/DependencyKind.qll index 2e4fab1af0b..4ceda85ff41 100644 --- a/python/ql/lib/semmle/python/dependencies/DependencyKind.qll +++ b/python/ql/lib/semmle/python/dependencies/DependencyKind.qll @@ -1,4 +1,5 @@ import semmle.python.dependencies.Dependencies +private import LegacyPointsTo /** * A library describing an abstract mechanism for representing dependency categories. diff --git a/python/ql/lib/semmle/python/dependencies/TechInventory.qll b/python/ql/lib/semmle/python/dependencies/TechInventory.qll index 20a938b86d0..2c29a05c48b 100644 --- a/python/ql/lib/semmle/python/dependencies/TechInventory.qll +++ b/python/ql/lib/semmle/python/dependencies/TechInventory.qll @@ -1,6 +1,7 @@ import python import semmle.python.dependencies.Dependencies import semmle.python.dependencies.DependencyKind +private import LegacyPointsTo /** * Combine the source-file and package into a single string: diff --git a/python/ql/lib/semmle/python/essa/Definitions.qll b/python/ql/lib/semmle/python/essa/Definitions.qll index 9c0df69c28e..d9426fc5612 100644 --- a/python/ql/lib/semmle/python/essa/Definitions.qll +++ b/python/ql/lib/semmle/python/essa/Definitions.qll @@ -1,5 +1,4 @@ import python - /* * Classification of variables. These should be non-overlapping and complete. * @@ -12,6 +11,9 @@ import python * Escaping globals -- Global variables that have definitions and at least one of those definitions is in another scope. */ +private import LegacyPointsTo +private import semmle.python.essa.SsaDefinitions + /** A source language variable, to be converted into a set of SSA variables. */ abstract class SsaSourceVariable extends @py_variable { SsaSourceVariable() { diff --git a/python/ql/lib/semmle/python/essa/Essa.qll b/python/ql/lib/semmle/python/essa/Essa.qll index cf2aca1e2ac..1b83f8df6ac 100644 --- a/python/ql/lib/semmle/python/essa/Essa.qll +++ b/python/ql/lib/semmle/python/essa/Essa.qll @@ -6,6 +6,8 @@ import python private import SsaCompute import semmle.python.essa.Definitions private import semmle.python.internal.CachedStages +private import LegacyPointsTo +private import semmle.python.essa.SsaDefinitions /** An (enhanced) SSA variable derived from `SsaSourceVariable`. */ class EssaVariable extends TEssaDefinition { diff --git a/python/ql/lib/semmle/python/essa/SsaDefinitions.qll b/python/ql/lib/semmle/python/essa/SsaDefinitions.qll index 0c1c8836f4e..2b15f1a2ab2 100644 --- a/python/ql/lib/semmle/python/essa/SsaDefinitions.qll +++ b/python/ql/lib/semmle/python/essa/SsaDefinitions.qll @@ -5,6 +5,7 @@ import python private import semmle.python.internal.CachedStages +private import LegacyPointsTo cached module SsaSource { diff --git a/python/ql/lib/semmle/python/libraries/Zope.qll b/python/ql/lib/semmle/python/libraries/Zope.qll index fea3cecf418..defea3e4720 100644 --- a/python/ql/lib/semmle/python/libraries/Zope.qll +++ b/python/ql/lib/semmle/python/libraries/Zope.qll @@ -1,7 +1,7 @@ /** Utilities for handling the zope libraries */ import python -private import semmle.python.pointsto.PointsTo +private import LegacyPointsTo /** A method that belongs to a sub-class of `zope.interface.Interface` */ class ZopeInterfaceMethodValue extends PythonFunctionValue { diff --git a/python/ql/lib/semmle/python/objects/Constants.qll b/python/ql/lib/semmle/python/objects/Constants.qll index 31b63399ff4..49221df5b67 100644 --- a/python/ql/lib/semmle/python/objects/Constants.qll +++ b/python/ql/lib/semmle/python/objects/Constants.qll @@ -5,6 +5,7 @@ private import semmle.python.pointsto.PointsTo private import semmle.python.pointsto.MRO private import semmle.python.pointsto.PointsToContext private import semmle.python.types.Builtins +private import semmle.python.objects.ObjectAPI /** * A constant. diff --git a/python/ql/lib/semmle/python/objects/Descriptors.qll b/python/ql/lib/semmle/python/objects/Descriptors.qll index 2c18708e16a..5cb855ee5ca 100644 --- a/python/ql/lib/semmle/python/objects/Descriptors.qll +++ b/python/ql/lib/semmle/python/objects/Descriptors.qll @@ -5,6 +5,7 @@ private import semmle.python.pointsto.PointsTo private import semmle.python.pointsto.PointsToContext private import semmle.python.pointsto.MRO private import semmle.python.types.Builtins +private import semmle.python.pointsto.Context /** A property object. */ class PropertyInternal extends ObjectInternal, TProperty { diff --git a/python/ql/lib/semmle/python/objects/Instances.qll b/python/ql/lib/semmle/python/objects/Instances.qll index 0b4187b6928..2ae00502902 100644 --- a/python/ql/lib/semmle/python/objects/Instances.qll +++ b/python/ql/lib/semmle/python/objects/Instances.qll @@ -5,6 +5,8 @@ private import semmle.python.pointsto.PointsTo private import semmle.python.pointsto.MRO private import semmle.python.pointsto.PointsToContext private import semmle.python.types.Builtins +private import semmle.python.pointsto.Context +private import semmle.python.pointsto.Base /** A class representing instances */ abstract class InstanceObject extends ObjectInternal { diff --git a/python/ql/lib/semmle/python/objects/Modules.qll b/python/ql/lib/semmle/python/objects/Modules.qll index e523ad0b70a..8c5653fa2a3 100644 --- a/python/ql/lib/semmle/python/objects/Modules.qll +++ b/python/ql/lib/semmle/python/objects/Modules.qll @@ -5,6 +5,7 @@ private import semmle.python.pointsto.PointsTo private import semmle.python.pointsto.MRO private import semmle.python.pointsto.PointsToContext private import semmle.python.types.Builtins +private import semmle.python.types.ImportTime /** A class representing modules */ abstract class ModuleObjectInternal extends ObjectInternal { diff --git a/python/ql/lib/semmle/python/objects/ObjectAPI.qll b/python/ql/lib/semmle/python/objects/ObjectAPI.qll index 45247c5d9d4..a5d4d91cc7a 100644 --- a/python/ql/lib/semmle/python/objects/ObjectAPI.qll +++ b/python/ql/lib/semmle/python/objects/ObjectAPI.qll @@ -6,9 +6,6 @@ import python private import LegacyPointsTo private import TObject -private import semmle.python.objects.ObjectInternal -private import semmle.python.pointsto.PointsTo -private import semmle.python.pointsto.PointsToContext private import semmle.python.pointsto.MRO private import semmle.python.types.Builtins diff --git a/python/ql/lib/semmle/python/objects/TObject.qll b/python/ql/lib/semmle/python/objects/TObject.qll index 12b4dc901c3..c041827ff5a 100644 --- a/python/ql/lib/semmle/python/objects/TObject.qll +++ b/python/ql/lib/semmle/python/objects/TObject.qll @@ -6,6 +6,7 @@ private import semmle.python.objects.ObjectInternal private import semmle.python.pointsto.PointsTo private import semmle.python.pointsto.PointsToContext private import semmle.python.internal.CachedStages +private import semmle.python.pointsto.Context /** * Internal type backing `ObjectInternal` and `Value` diff --git a/python/ql/lib/semmle/python/pointsto/Base.qll b/python/ql/lib/semmle/python/pointsto/Base.qll index 56dc633eb9c..c3f10778cda 100644 --- a/python/ql/lib/semmle/python/pointsto/Base.qll +++ b/python/ql/lib/semmle/python/pointsto/Base.qll @@ -12,6 +12,8 @@ import python import semmle.python.essa.SsaDefinitions private import semmle.python.types.Builtins private import semmle.python.internal.CachedStages +private import semmle.python.types.Object +private import semmle.python.types.ClassObject /* * The following predicates exist in order to provide diff --git a/python/ql/lib/semmle/python/pointsto/CallGraph.qll b/python/ql/lib/semmle/python/pointsto/CallGraph.qll index da225439588..734a5540254 100644 --- a/python/ql/lib/semmle/python/pointsto/CallGraph.qll +++ b/python/ql/lib/semmle/python/pointsto/CallGraph.qll @@ -11,6 +11,8 @@ import python private import semmle.python.pointsto.PointsToContext +private import semmle.python.types.FunctionObject +private import semmle.python.pointsto.Context private newtype TTInvocation = TInvocation(FunctionObject f, Context c) { diff --git a/python/ql/lib/semmle/python/pointsto/PointsTo.qll b/python/ql/lib/semmle/python/pointsto/PointsTo.qll index 56e8f6d6a63..ce1485c3f3d 100644 --- a/python/ql/lib/semmle/python/pointsto/PointsTo.qll +++ b/python/ql/lib/semmle/python/pointsto/PointsTo.qll @@ -7,6 +7,11 @@ private import semmle.python.pointsto.MRO private import semmle.python.types.Builtins private import semmle.python.types.Extensions private import semmle.python.internal.CachedStages +private import semmle.python.types.Object +private import semmle.python.types.FunctionObject +private import semmle.python.types.ClassObject +private import semmle.python.pointsto.Base +private import semmle.python.types.ImportTime /* Use this version for speed */ class CfgOrigin extends @py_object { diff --git a/python/ql/lib/semmle/python/pointsto/PointsToContext.qll b/python/ql/lib/semmle/python/pointsto/PointsToContext.qll index d68ce93e576..fb005b8f046 100644 --- a/python/ql/lib/semmle/python/pointsto/PointsToContext.qll +++ b/python/ql/lib/semmle/python/pointsto/PointsToContext.qll @@ -1,6 +1,8 @@ import python private import semmle.python.pointsto.PointsTo private import semmle.python.objects.ObjectInternal +private import semmle.python.types.ImportTime +private import semmle.python.types.Version /* * A note on 'cost'. Cost doesn't represent the cost to compute, diff --git a/python/ql/lib/semmle/python/types/Builtins.qll b/python/ql/lib/semmle/python/types/Builtins.qll index e6a21e1b717..796397f72cd 100644 --- a/python/ql/lib/semmle/python/types/Builtins.qll +++ b/python/ql/lib/semmle/python/types/Builtins.qll @@ -1,4 +1,5 @@ import python +private import LegacyPointsTo class Builtin extends @py_cobject { Builtin() { diff --git a/python/ql/lib/semmle/python/types/ClassObject.qll b/python/ql/lib/semmle/python/types/ClassObject.qll index 6954a83463c..fbea3acdb5b 100644 --- a/python/ql/lib/semmle/python/types/ClassObject.qll +++ b/python/ql/lib/semmle/python/types/ClassObject.qll @@ -6,6 +6,7 @@ private import semmle.python.pointsto.PointsTo private import semmle.python.pointsto.MRO private import semmle.python.types.Builtins private import semmle.python.objects.ObjectInternal +private import semmle.python.types.ImportTime /** * A class whose instances represents Python classes. diff --git a/python/ql/lib/semmle/python/types/Descriptors.qll b/python/ql/lib/semmle/python/types/Descriptors.qll index 6a5743c444a..7a81142a4f2 100644 --- a/python/ql/lib/semmle/python/types/Descriptors.qll +++ b/python/ql/lib/semmle/python/types/Descriptors.qll @@ -1,5 +1,8 @@ import python private import semmle.python.objects.ObjectInternal +private import semmle.python.types.Object +private import semmle.python.types.FunctionObject +private import semmle.python.pointsto.Context /** A class method object. Either a decorated function or an explicit call to classmethod(f) */ class ClassMethodObject extends Object { diff --git a/python/ql/lib/semmle/python/types/Extensions.qll b/python/ql/lib/semmle/python/types/Extensions.qll index f6c824f9ab2..d292f568fb9 100644 --- a/python/ql/lib/semmle/python/types/Extensions.qll +++ b/python/ql/lib/semmle/python/types/Extensions.qll @@ -16,6 +16,7 @@ private import semmle.python.pointsto.PointsToContext private import semmle.python.objects.TObject /* Make ObjectInternal visible to save extra imports in user code */ import semmle.python.objects.ObjectInternal +import semmle.python.pointsto.Context abstract class PointsToExtension extends @py_flow_node { string toString() { result = "PointsToExtension with missing toString" } diff --git a/python/ql/lib/semmle/python/types/FunctionObject.qll b/python/ql/lib/semmle/python/types/FunctionObject.qll index 72ddb9411fb..7ff0f37ca9a 100644 --- a/python/ql/lib/semmle/python/types/FunctionObject.qll +++ b/python/ql/lib/semmle/python/types/FunctionObject.qll @@ -1,10 +1,7 @@ import python private import LegacyPointsTo -import semmle.python.types.Exceptions -private import semmle.python.pointsto.PointsTo private import semmle.python.objects.Callables private import semmle.python.libraries.Zope -private import semmle.python.objects.ObjectInternal private import semmle.python.types.Builtins /** A function object, whether written in Python or builtin */ diff --git a/python/ql/lib/semmle/python/types/ModuleKind.qll b/python/ql/lib/semmle/python/types/ModuleKind.qll index ef44d80701e..03b64396bae 100644 --- a/python/ql/lib/semmle/python/types/ModuleKind.qll +++ b/python/ql/lib/semmle/python/types/ModuleKind.qll @@ -1,4 +1,5 @@ import python +private import semmle.python.types.ModuleObject private predicate is_normal_module(ModuleObject m) { m instanceof BuiltinModuleObject diff --git a/python/ql/lib/semmle/python/types/ModuleObject.qll b/python/ql/lib/semmle/python/types/ModuleObject.qll index 2e6d3863801..0dfa96e7050 100644 --- a/python/ql/lib/semmle/python/types/ModuleObject.qll +++ b/python/ql/lib/semmle/python/types/ModuleObject.qll @@ -2,6 +2,9 @@ import python private import semmle.python.pointsto.PointsTo private import semmle.python.objects.ObjectInternal private import semmle.python.types.ModuleKind +private import semmle.python.types.Object +private import semmle.python.types.ClassObject +private import semmle.python.objects.ObjectAPI abstract class ModuleObject extends Object { ModuleValue theModule() { diff --git a/python/ql/lib/semmle/python/types/Object.qll b/python/ql/lib/semmle/python/types/Object.qll index 1e0868648be..4c88f46dde8 100644 --- a/python/ql/lib/semmle/python/types/Object.qll +++ b/python/ql/lib/semmle/python/types/Object.qll @@ -1,6 +1,5 @@ import python private import LegacyPointsTo -private import semmle.python.objects.ObjectInternal private import semmle.python.types.Builtins private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/values/StringAttributes.qll b/python/ql/lib/semmle/python/values/StringAttributes.qll index e94540dbf20..e914730ef8b 100644 --- a/python/ql/lib/semmle/python/values/StringAttributes.qll +++ b/python/ql/lib/semmle/python/values/StringAttributes.qll @@ -1,8 +1,5 @@ import python private import LegacyPointsTo -private import semmle.python.types.Object -private import semmle.python.types.ClassObject -private import semmle.python.types.FunctionObject predicate string_attribute_all(ControlFlowNodeWithPointsTo n, string attr) { (n.getNode() instanceof Unicode or n.getNode() instanceof Bytes) and diff --git a/python/ql/src/Expressions/ContainsNonContainer.ql b/python/ql/src/Expressions/ContainsNonContainer.ql index fd2123dd436..de8c3879567 100644 --- a/python/ql/src/Expressions/ContainsNonContainer.ql +++ b/python/ql/src/Expressions/ContainsNonContainer.ql @@ -13,7 +13,6 @@ import python private import LegacyPointsTo -import semmle.python.pointsto.PointsTo predicate rhs_in_expr(ControlFlowNode rhs, Compare cmp) { exists(Cmpop op, int i | cmp.getOp(i) = op and cmp.getComparator(i) = rhs.getNode() | diff --git a/python/ql/src/Expressions/IsComparisons.qll b/python/ql/src/Expressions/IsComparisons.qll index 1ed4534bd23..052407f7111 100644 --- a/python/ql/src/Expressions/IsComparisons.qll +++ b/python/ql/src/Expressions/IsComparisons.qll @@ -3,6 +3,7 @@ import python private import LegacyPointsTo private import semmle.python.objects.ObjectInternal +private import semmle.python.objects.ObjectAPI /** Holds if the comparison `comp` uses `is` or `is not` (represented as `op`) to compare its `left` and `right` arguments. */ predicate comparison_using_is(Compare comp, ControlFlowNode left, Cmpop op, ControlFlowNode right) { diff --git a/python/ql/src/Statements/RedundantAssignment.ql b/python/ql/src/Statements/RedundantAssignment.ql index 357364c41b2..e3f58995fa1 100644 --- a/python/ql/src/Statements/RedundantAssignment.ql +++ b/python/ql/src/Statements/RedundantAssignment.ql @@ -14,6 +14,7 @@ import python private import LegacyPointsTo +private import semmle.python.objects.ObjectAPI predicate assignment(AssignStmt a, Expr left, Expr right) { a.getATarget() = left and a.getValue() = right diff --git a/python/ql/src/Variables/UndefinedGlobal.ql b/python/ql/src/Variables/UndefinedGlobal.ql index 3ea1c0d38eb..bfe816d5c58 100644 --- a/python/ql/src/Variables/UndefinedGlobal.ql +++ b/python/ql/src/Variables/UndefinedGlobal.ql @@ -14,7 +14,6 @@ import python private import LegacyPointsTo import Variables.MonkeyPatched import Loop -import semmle.python.pointsto.PointsTo predicate guarded_against_name_error(Name u) { exists(Try t | t.getBody().getAnItem().contains(u) | diff --git a/python/ql/src/Variables/UninitializedLocal.ql b/python/ql/src/Variables/UninitializedLocal.ql index d4d94f5a4f3..48332e01af3 100644 --- a/python/ql/src/Variables/UninitializedLocal.ql +++ b/python/ql/src/Variables/UninitializedLocal.ql @@ -14,7 +14,6 @@ import python private import LegacyPointsTo import Undefined -import semmle.python.pointsto.PointsTo predicate uninitialized_local(NameNode use) { exists(FastLocalVariable local | use.uses(local) or use.deletes(local) | diff --git a/python/ql/src/analysis/Efficiency.ql b/python/ql/src/analysis/Efficiency.ql index 37cb5c97387..d8ed85f2a2b 100644 --- a/python/ql/src/analysis/Efficiency.ql +++ b/python/ql/src/analysis/Efficiency.ql @@ -5,8 +5,6 @@ import python private import LegacyPointsTo -import semmle.python.pointsto.PointsTo -import semmle.python.pointsto.PointsToContext predicate trivial(ControlFlowNode f) { f.getNode() instanceof Parameter