Skip to content

Commit

Permalink
Merge pull request #17648 from github/cklin/dataflow-diff-informed-fi…
Browse files Browse the repository at this point in the history
…ltering

Dataflow: apply diff-informed filtering consistently
  • Loading branch information
cklin authored Oct 18, 2024
2 parents f3abe54 + 1aa3eb5 commit 41e8117
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
hasFilteredSource()
)
}

bindingset[source, sink]
pragma[inline_late]
predicate isRelevantSourceSinkPair(Node source, Node sink) {
isFilteredSource(source) or
isFilteredSink(sink)
}
}

private import SourceSinkFiltering
Expand Down Expand Up @@ -3511,6 +3518,17 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
* included in the module `PathGraph`.
*/
predicate flowPath(PathNode source, PathNode sink) {
(
// When there are both sources and sinks in the diff range,
// diff-informed dataflow falls back to computing all paths without
// any filtering. To prevent significant alert flip-flopping due to
// minor code changes triggering the fallback, we consistently apply
// source-or-sink filtering here to ensure that we return the same
// paths regardless of whether the fallback is triggered.
if Config::observeDiffInformedIncrementalMode()
then isRelevantSourceSinkPair(source.getNode(), sink.getNode())
else any()
) and
exists(PathNodeImpl flowsource, PathNodeImpl flowsink |
source = flowsource and sink = flowsink
|
Expand Down

0 comments on commit 41e8117

Please sign in to comment.