Documentation Index
Fetch the complete documentation index at: https://docs.semgrep.dev/llms.txt
Use this file to discover all available pages before exploring further.
Blocking findings
Blocking findings are those identified by Semgrep Code using rules defined in Semgrep AppSec Platform’s Policies page and are set to Block mode. You can avoid blocking findings by removing rules or by switching the rule mode to Monitor, Comment, or Disabled. If you do not use Semgrep AppSec Platform with Semgrep in CI or Semgrep Managed Scans (that is, you are using a stand-alone setup), all Semgrep findings are blocking findings. The existence of any findings means that Semgrep returns an exit code of1, which you can use to block your PRs or MRs.
Semgrep’s default behavior regarding blocking findings and errors
When Semgrep identifies one or more blocking findings, it returns exit code1. You can use this result to set up additional checks to enforce a block in your CI/CD pipeline, such as not allowing the merge of the PR/MR. This action applies to both full scans and .
The process to enforce a block on a PR or MR after Semgrep exits with error code 1 is dependent on your CI provider. Review your CI provider’s documentation for further information.
If Semgrep encounters an internal error, it sends an anonymous crash report to a crash-reporting server and returns exit code 0. If you want to catch internal errors, review the CLI reference for more information about Semgrep’s exit codes and the options explained in this article to determine how you want to handle each exit code.
Configuration options for blocking findings and errors in CI
You can configure, change, or revert to the default setup of blocking findings and errors in your CI pipeline by passing one of the following options in thesemgrep.yml file used to configure and run Semgrep in your CI pipeline:
| CI option | Description |
|---|---|
semgrep ci or semgrep ci --suppress-errors | Default. CI fails on blocking findings, but passes on internal errors. |
semgrep ci --no-suppress-errors | CI fails on blocking findings and internal errors. |
semgrep ci || true | CI passes on blocking findings and internal errors. |
semgrep ci command, to the CI option that best fits your needs. For example, GitHub users should edit the semgrep.yml workflow file and include the following under the run key:
script key:
Sample configurations for blocking findings and errors
The following is a sample.semgrep.yml file you can use with GitHub Actions. Semgrep’s default behavior regarding blocking findings and errors applies here:
- Semgrep returns exit code
1if there are blocking findings - Semgrep returns exit code
0if there are no blocking findings, even if there are internal errors. Semgrep does, however, send an anonymous report to the crash-reporting server.
0 or 1.
--suppress-errors flag. The modified portion of the configuration file is as follows:
- BitBucket Pipelines
- Buildkite
- CircleCI
- GitHub Actions
- GitLab CI/CD
- Jenkins