CodeQL library for Go
codeql/go-all 4.3.0 (changelog, source)
Search

Predicate restrictAlertsTo

Holds if the query may restrict its computation to only produce alerts that match the given line ranges. This predicate is used for implementing diff-informed queries for pull requests in GitHub Code Scanning.

This predicate is active if and only if it is nonempty. If this predicate is inactive, it has no effect. If it is active, queries may omit alerts that don’t have a primary or related location (in SARIF terminology) whose start line is within a specified range. Queries are allowed to produce alerts outside this range.

An alert location is a match if it matches a row in this predicate. If startLineStart and startLineEnd are both 0, the row specifies a whole-file match, and a location is a match if its file path matches filePath. Otherwise, the row specifies a line-range match, and a location is a match if its file path matches filePath, and its start line is between startLineStart and startLineEnd, inclusive. (Note that only start line of the location is used for matching because an alert is displayed on the first line of its location.)

  • filePath: alert location file path (absolute).
  • startLineStart: inclusive start of the range for alert location start line number (1-based).
  • startLineEnd: inclusive end of the range for alert location start line number (1-based).

Note that an alert that is not accepted by this filtering predicate may still be included in the query results if it is accepted by another active filtering predicate in this module. An alert is excluded from the query results if only if (1) there is at least one active filtering predicate, and (2) it is not accepted by any active filtering predicate.

See also: restrictAlertsToExactLocation.

Import path

import codeql.util.AlertFiltering
predicate restrictAlertsTo(string filePath, int startLineStart, int startLineEnd)