Skip to content

Commit 97e2376

Browse files
committed
Fix remaining overlay[local] issues
1 parent 846da9c commit 97e2376

File tree

7 files changed

+39
-16
lines changed

7 files changed

+39
-16
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/Attributes.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/** This module provides an API for attribute reads and writes. */
2+
overlay[local]
3+
module;
24

35
private import python
46
import DataFlowUtil

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ predicate resolveCall(CallNode call, Function target, CallType type) {
12351235
* Holds if the argument of `call` at position `apos` is `arg`. This is just a helper
12361236
* predicate that maps ArgumentPositions to the arguments of the underlying `CallNode`.
12371237
*/
1238+
overlay[local]
12381239
cached
12391240
predicate normalCallArg(CallNode call, Node arg, ArgumentPosition apos) {
12401241
exists(int index |
@@ -1712,6 +1713,7 @@ private class SummaryReturnNode extends FlowSummaryNode, ReturnNode {
17121713
override ReturnKind getKind() { result = rk }
17131714
}
17141715

1716+
overlay[global]
17151717
private class SummaryArgumentNode extends FlowSummaryNode, ArgumentNode {
17161718
private SummaryCall call_;
17171719
private ArgumentPosition pos_;
@@ -1750,28 +1752,27 @@ private class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNodeImpl
17501752
* `CallGraphConstruction::Make` in stead of
17511753
* `CallGraphConstruction::Simple::Make` appropriately.
17521754
*/
1753-
class CapturedVariablesArgumentNode extends CfgNode, ArgumentNode {
1755+
class CapturedVariablesArgumentNode extends CfgNode {
17541756
CallNode callNode;
17551757

1756-
CapturedVariablesArgumentNode() {
1757-
node = callNode.getFunction() and
1758-
exists(Function target | resolveCall(callNode, target, _) |
1759-
target = any(VariableCapture::CapturedVariable v).getACapturingScope()
1760-
)
1761-
}
1758+
CapturedVariablesArgumentNode() { node = callNode.getFunction() }
17621759

17631760
override string toString() { result = "Capturing closure argument" }
1761+
}
17641762

1763+
class CapturedVariablesArgumentNodeAsArgumentNode extends CapturedVariablesArgumentNode,
1764+
ArgumentNode
1765+
{
1766+
overlay[global]
17651767
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
17661768
callNode = call.getNode() and
17671769
pos.isLambdaSelf()
17681770
}
17691771
}
17701772

17711773
/** A synthetic node representing the values of variables captured by a comprehension. */
1772-
class SynthCompCapturedVariablesArgumentNode extends Node, TSynthCompCapturedVariablesArgumentNode,
1773-
ArgumentNode
1774-
{
1774+
overlay[local]
1775+
class SynthCompCapturedVariablesArgumentNode extends Node, TSynthCompCapturedVariablesArgumentNode {
17751776
Comp comp;
17761777

17771778
SynthCompCapturedVariablesArgumentNode() { this = TSynthCompCapturedVariablesArgumentNode(comp) }
@@ -1783,7 +1784,12 @@ class SynthCompCapturedVariablesArgumentNode extends Node, TSynthCompCapturedVar
17831784
override Location getLocation() { result = comp.getLocation() }
17841785

17851786
Comp getComprehension() { result = comp }
1787+
}
17861788

1789+
class SynthCompCapturedVariablesArgumentNodeAsArgumentNode extends SynthCompCapturedVariablesArgumentNode,
1790+
ArgumentNode
1791+
{
1792+
overlay[global]
17871793
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
17881794
call.(ComprehensionCall).getComprehension() = comp and
17891795
pos.isLambdaSelf()

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ class LocalSourceParameterNode extends ExtractedParameterNode, LocalSourceNode {
336336
ExtractedParameterNode parameterNode(Parameter p) { result.getParameter() = p }
337337

338338
/** A data flow node that represents a call argument. */
339+
overlay[global]
339340
abstract class ArgumentNode extends Node {
340341
/** Holds if this argument occurs at the given position in the given call. */
341342
abstract predicate argumentOf(DataFlowCall call, ArgumentPosition pos);
@@ -347,11 +348,12 @@ abstract class ArgumentNode extends Node {
347348
/**
348349
* A data flow node that represents a call argument found in the source code.
349350
*/
351+
overlay[global]
350352
class ExtractedArgumentNode extends ArgumentNode {
351353
ExtractedArgumentNode() {
352354
// for resolved calls, we need to allow all argument nodes
353-
getCallArg(_, _, _, this, _)
354-
or
355+
// getCallArg(_, _, _, this, _)
356+
// or
355357
// for potential summaries we allow all normal call arguments
356358
normalCallArg(_, this, _)
357359
or
@@ -436,6 +438,7 @@ class ModuleVariableNode extends Node, TModuleVariableNode {
436438
GlobalVariable getVariable() { result = var }
437439

438440
/** Gets a node that reads this variable. */
441+
overlay[global]
439442
Node getARead() {
440443
result.asCfgNode() = var.getALoad().getAFlowNode() and
441444
// Ignore reads that happen when the module is imported. These are only executed once.
@@ -463,12 +466,12 @@ class ModuleVariableNode extends Node, TModuleVariableNode {
463466
override Location getLocation() { result = mod.getLocation() }
464467
}
465468

466-
private predicate isAccessedThroughImportStar(Module m) { m = ImportStar::getStarImported(_) }
467-
469+
overlay[global]
468470
private ModuleVariableNode import_star_read(Node n) {
469471
resolved_import_star_module(result.getModule(), result.getVariable().getId(), n)
470472
}
471473

474+
overlay[global]
472475
pragma[nomagic]
473476
private predicate resolved_import_star_module(Module m, string name, Node n) {
474477
exists(NameNode nn | nn = n.asCfgNode() |
@@ -594,6 +597,7 @@ signature predicate guardChecksSig(GuardNode g, ControlFlowNode node, boolean br
594597
* This is expected to be used in `isBarrier`/`isSanitizer` definitions
595598
* in data flow and taint tracking.
596599
*/
600+
overlay[global]
597601
module BarrierGuard<guardChecksSig/3 guardChecks> {
598602
/** Gets a node that is safely guarded by the given guard check. */
599603
ExprNode getABarrierNode() {

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module Input implements InputSig<Location, DataFlowImplSpecific::PythonDataFlow>
9999
private import Make<Location, DataFlowImplSpecific::PythonDataFlow, Input> as Impl
100100

101101
private module StepsInput implements Impl::Private::StepsInputSig {
102+
overlay[global]
102103
DataFlowCall getACall(Public::SummarizedCallable sc) {
103104
result =
104105
TPotentialLibraryCall([

python/ql/lib/semmle/python/dataflow/new/internal/ImportStar.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module ImportStar {
1313
* Holds if `n` is an access of a variable called `name` (which is _not_ the name of a
1414
* built-in, and which is _not_ a global defined in the enclosing module) inside the scope `s`.
1515
*/
16+
overlay[local]
1617
cached
1718
predicate namePossiblyDefinedInImportStar(NameNode n, string name, Scope s) {
1819
n.isLoad() and
@@ -63,6 +64,7 @@ module ImportStar {
6364
* Holds if `n` may refer to a global variable of the same name in the module `m`, accessible
6465
* from the scope of `n` by a chain of `import *` imports.
6566
*/
67+
overlay[global]
6668
cached
6769
predicate importStarResolvesTo(NameNode n, Module m) {
6870
m = getStarImported+(n.getEnclosingModule()) and
@@ -73,6 +75,7 @@ module ImportStar {
7375
/**
7476
* Gets a module that is imported from `m` via `import *`.
7577
*/
78+
overlay[global]
7679
cached
7780
Module getStarImported(Module m) {
7881
exists(ImportStar i, DataFlow::CfgNode imported_module |

python/ql/lib/semmle/python/dataflow/new/internal/LocalSources.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class LocalSourceNode extends Node {
6969
or
7070
// We explicitly include any read of a global variable, as some of these may have local flow going
7171
// into them.
72-
this = any(ModuleVariableNode mvn).getARead()
72+
this.asCfgNode() = any(GlobalVariable v).getALoad().getAFlowNode()
7373
or
7474
// We include all scope entry definitions, as these act as the local source within the scope they
7575
// enter.
@@ -79,6 +79,7 @@ class LocalSourceNode extends Node {
7979
}
8080

8181
/** Holds if this `LocalSourceNode` can flow to `nodeTo` in one or more local flow steps. */
82+
overlay[caller]
8283
pragma[inline]
8384
predicate flowsTo(Node nodeTo) { Cached::hasLocalSource(nodeTo, this) }
8485

@@ -151,6 +152,7 @@ class LocalSourceNode extends Node {
151152
*
152153
* See `TypeTracker` for more details about how to use this.
153154
*/
155+
overlay[global]
154156
pragma[inline]
155157
LocalSourceNode track(TypeTracker t2, TypeTracker t) { t = t2.step(this, result) }
156158

@@ -159,6 +161,7 @@ class LocalSourceNode extends Node {
159161
*
160162
* See `TypeBackTracker` for more details about how to use this.
161163
*/
164+
overlay[global]
162165
pragma[inline]
163166
LocalSourceNode backtrack(TypeBackTracker t2, TypeBackTracker t) { t = t2.step(result, this) }
164167
}
@@ -212,6 +215,7 @@ private module FutureWork {
212215
*
213216
* See `TypeTracker` for more details about how to use this.
214217
*/
218+
overlay[global]
215219
pragma[inline]
216220
TypeTrackingNode track(TypeTracker t2, TypeTracker t) { t = t2.step(this, result) }
217221

@@ -220,6 +224,7 @@ private module FutureWork {
220224
*
221225
* See `TypeBackTracker` for more details about how to use this.
222226
*/
227+
overlay[global]
223228
pragma[inline]
224229
TypeTrackingNode backtrack(TypeBackTracker t2, TypeBackTracker t) { t2 = t.step(result, this) }
225230
}
@@ -250,7 +255,7 @@ private module Cached {
250255
pragma[nomagic]
251256
private predicate localSourceFlowStep(Node nodeFrom, Node nodeTo) {
252257
simpleLocalFlowStep(nodeFrom, nodeTo, _) and
253-
not nodeTo = any(ModuleVariableNode v).getARead()
258+
not nodeTo instanceof LocalSourceNode
254259
}
255260

256261
/**

python/ql/lib/semmle/python/internal/Awaited.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*
44
* Provides helper class for defining additional API graph edges.
55
*/
6+
overlay[local]
7+
module;
68

79
private import python
810
private import semmle.python.dataflow.new.DataFlow

0 commit comments

Comments
 (0)