From e09840426c24fed32432f5f4f9fd17079425c246 Mon Sep 17 00:00:00 2001 From: Taus Date: Fri, 31 Oct 2025 14:56:13 +0000 Subject: [PATCH] Python: Get rid of points-to from `Definitions.qll` Turns out the `ImportTime` module (despite living in `semmle.python.types` does not actually depend on points-to, so some of the `LegacyPointsTo` imports could be replaced or removed. --- python/ql/lib/LegacyPointsTo.qll | 1 - python/ql/lib/analysis/DefinitionTracking.qll | 1 + python/ql/lib/semmle/python/essa/Definitions.qll | 2 +- python/ql/src/Imports/Cyclic.qll | 1 + python/ql/src/Imports/UnintentionalImport.ql | 1 + python/ql/src/Variables/UndefinedGlobal.ql | 1 + python/ql/src/Variables/UndefinedPlaceHolder.ql | 1 + python/ql/test/library-tests/PointsTo/general/GlobalPointsTo.ql | 1 + 8 files changed, 7 insertions(+), 2 deletions(-) diff --git a/python/ql/lib/LegacyPointsTo.qll b/python/ql/lib/LegacyPointsTo.qll index 3bc0258bdaa..9e6efdb29cf 100644 --- a/python/ql/lib/LegacyPointsTo.qll +++ b/python/ql/lib/LegacyPointsTo.qll @@ -32,7 +32,6 @@ 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 diff --git a/python/ql/lib/analysis/DefinitionTracking.qll b/python/ql/lib/analysis/DefinitionTracking.qll index c019e92c0ca..0d58bd69b7b 100644 --- a/python/ql/lib/analysis/DefinitionTracking.qll +++ b/python/ql/lib/analysis/DefinitionTracking.qll @@ -4,6 +4,7 @@ import python private import LegacyPointsTo +private import semmle.python.types.ImportTime import IDEContextual private newtype TDefinition = diff --git a/python/ql/lib/semmle/python/essa/Definitions.qll b/python/ql/lib/semmle/python/essa/Definitions.qll index 17b4e622ea1..aca6991b9f6 100644 --- a/python/ql/lib/semmle/python/essa/Definitions.qll +++ b/python/ql/lib/semmle/python/essa/Definitions.qll @@ -11,7 +11,7 @@ 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.types.ImportTime private import semmle.python.essa.SsaDefinitions /** A source language variable, to be converted into a set of SSA variables. */ diff --git a/python/ql/src/Imports/Cyclic.qll b/python/ql/src/Imports/Cyclic.qll index 720ea8f0048..ad24a08eddd 100644 --- a/python/ql/src/Imports/Cyclic.qll +++ b/python/ql/src/Imports/Cyclic.qll @@ -1,5 +1,6 @@ import python private import LegacyPointsTo +private import semmle.python.types.ImportTime predicate is_import_time(Stmt s) { not s.getScope+() instanceof Function } diff --git a/python/ql/src/Imports/UnintentionalImport.ql b/python/ql/src/Imports/UnintentionalImport.ql index 7b22865cd89..db1775a0d41 100644 --- a/python/ql/src/Imports/UnintentionalImport.ql +++ b/python/ql/src/Imports/UnintentionalImport.ql @@ -14,6 +14,7 @@ import python private import LegacyPointsTo +private import semmle.python.types.ImportTime predicate import_star(ImportStar imp, ModuleValue exporter) { exporter.importedAs(imp.getImportedModuleName()) diff --git a/python/ql/src/Variables/UndefinedGlobal.ql b/python/ql/src/Variables/UndefinedGlobal.ql index bfe816d5c58..2fdf708a2b9 100644 --- a/python/ql/src/Variables/UndefinedGlobal.ql +++ b/python/ql/src/Variables/UndefinedGlobal.ql @@ -12,6 +12,7 @@ import python private import LegacyPointsTo +private import semmle.python.types.ImportTime import Variables.MonkeyPatched import Loop diff --git a/python/ql/src/Variables/UndefinedPlaceHolder.ql b/python/ql/src/Variables/UndefinedPlaceHolder.ql index 11bf3b6d0be..4b21e371977 100644 --- a/python/ql/src/Variables/UndefinedPlaceHolder.ql +++ b/python/ql/src/Variables/UndefinedPlaceHolder.ql @@ -14,6 +14,7 @@ import python import Variables.MonkeyPatched private import LegacyPointsTo +private import semmle.python.types.ImportTime /* Local variable part */ predicate initialized_as_local(PlaceHolder use) { diff --git a/python/ql/test/library-tests/PointsTo/general/GlobalPointsTo.ql b/python/ql/test/library-tests/PointsTo/general/GlobalPointsTo.ql index e90674bab2e..a0b7e8979f3 100644 --- a/python/ql/test/library-tests/PointsTo/general/GlobalPointsTo.ql +++ b/python/ql/test/library-tests/PointsTo/general/GlobalPointsTo.ql @@ -1,5 +1,6 @@ import python private import LegacyPointsTo +private import semmle.python.types.ImportTime import interesting from int line, ControlFlowNodeWithPointsTo f, Object o, ImportTimeScope n