Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions python/ql/lib/analysis/DefinitionTracking.qll
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,10 @@ Definition getUniqueDefinition(Expr use) {
not result = TLocalDefinition(use)
}

/** A helper class to get suitable locations for attributes */
class NiceLocationExpr extends Expr {
/** Gets a textual representation of this element. */
override string toString() { result = this.(Expr).toString() }
final class FinalExpr = Expr;

/** A helper class to get suitable locations for attributes */
class NiceLocationExpr extends FinalExpr {
/**
* Holds if this element is at the specified location.
* The location spans column `bc` of line `bl` to
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/AstExtended.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python
private import semmle.python.internal.CachedStages

Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/AstGenerated.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/Class.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes representing Python classes.
*/
overlay[local]
module;

import python

Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/Comment.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes representing comments in Python.
*/
overlay[local]
module;

import python

Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Comprehensions.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/** The base class for list, set and dictionary comprehensions, and generator expressions. */
Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/Constants.qll
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Standard builtin types and modules */
overlay[local]
module;

import python

Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Exprs.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

private import python
private import semmle.python.internal.CachedStages

Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Files.qll
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** Provides classes for working with files and folders. */
overlay[local]
module;

import python
private import codeql.util.FileSystem
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Flow.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python
private import semmle.python.internal.CachedStages
private import codeql.controlflow.BasicBlock as BB
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Function.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/**
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/GuardedControlFlow.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/** A basic block which terminates in a condition, splitting the subsequent control flow */
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Import.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python
private import semmle.python.types.Builtins
private import semmle.python.internal.CachedStages
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Keywords.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

class KeyValuePair extends KeyValuePair_, DictDisplayItem {
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Module.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python
private import semmle.python.internal.CachedStages

Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Operations.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/** The base class for operators */
Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/Patterns.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Wrapping generated AST classes: `Pattern_` and subclasses.
*/
overlay[local]
module;

import python

Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/SSA.qll
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** SSA library */
overlay[local]
module;

import python

Expand Down
5 changes: 5 additions & 0 deletions python/ql/lib/semmle/python/Scope.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python
private import semmle.python.dataflow.new.internal.ImportResolution

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Stmts.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/** A statement */
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/Variables.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/** A variable, either a global or local variable (including parameters) */
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/essa/Definitions.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python
/*
* Classification of variables. These should be non-overlapping and complete.
Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/essa/Essa.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Library for SSA representation (Static Single Assignment form).
*/
overlay[local]
module;

import python
private import SsaCompute
Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/essa/SsaCompute.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions python/ql/lib/semmle/python/essa/SsaDefinitions.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions python/ql/lib/semmle/python/internal/CachedStages.qll
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Stages {
* Computes predicates based on the AST.
* These include SSA and basic-blocks.
*/
overlay[local]
cached
module AST {
/**
Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/types/Builtins.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local?]
module;

import python
private import LegacyPointsTo

Expand Down
3 changes: 3 additions & 0 deletions python/ql/lib/semmle/python/types/ImportTime.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
overlay[local]
module;

import python

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import python
import semmle.python.dataflow.new.DataFlow

final class FinalAstNode = AstNode;

/** A looping construct. */
abstract class Loop extends AstNode {
abstract class Loop extends FinalAstNode {
/**
* Gets a loop variable of this loop.
* For example, `x` and `y` in `for x,y in pairs: print(x+y)`
Expand All @@ -13,9 +15,9 @@ abstract class Loop extends AstNode {
}

/** A `for` loop. */
private class ForLoop extends Loop, For {
private class ForLoop extends Loop instanceof For {
override Variable getALoopVariable() {
this.getTarget() = result.getAnAccess().getParentNode*() and
this.(For).getTarget() = result.getAnAccess().getParentNode*() and
result.getScope() = this.getScope()
}
}
Expand Down
6 changes: 4 additions & 2 deletions python/ql/src/analysis/ImportFailure.ql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ predicate ok_to_fail(ImportExpr ie) {
os_specific_import(ie) != get_os()
}

class VersionTest extends ControlFlowNode {
final class FinalControlFlowNode = ControlFlowNode;

class VersionTest extends FinalControlFlowNode {
VersionTest() {
exists(string name |
name.matches("%version%") and
Expand All @@ -70,7 +72,7 @@ class VersionTest extends ControlFlowNode {
)
}

override string toString() { result = "VersionTest" }
string toString() { result = "VersionTest" }
}

/** A guard on the version of the Python interpreter */
Expand Down