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.
INFOSemgrep CE is the open source version of Semgrep Code, a commercial offering recommended for enterprise use cases. Both products share a common command-line interface, but Semgrep Code adds additional capabilities, including a web user interface.
Prerequisites
See Prerequisites to ensure your machine meets Semgrep’s requirements.Install Semgrep CE
- macOS
- Linux
- Windows (beta)
Install the Semgrep CLI and confirm the installation:Homebrew users: ensure that you’ve added Homebrew to your PATH.
Create a test file for use with Semgrep CE
Navigate to the directory of your choice, and create a sample file calledapp.py with the following:
Scan app.py with Semgrep CE
To check your code for security vulnerabilities:
Invoke Semgrep CE using The specific numbers shown in your Scan Status printed to the terminal may vary, but you can still see that Semgrep is scanning the source code using community rules. There are over 1000 community rules in the default rule set, but because Semgrep recognizes the source code language, only rules relevant to the code being scanned are evaluated.To fine-tune your scan, you can include the In the preceding example, the command uses a predefined rule set from the Semgrep Registry focused on command injection vulnerabilities in Python. The specific rules you use during a scan will significantly impact what is detected in your source code.
semgrep scan. The semgrep scan command pulls down rules from the Semgrep Registry, similar to package managers for source code libraries, and stores rules that help define semantic meaning to patterns in source code. By default, Semgrep CE uses open source community rules:--config parameter, which allows you to choose which rules to run:View and understand Semgrep Scan output
Semgrep displays your results when the scan is completed. The Scan Summary printed to the terminal tells you how many rules were run and whether or not there were any findings. A finding indicates that Semgrep detected a potential vulnerability.python.lang.
The rule’s author defines the source code patterns and provides remediation advice or an explanation of the problem. In this example, you can also see the specific expression and line of code where the issue appears.
This example is a Command Injection vulnerability. The rule advises you to review the Python Code Injection Cheat Sheet to learn more. The link in the output takes you to the Semgrep Playground, where you can interactively modify this rule and test it against sample code.