Skip to content

Commit 82e4fc9

Browse files
author
Alex Eyers-Taylor
committed
AlertFiltering: Expose filtering further.
1 parent 8c02130 commit 82e4fc9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

shared/util/codeql/util/AlertFiltering.qll

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ module AlertFilteringImpl<LocationSig Location> {
8282
)
8383
}
8484

85+
/** Holds if diff information is available in this evaluation. */
86+
predicate diffInformationAvailable() {
87+
restrictAlertsTo(_, _, _) or restrictAlertsToExactLocation(_, _, _, _, _)
88+
}
89+
90+
/**
91+
* Holds if diff information is available, and `filePath` is in the diff
92+
* range.
93+
*/
94+
predicate fileIsInDiff(string filePath) {
95+
restrictAlertsTo(filePath, _, _)
96+
or
97+
restrictAlertsToExactLocation(filePath, _, _, _, _)
98+
}
99+
85100
/**
86101
* Holds if the given location is a match for one of the active filtering
87102
* predicates in this module, or if all filtering predicates are inactive
@@ -92,8 +107,17 @@ module AlertFilteringImpl<LocationSig Location> {
92107
*/
93108
bindingset[location]
94109
predicate filterByLocation(Location location) {
95-
not restrictAlertsTo(_, _, _) and not restrictAlertsToExactLocation(_, _, _, _, _)
110+
not diffInformationAvailable()
96111
or
112+
locationIsInDiff(location)
113+
}
114+
115+
/**
116+
* Like `filterByLocation`, except that if there is no diff range, this
117+
* predicate never holds.
118+
*/
119+
bindingset[location]
120+
predicate locationIsInDiff(Location location) {
97121
exists(string filePath |
98122
restrictAlertsToEntireFile(filePath) and
99123
location.hasLocationInfo(filePath, _, _, _, _)

0 commit comments

Comments
 (0)