Semgrep is a fast, open-source, static analysis engine for finding bugs, detecting vulnerabilities in third-party dependencies, and enforcing code standards across over 30 programming languages. It scans code locally, without uploading it to external servers by default. As of version 1.156.0, it is actively developed with frequent (often weekly) releases, offering both a free Community Edition and a commercial AppSec Platform with enhanced features.
pip install semgrepVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically run a Semgrep scan on a Python file using the `subprocess` module. It creates a dummy file with a common vulnerability pattern, runs Semgrep with a security ruleset, and parses the JSON output to display findings.
Remove any usage of `semgrep install-ci`. Consult official documentation for recommended CI/CD integration patterns.
Ensure your integrations with the Semgrep MCP server (Model Context Protocol) are updated to use OAuth for authentication.
Monitor scan performance and resource consumption after upgrading. If necessary, consult Semgrep documentation for options to adjust memory policies or optimize scans.
To force a non-zero exit code on findings, use the `--error` flag with `semgrep scan` or configure blocking rules in the Semgrep AppSec Platform for `semgrep ci`.
For comprehensive security scanning (SAST, SCA, secrets), Semgrep, Inc. strongly recommends using the commercial Semgrep AppSec Platform which includes advanced analysis capabilities and AI-assisted triage.
Ensure Semgrep is executed from the intended project directory. When specifying files to scan (e.g., using explicit paths or `.` for current directory), confirm they are accessible and correctly located relative to where Semgrep is invoked. Check for issues with bind mounts or working directories in containerized environments (like CI/CD) that might alter Semgrep's perception of the filesystem.
Install Semgrep using your preferred package manager (e.g., `brew install semgrep` on macOS, `pip install semgrep` for Python environments) and ensure the installation path is in your system's PATH.
Provide a valid rule configuration using the `--config` flag, specifying a single rule file, a directory containing rule files, or a Semgrep registry rule (e.g., `semgrep --config auto .` or `semgrep --config path/to/rules.yaml .`).
Carefully review the specified rule file (<file_path>) for incorrect YAML syntax (e.g., indentation, missing colons) or structural issues. Refer to the official Semgrep documentation for correct rule writing and schema guidelines (e.g., `https://semgrep.dev/docs/writing-rules/`).
Ensure files have standard extensions for their respective languages. If Semgrep still can't detect it, you can explicitly specify the language using the `--lang` flag (e.g., `semgrep --lang python --config rules.yaml your_file`).
No dependency data recorded yet.