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.
Prerequisites
- An existing Semgrep org account.
- Semgrep CLI tool installed in your local machine.
Best practices
It’s best to run the following command for local scans:- The command
semgrep citells Semgrep to use your organization’s chosen analyses and rules for the scan. - The
--dry-runflag ensures that your scans are not uploaded to the Semgrep web app. This is recommended because your code could be a work in progress, subject to change, whereas code uploaded as a PR or MR usually indicates the code is ready for review.
Common Semgrep commands
semgrep scan
The following command runs a local scan with Semgrep’s open source Community Edition (CE) using pre-selected rules for a variety of languages:
semgrep scandoes not take into account your organization’s settings.- You do not need to be logged in to run a scan.
- It only runs lightweight SAST analyses.
- It does not run other Semgrep products, such as Secrets or Supply Chain.
Test a custom rule
You can test a custom rule by creating a test file. See Testing rules. After you’ve tested your custom rule, you can try it on your codebase locally:- Ensure that you’re signed in to Semgrep from the CLI by entering
semgrep login. If you have successfully signed in, you should see API token already exists or a similar message. - Enter the following command:
Replace
CUSTOM_RULE.yamlwith the name of your custom rule.
semgrep ci
The semgrep ci command, without any flags, sends the results of your scan to Semgrep AppSec Platform with the slug local-scan/PROJECT_NAME. When using this command in a team setting, ensure that you are aware of its risks and that your team members are aware that you’re uploading the results of local scans.