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 8b257aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 2 additions & 10 deletions shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1014,20 +1014,12 @@ 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)
or
not knownSourceModel(n, _) and model = ""
)
model = getSourceModel(node)
}

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

bindingset[label1, label2]
Expand Down
18 changes: 18 additions & 0 deletions shared/dataflow/codeql/dataflow/internal/DataFlowImplCommon.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,24 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
exists(n.asParamReturnNode())
}

cached
string getSourceModel(NodeEx node) {
exists(Node n | n = node.asNode() |
knownSourceModel(n, result)
or
not knownSourceModel(n, _) and result = ""
)
}

cached
string getSinkModel(NodeEx node) {
exists(Node n | n = node.asNode() |
knownSinkModel(n, result)
or
not knownSinkModel(n, _) and result = ""
)
}

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

0 comments on commit 8b257aa

Please sign in to comment.