From fd7b123ee38957e99ac0cedf83fee8cd0e5cc2f7 Mon Sep 17 00:00:00 2001 From: Taus Date: Fri, 5 Dec 2025 13:23:11 +0000 Subject: [PATCH] Python: Add overlay annotations to AST classes ... and everything else that it depends on. --- python/ql/lib/semmle/python/AstExtended.qll | 3 +++ python/ql/lib/semmle/python/AstGenerated.qll | 2 ++ python/ql/lib/semmle/python/Class.qll | 2 ++ python/ql/lib/semmle/python/Comment.qll | 2 ++ python/ql/lib/semmle/python/Comprehensions.qll | 3 +++ python/ql/lib/semmle/python/Constants.qll | 2 ++ python/ql/lib/semmle/python/Exprs.qll | 3 +++ python/ql/lib/semmle/python/Files.qll | 3 +++ python/ql/lib/semmle/python/Flow.qll | 3 +++ python/ql/lib/semmle/python/Function.qll | 3 +++ python/ql/lib/semmle/python/GuardedControlFlow.qll | 3 +++ python/ql/lib/semmle/python/Import.qll | 3 +++ python/ql/lib/semmle/python/Keywords.qll | 3 +++ python/ql/lib/semmle/python/Module.qll | 3 +++ python/ql/lib/semmle/python/Operations.qll | 3 +++ python/ql/lib/semmle/python/Patterns.qll | 2 ++ python/ql/lib/semmle/python/SSA.qll | 2 ++ python/ql/lib/semmle/python/Scope.qll | 5 +++++ python/ql/lib/semmle/python/Stmts.qll | 3 +++ python/ql/lib/semmle/python/Variables.qll | 3 +++ python/ql/lib/semmle/python/essa/Definitions.qll | 3 +++ python/ql/lib/semmle/python/essa/Essa.qll | 2 ++ python/ql/lib/semmle/python/essa/SsaCompute.qll | 2 ++ python/ql/lib/semmle/python/essa/SsaDefinitions.qll | 2 ++ python/ql/lib/semmle/python/internal/CachedStages.qll | 1 + python/ql/lib/semmle/python/types/Builtins.qll | 3 +++ python/ql/lib/semmle/python/types/ImportTime.qll | 3 +++ 27 files changed, 72 insertions(+) diff --git a/python/ql/lib/semmle/python/AstExtended.qll b/python/ql/lib/semmle/python/AstExtended.qll index 73292b85c3a..13da4e899a7 100644 --- a/python/ql/lib/semmle/python/AstExtended.qll +++ b/python/ql/lib/semmle/python/AstExtended.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/AstGenerated.qll b/python/ql/lib/semmle/python/AstGenerated.qll index 12f86832387..8805a43bec3 100644 --- a/python/ql/lib/semmle/python/AstGenerated.qll +++ b/python/ql/lib/semmle/python/AstGenerated.qll @@ -3,6 +3,8 @@ * WARNING: Any modifications to this file will be lost. * Relations can be changed by modifying master.py. */ +overlay[local] +module; import python diff --git a/python/ql/lib/semmle/python/Class.qll b/python/ql/lib/semmle/python/Class.qll index 19b81e86a12..cee0e730cb4 100644 --- a/python/ql/lib/semmle/python/Class.qll +++ b/python/ql/lib/semmle/python/Class.qll @@ -1,6 +1,8 @@ /** * Provides classes representing Python classes. */ +overlay[local] +module; import python diff --git a/python/ql/lib/semmle/python/Comment.qll b/python/ql/lib/semmle/python/Comment.qll index 839d700b8cd..c87ccc1521d 100644 --- a/python/ql/lib/semmle/python/Comment.qll +++ b/python/ql/lib/semmle/python/Comment.qll @@ -1,6 +1,8 @@ /** * Provides classes representing comments in Python. */ +overlay[local] +module; import python diff --git a/python/ql/lib/semmle/python/Comprehensions.qll b/python/ql/lib/semmle/python/Comprehensions.qll index 37f07614282..12e71e2d5d1 100644 --- a/python/ql/lib/semmle/python/Comprehensions.qll +++ b/python/ql/lib/semmle/python/Comprehensions.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /** The base class for list, set and dictionary comprehensions, and generator expressions. */ diff --git a/python/ql/lib/semmle/python/Constants.qll b/python/ql/lib/semmle/python/Constants.qll index 03254a4bfd0..f86019c0256 100644 --- a/python/ql/lib/semmle/python/Constants.qll +++ b/python/ql/lib/semmle/python/Constants.qll @@ -1,4 +1,6 @@ /** Standard builtin types and modules */ +overlay[local] +module; import python diff --git a/python/ql/lib/semmle/python/Exprs.qll b/python/ql/lib/semmle/python/Exprs.qll index c374863d684..6ab9f8d8340 100644 --- a/python/ql/lib/semmle/python/Exprs.qll +++ b/python/ql/lib/semmle/python/Exprs.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + private import python private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/Files.qll b/python/ql/lib/semmle/python/Files.qll index 2da0dd61f88..bb3c504654e 100644 --- a/python/ql/lib/semmle/python/Files.qll +++ b/python/ql/lib/semmle/python/Files.qll @@ -1,4 +1,6 @@ /** Provides classes for working with files and folders. */ +overlay[local] +module; import python private import codeql.util.FileSystem @@ -178,6 +180,7 @@ class Container extends Impl::Container { override Container getParentContainer() { result = super.getParentContainer() } + overlay[global] Container getChildContainer(string baseName) { result = this.getAChildContainer() and result.getBaseName() = baseName diff --git a/python/ql/lib/semmle/python/Flow.qll b/python/ql/lib/semmle/python/Flow.qll index 898cd566ab9..b29f9fd1383 100644 --- a/python/ql/lib/semmle/python/Flow.qll +++ b/python/ql/lib/semmle/python/Flow.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python private import semmle.python.internal.CachedStages private import codeql.controlflow.BasicBlock as BB diff --git a/python/ql/lib/semmle/python/Function.qll b/python/ql/lib/semmle/python/Function.qll index e15d28d3a12..c133275b8b7 100644 --- a/python/ql/lib/semmle/python/Function.qll +++ b/python/ql/lib/semmle/python/Function.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /** diff --git a/python/ql/lib/semmle/python/GuardedControlFlow.qll b/python/ql/lib/semmle/python/GuardedControlFlow.qll index 73ea183850a..3169e4d0c1a 100644 --- a/python/ql/lib/semmle/python/GuardedControlFlow.qll +++ b/python/ql/lib/semmle/python/GuardedControlFlow.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /** A basic block which terminates in a condition, splitting the subsequent control flow */ diff --git a/python/ql/lib/semmle/python/Import.qll b/python/ql/lib/semmle/python/Import.qll index c75ef9f0c91..e8a7facccad 100644 --- a/python/ql/lib/semmle/python/Import.qll +++ b/python/ql/lib/semmle/python/Import.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python private import semmle.python.types.Builtins private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/Keywords.qll b/python/ql/lib/semmle/python/Keywords.qll index b7ecca528bb..da7b582ef16 100644 --- a/python/ql/lib/semmle/python/Keywords.qll +++ b/python/ql/lib/semmle/python/Keywords.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python class KeyValuePair extends KeyValuePair_, DictDisplayItem { diff --git a/python/ql/lib/semmle/python/Module.qll b/python/ql/lib/semmle/python/Module.qll index f22f0d6fe39..a30aab452c3 100644 --- a/python/ql/lib/semmle/python/Module.qll +++ b/python/ql/lib/semmle/python/Module.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/Operations.qll b/python/ql/lib/semmle/python/Operations.qll index e8f5e4799a5..c6318af63e2 100644 --- a/python/ql/lib/semmle/python/Operations.qll +++ b/python/ql/lib/semmle/python/Operations.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /** The base class for operators */ diff --git a/python/ql/lib/semmle/python/Patterns.qll b/python/ql/lib/semmle/python/Patterns.qll index 9b4760611d0..fb99a123584 100644 --- a/python/ql/lib/semmle/python/Patterns.qll +++ b/python/ql/lib/semmle/python/Patterns.qll @@ -1,6 +1,8 @@ /** * Wrapping generated AST classes: `Pattern_` and subclasses. */ +overlay[local] +module; import python diff --git a/python/ql/lib/semmle/python/SSA.qll b/python/ql/lib/semmle/python/SSA.qll index b71bd95de79..77779287734 100644 --- a/python/ql/lib/semmle/python/SSA.qll +++ b/python/ql/lib/semmle/python/SSA.qll @@ -1,4 +1,6 @@ /** SSA library */ +overlay[local] +module; import python diff --git a/python/ql/lib/semmle/python/Scope.qll b/python/ql/lib/semmle/python/Scope.qll index 4131455299c..66a7170aec7 100644 --- a/python/ql/lib/semmle/python/Scope.qll +++ b/python/ql/lib/semmle/python/Scope.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python private import semmle.python.dataflow.new.internal.ImportResolution @@ -6,6 +9,7 @@ private import semmle.python.dataflow.new.internal.ImportResolution * * This aims to be the same as m.getAnExport(), but without using the points-to machinery. */ +overlay[global] private string getAModuleExport(Module m) { py_exports(m, result) or @@ -76,6 +80,7 @@ class Scope extends Scope_ { predicate isTopLevel() { this.getEnclosingModule() = this.getEnclosingScope() } /** Holds if this scope is deemed to be public */ + overlay[global] predicate isPublic() { /* Not inside a function */ not this.getEnclosingScope() instanceof Function and diff --git a/python/ql/lib/semmle/python/Stmts.qll b/python/ql/lib/semmle/python/Stmts.qll index ea309227af6..c0dfac10ee8 100644 --- a/python/ql/lib/semmle/python/Stmts.qll +++ b/python/ql/lib/semmle/python/Stmts.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /** A statement */ diff --git a/python/ql/lib/semmle/python/Variables.qll b/python/ql/lib/semmle/python/Variables.qll index 1249fd020ca..d2baf04a5bf 100644 --- a/python/ql/lib/semmle/python/Variables.qll +++ b/python/ql/lib/semmle/python/Variables.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /** A variable, either a global or local variable (including parameters) */ diff --git a/python/ql/lib/semmle/python/essa/Definitions.qll b/python/ql/lib/semmle/python/essa/Definitions.qll index aca6991b9f6..6e7b8d5b376 100644 --- a/python/ql/lib/semmle/python/essa/Definitions.qll +++ b/python/ql/lib/semmle/python/essa/Definitions.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /* * Classification of variables. These should be non-overlapping and complete. diff --git a/python/ql/lib/semmle/python/essa/Essa.qll b/python/ql/lib/semmle/python/essa/Essa.qll index 384bfd2f91f..ebc22beedf3 100644 --- a/python/ql/lib/semmle/python/essa/Essa.qll +++ b/python/ql/lib/semmle/python/essa/Essa.qll @@ -1,6 +1,8 @@ /** * Library for SSA representation (Static Single Assignment form). */ +overlay[local] +module; import python private import SsaCompute diff --git a/python/ql/lib/semmle/python/essa/SsaCompute.qll b/python/ql/lib/semmle/python/essa/SsaCompute.qll index d2512eecded..fb030b6250e 100644 --- a/python/ql/lib/semmle/python/essa/SsaCompute.qll +++ b/python/ql/lib/semmle/python/essa/SsaCompute.qll @@ -88,6 +88,8 @@ * ``` * and thus it falls out that `g3` must be `1`. */ +overlay[local] +module; import python private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/essa/SsaDefinitions.qll b/python/ql/lib/semmle/python/essa/SsaDefinitions.qll index 6c87af102fa..827bee34474 100644 --- a/python/ql/lib/semmle/python/essa/SsaDefinitions.qll +++ b/python/ql/lib/semmle/python/essa/SsaDefinitions.qll @@ -2,6 +2,8 @@ * Provides classes and predicates for determining the uses and definitions of * variables for ESSA form. */ +overlay[local] +module; import python private import semmle.python.internal.CachedStages diff --git a/python/ql/lib/semmle/python/internal/CachedStages.qll b/python/ql/lib/semmle/python/internal/CachedStages.qll index 687cabeceae..df96e849855 100644 --- a/python/ql/lib/semmle/python/internal/CachedStages.qll +++ b/python/ql/lib/semmle/python/internal/CachedStages.qll @@ -35,6 +35,7 @@ module Stages { * Computes predicates based on the AST. * These include SSA and basic-blocks. */ + overlay[local] cached module AST { /** diff --git a/python/ql/lib/semmle/python/types/Builtins.qll b/python/ql/lib/semmle/python/types/Builtins.qll index 796397f72cd..371cf758d5c 100644 --- a/python/ql/lib/semmle/python/types/Builtins.qll +++ b/python/ql/lib/semmle/python/types/Builtins.qll @@ -1,3 +1,6 @@ +overlay[local?] +module; + import python private import LegacyPointsTo diff --git a/python/ql/lib/semmle/python/types/ImportTime.qll b/python/ql/lib/semmle/python/types/ImportTime.qll index 1604013d7ff..27f70b09aa4 100644 --- a/python/ql/lib/semmle/python/types/ImportTime.qll +++ b/python/ql/lib/semmle/python/types/ImportTime.qll @@ -1,3 +1,6 @@ +overlay[local] +module; + import python /**