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.
Scan your codebase and export results
Navigate to the root of your codebase to run first scan. The specific command you use depends on how you want to view the results. To view the results in the CLI:The JSON schema for Semgrep’s CLI output can be found in semgrep/semgrep-interfaces.In addition to the
--text, --json, and --sarif flags, which set the primary output formats, and the --output= flag that saves the results to a file or posts to a URL, you can append -- -output= to obtain additional output streams:
: text, json, sarif, gitlab-sast, gitlab-secrets, junit-xml, emacs, vim
Scan your codebase with a specific ruleset
You can scan your codebase using--config auto to run Semgrep with rules that apply to your programming languages and frameworks:
INFOSemgrep collects pseudonymous metrics when you use rules from the Registry. You can turn this off with
--metrics=off.--config flag.
dir/.hidden/myrule.yml, are processed by Semgrep when scanning with the --config flag.
Scan with rules in a directory and all its subdirectories:
Test custom rules
Semgrep includes features to test the custom rules that you write:Improve performance for large codebases
You can set the number of subprocesses Semgrep uses to run checks in parallel:Semgrep doesn’t currently support parallelism on Windows.
Set log levels
Semgrep provides three levels of logging:| Log level | Flag | Description |
|---|---|---|
| Default | None | Prints scan progress, findings information, warnings, and errors. |
| Verbose | -v or --verbose | Includes everything printed when using the default logging level, adding a list of rules and details such as skipped files. |
| Debug | --debug | Logs the entire scan process at a high level of detail. |
Example usage
To set the logging level for a scan, include the flag when scanning your project:Exit codes
The commandsemgrep scan finishes with exit code 0 as long as the scan completes, regardless of whether there were findings. To finish with exit code 1 when there are findings, pass in the --error flag.