Skip to content

Commit 41e8117

Browse files
authored
Merge pull request #17648 from github/cklin/dataflow-diff-informed-filtering
Dataflow: apply diff-informed filtering consistently
2 parents f3abe54 + 1aa3eb5 commit 41e8117

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

+18
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
224224
hasFilteredSource()
225225
)
226226
}
227+
228+
bindingset[source, sink]
229+
pragma[inline_late]
230+
predicate isRelevantSourceSinkPair(Node source, Node sink) {
231+
isFilteredSource(source) or
232+
isFilteredSink(sink)
233+
}
227234
}
228235

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

0 commit comments

Comments
 (0)