Skip to content

Commit e19ebf9

Browse files
committed
Add external file scope
1 parent 563805f commit e19ebf9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ module Private {
2323
or
2424
not n instanceof FlowSummaryNode and
2525
not exists(n.getEnclosingCallable()) and
26-
result.asFileScope() = n.getFile()
26+
(
27+
result.asFileScope() = n.getFile()
28+
or
29+
not exists(n.getFile()) and
30+
result.isExternalFileScope()
31+
)
2732
or
2833
result.asSummarizedCallable() = n.(FlowSummaryNode).getSummarizedCallable()
2934
}

go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class DataFlowLocation = Location;
256256
private newtype TDataFlowCallable =
257257
TCallable(Callable c) or
258258
TFileScope(File f) or
259+
TExternalFileScope() or
259260
TSummarizedCallable(FlowSummary::SummarizedCallable c)
260261

261262
class DataFlowCallable extends TDataFlowCallable {
@@ -269,6 +270,11 @@ class DataFlowCallable extends TDataFlowCallable {
269270
*/
270271
File asFileScope() { this = TFileScope(result) }
271272

273+
/**
274+
* Holds if this `DataFlowCallable` is an external file scope.
275+
*/
276+
predicate isExternalFileScope() { this = TExternalFileScope() }
277+
272278
/**
273279
* Gets the `SummarizedCallable` corresponding to this `DataFlowCallable`, if any.
274280
*/

0 commit comments

Comments
 (0)