Skip to content

Commit

Permalink
Dataflow: apply diff-informed filtering consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
cklin committed Oct 2, 2024
1 parent d6415cd commit 105887f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
private module SourceSinkFiltering {
private import codeql.util.AlertFiltering

private module AlertFiltering = AlertFilteringImpl<Location>;
module AlertFiltering = AlertFilteringImpl<Location>;

pragma[nomagic]
private predicate isFilteredSource(Node source) {
Expand Down Expand Up @@ -3511,6 +3511,19 @@ 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
AlertFiltering::filterByLocation(source.getLocation()) or
AlertFiltering::filterByLocation(sink.getLocation())
else any()
) and
exists(PathNodeImpl flowsource, PathNodeImpl flowsink |
source = flowsource and sink = flowsink
|
Expand Down

0 comments on commit 105887f

Please sign in to comment.