Skip to main content

Verify Semgrep Rule in SARIF

Type: Rule
ID: sarif-semgrep-report
Source: v2/rules/sarif/verify-semgrep-report.yaml
Rego Source: verify-semgrep-report.rego
Labels: SARIF, Semgrep

Verify the Semgrep SARIF report complies with predefined rules to ensure compliance and detect issues.

note

This rule requires SARIF Evidence. See here for more details.

tip

Signed Evidence for this rule IS NOT required by default but is recommended.

warning

Rule requires evaluation with a target. Without one, it will be disabled unless the --all-evidence flag is provided.

Usage example

uses: sarif/verify-semgrep-report@v2

Mitigation

Ensures that any violations detected in the SARIF report produced by Semgrep are promptly identified and flagged, helping to prevent the use of assets that do not meet the required security standards.

Description

This rule evaluates the SARIF report generated by Semgrep to verify that it complies with a set of predefined compliance rules. It iterates over the vulnerability results in the SARIF report (located under input.evidence.predicate.content.runs[0].results) and retrieves the corresponding rule definitions from input.evidence.predicate.content.runs[0].tool.driver.rules based on each result's ruleIndex.

The rule checks whether the result’s ruleId contains any of the identifiers specified in the configuration (with.rule_ids). If the total number of matching findings exceeds the allowed threshold (specified by with.violations_threshold), a violation is recorded. Each violation includes details such as the rule identifier, the extracted severity, and the location of the finding.

Evidence Requirements

  • Evidence must be provided in a generic format conforming to the SARIF 2.1.0 schema.
  • The SARIF report should be generated by Semgrep.
  • The report must include detailed rule definitions and descriptions that support matching against the specified blocklist.

Evidence Requirements

FieldValue
signedFalse
content_body_typegeneric
target_typedata
predicate_typehttp://docs.oasis-open.org/sarif/sarif/2.1.0

Input Definitions

ParameterTypeRequiredDescription
rule_levelarrayFalseList of rule levels to check for in the SARIF report.
precisionarrayFalseList of precision levels to check for in the SARIF report.
rule_idsarrayFalseList of rule IDs to check for in the SARIF report.
ignorearrayFalseList of rule IDs to ignore in the SARIF report.
max_allowedintegerFalseThe maximum number of allowed violations.