Skip to content

Commit

Permalink
Data flow: Cache known{Source,Sink}Model
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Jan 9, 2025
1 parent a7bb952 commit 653d122
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1014,19 +1014,19 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {

private predicate sourceModel(NodeEx node, string model) {
sourceNode(node, _) and
exists(Node n | n = node.asNode() |
knownSourceModel(n, model)
(
model = getSourceModel(node)
or
not knownSourceModel(n, _) and model = ""
not exists(getSourceModel(node)) and model = ""
)
}

private predicate sinkModel(NodeEx node, string model) {
sinkNode(node, _) and
exists(Node n | n = node.asNodeOrImplicitRead() |
knownSinkModel(n, model)
(
model = getSinkModel(node)
or
not knownSinkModel(n, _) and model = ""
not exists(getSinkModel(node)) and model = ""
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,12 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
exists(n.asParamReturnNode())
}

cached
string getSourceModel(NodeEx node) { knownSourceModel(node.asNode(), result) }

cached
string getSinkModel(NodeEx node) { knownSinkModel(node.asNodeOrImplicitRead(), result) }

cached
predicate parameterNode(Node p, DataFlowCallable c, ParameterPosition pos) {
isParameterNode(p, c, pos)
Expand Down

0 comments on commit 653d122

Please sign in to comment.