Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataflow: apply diff-informed filtering consistently #17648

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading