Skip to content

Commit

Permalink
Add external file scope
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Oct 19, 2023
1 parent 563805f commit e19ebf9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ module Private {
or
not n instanceof FlowSummaryNode and
not exists(n.getEnclosingCallable()) and
result.asFileScope() = n.getFile()
(
result.asFileScope() = n.getFile()
or
not exists(n.getFile()) and
result.isExternalFileScope()
)
or
result.asSummarizedCallable() = n.(FlowSummaryNode).getSummarizedCallable()
}
Expand Down
6 changes: 6 additions & 0 deletions go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class DataFlowLocation = Location;
private newtype TDataFlowCallable =
TCallable(Callable c) or
TFileScope(File f) or
TExternalFileScope() or
TSummarizedCallable(FlowSummary::SummarizedCallable c)

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

/**
* Holds if this `DataFlowCallable` is an external file scope.
*/
predicate isExternalFileScope() { this = TExternalFileScope() }

/**
* Gets the `SummarizedCallable` corresponding to this `DataFlowCallable`, if any.
*/
Expand Down

0 comments on commit e19ebf9

Please sign in to comment.