1
1
/**
2
- * Provides the `restrictAlertsTo` extensible predicate to restrict alerts to specific source
3
- * locations, and the `AlertFilteringImpl` parameterized module to apply the filtering.
2
+ * Provides the `restrictAlertsTo` and `restrictAlertsToExactLocation` extensible predicate to
3
+ * restrict alerts to specific source locations, and the `AlertFilteringImpl` parameterized module
4
+ * to apply the filtering.
4
5
*/
5
6
overlay [ local?]
6
7
module ;
@@ -13,55 +14,54 @@ private import codeql.util.Location
13
14
* GitHub Code Scanning.
14
15
*
15
16
* This predicate is active if and only if it is nonempty. If this predicate is inactive, it has no
16
- * effect. If it is active, queries may omit alerts that don't have a _primary_ or _related_
17
- * location ( in SARIF terminology) whose start line is within a specified range. Queries are allowed
18
- * to produce alerts outside this range .
17
+ * effect. If it is active, queries may omit alerts that don't have a matching ( see below ) _primary_
18
+ * or _related_ location ( in SARIF terminology) . Queries are still allowed to produce alerts that
19
+ * have no matching locations , but they are not required to do so .
19
20
*
20
- * An alert location is a match if it matches a row in this predicate . If `startLineStart ` and
21
- * `startLineEnd ` are both 0 , the row specifies a whole- file match, and a location is a match if
21
+ * An alert location is a match if it matches a row in this predicate . If `lineStart ` and
22
+ * `lineEnd ` are both 0 , the row specifies a whole- file match, and a location is a match if
22
23
* its file path matches `filePath`. Otherwise, the row specifies a line- range match, and a
23
- * location is a match if its file path matches `filePath`, and its start line is between
24
- * `startLineStart` and `startLineEnd`, inclusive. ( Note that only start line of the location is
25
- * used for matching because an alert is displayed on the first line of its location.)
24
+ * location is a match if its file path matches `filePath`, and its character range intersects
25
+ * with the range from the beginning of `lineStart` to the end of `lineEnd`.
26
26
*
27
27
* - filePath: alert location file path ( absolute) .
28
- * - startLineStart : inclusive start of the range for alert location start line number ( 1 - based) .
29
- * - startLineEnd : inclusive end of the range for alert location start line number ( 1 - based) .
28
+ * - lineStart : inclusive start of the line range ( 1 - based) .
29
+ * - lineEnd : inclusive end of the line range ( 1 - based) .
30
30
*
31
- * Note that an alert that is not accepted by this filtering predicate may still be included in the
32
- * query results if it is accepted by another active filtering predicate in this module . An alert is
33
- * excluded from the query results if only if ( 1 ) there is at least one active filtering predicate ,
34
- * and ( 2 ) it is not accepted by any active filtering predicate .
31
+ * Note that even if an alert has no matching locations for this filtering predicate, it could still
32
+ * have matching locations for other filtering predicates in this module . In that case , queries must
33
+ * still produce such an alert. An alert can be omitted if only if ( 1 ) there is at least one active
34
+ * filtering predicate , and ( 2 ) it has no matching locations for any active filtering predicate .
35
35
*
36
36
* See also: `restrictAlertsToExactLocation`.
37
37
* /
38
- extensible predicate restrictAlertsTo( string filePath, int startLineStart , int startLineEnd ) ;
38
+ extensible predicate restrictAlertsTo( string filePath, int lineStart , int lineEnd ) ;
39
39
40
40
/**
41
41
* Holds if the query may restrict its computation to only produce alerts that match the given
42
- * character ranges. This predicate is suitable for testing, where we want to filter by the exact
43
- * alert location, distinguishing between alerts on the same line.
42
+ * character ranges. This predicate is suitable for testing, where we want to distinguish between
43
+ * alerts on the same line.
44
44
*
45
45
* This predicate is active if and only if it is nonempty. If this predicate is inactive, it has no
46
- * effect. If it is active, queries may omit alerts that don't have a _primary_ or _related_
47
- * location (in SARIF terminology) whose location equals a tuple from this predicate. Queries are
48
- * allowed to produce alerts outside this range .
46
+ * effect. If it is active, queries may omit alerts that don't have a matching (see below) _primary_
47
+ * or _related_ location (in SARIF terminology). Queries are still allowed to produce alerts that
48
+ * have no matching locations, but they are not required to do so .
49
49
*
50
- * An alert location is a match if it matches a row in this predicate. Each row specifies an exact
51
- * location: an alert location is a match if its file path matches `filePath`, its start line and
52
- * column match `startLine` and `startColumn`, and its end line and column match `endLine` and
53
- * `endColumn`.
50
+ * An alert location is a match if it matches a row in this predicate. Each row specifies a
51
+ * character-range match, and a location is a match if its file path matches `filePath`, and its
52
+ * character range wholly contains the character range from `startColumn` on `startLine` to
53
+ * `endColumn` on `endLine` (inclusive) .
54
54
*
55
55
* - filePath: alert location file path (absolute).
56
- * - startLine: alert location start line number (1-based).
57
- * - startColumn: alert location start column number (1-based).
58
- * - endLine: alert location end line number (1-based).
59
- * - endColumn: alert location end column number (1-based).
56
+ * - startLine: inclusive start line of the character range (1-based).
57
+ * - startColumn: inclusive start column of the character range (1-based).
58
+ * - endLine: inclusive end line of the character range (1-based).
59
+ * - endColumn: inclusive end column of the character range (1-based).
60
60
*
61
- * Note that an alert that is not accepted by this filtering predicate may still be included in the
62
- * query results if it is accepted by another active filtering predicate in this module. An alert is
63
- * excluded from the query results if only if (1) there is at least one active filtering predicate,
64
- * and (2) it is not accepted by any active filtering predicate.
61
+ * Note that even if an alert has no matching locations for this filtering predicate, it could still
62
+ * have matching locations for other filtering predicates in this module. In that case, queries must
63
+ * still produce such an alert. An alert can be omitted if only if (1) there is at least one active
64
+ * filtering predicate, and (2) it has no matching locations for any active filtering predicate.
65
65
*
66
66
* See also: `restrictAlertsTo`.
67
67
*/
@@ -83,22 +83,11 @@ module AlertFilteringImpl<LocationSig Location> {
83
83
}
84
84
85
85
/**
86
- * Holds if the given location intersects the diff range. When that is the
87
- * case, ensuring that alerts mentioning this location are included in the
88
- * query results is a valid overapproximation of the requirements for
89
- * _diff-informed queries_ as documented under `restrictAlertsTo`.
86
+ * Holds if the given location is a match for one of the active filtering
87
+ * predicates in this module, or if all filtering predicates are inactive
88
+ * (which means that all alerts must be produced).
90
89
*
91
- * Testing for full intersection rather than only matching the start line
92
- * means that this predicate is more broadly useful than just checking whether
93
- * a specific element is considered to be in the diff range of GitHub Code
94
- * Scanning:
95
- * - If it's inconvenient to pass the exact `Location` of the element of
96
- * interest, it's valid to use a `Location` of an enclosing element.
97
- * - This predicate could be useful for other systems of alert presentation
98
- * where the rules don't exactly match GitHub Code Scanning.
99
- *
100
- * If there is no diff range, this predicate holds for all locations. Note
101
- * that this predicate has a bindingset and will therefore be inlined;
90
+ * Note that this predicate has a bindingset and will therefore be inlined;
102
91
* callers should include enough context to ensure efficient evaluation.
103
92
*/
104
93
bindingset [ location]
0 commit comments