Python: Add overlay annotations to AST classes

... and everything else that it depends on.
This commit is contained in:
Taus
2025-12-05 13:23:11 +00:00
parent 1b519384d7
commit 09e1f8d5ad
27 changed files with 72 additions and 0 deletions

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
private import semmle.python.internal.CachedStages

View File

@@ -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

View File

@@ -1,6 +1,8 @@
/**
* Provides classes representing Python classes.
*/
overlay[local]
module;
import python

View File

@@ -1,6 +1,8 @@
/**
* Provides classes representing comments in Python.
*/
overlay[local]
module;
import python

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/** The base class for list, set and dictionary comprehensions, and generator expressions. */

View File

@@ -1,4 +1,6 @@
/** Standard builtin types and modules */
overlay[local]
module;
import python

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
private import python
private import semmle.python.internal.CachedStages

View File

@@ -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

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
private import semmle.python.internal.CachedStages
private import codeql.controlflow.BasicBlock as BB

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/**

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/** A basic block which terminates in a condition, splitting the subsequent control flow */

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
private import semmle.python.types.Builtins
private import semmle.python.internal.CachedStages

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
class KeyValuePair extends KeyValuePair_, DictDisplayItem {

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
private import semmle.python.internal.CachedStages

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/** The base class for operators */

View File

@@ -1,6 +1,8 @@
/**
* Wrapping generated AST classes: `Pattern_` and subclasses.
*/
overlay[local]
module;
import python

View File

@@ -1,4 +1,6 @@
/** SSA library */
overlay[local]
module;
import python

View File

@@ -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

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/** A statement */

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/** A variable, either a global or local variable (including parameters) */

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/*
* Classification of variables. These should be non-overlapping and complete.

View File

@@ -1,6 +1,8 @@
/**
* Library for SSA representation (Static Single Assignment form).
*/
overlay[local]
module;
import python
private import SsaCompute

View File

@@ -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

View File

@@ -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

View File

@@ -35,6 +35,7 @@ module Stages {
* Computes predicates based on the AST.
* These include SSA and basic-blocks.
*/
overlay[local]
cached
module AST {
/**

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
import python
private import LegacyPointsTo

View File

@@ -1,3 +1,6 @@
overlay[local]
module;
import python
/**