| name | semgrep |
| description | Run Semgrep security and code quality analysis |
| triggers | ["semgrep","security scan","sast scan","vulnerability scan","code security","security audit"] |
| requires_binary | ["semgrep"] |
Semgrep Security Analysis
Run Semgrep to detect security vulnerabilities and code quality issues in the codebase.
Workflow
1. Run Semgrep scan
semgrep scan --config auto --json --quiet 2>/dev/null | head -c 50000
If JSON output is too large, use text output:
semgrep scan --config auto --quiet 2>/dev/null
2. For specific rule sets
semgrep scan --config "p/security-audit" --json --quiet
semgrep scan --config "p/owasp-top-ten" --json --quiet
semgrep scan --config "p/golang" --json --quiet
semgrep scan --config "p/python" --json --quiet
semgrep scan --config "p/typescript" --json --quiet
3. Triage results
For each finding:
- Read the file and surrounding context
- Assess whether the finding is a true positive or false positive
- For true positives, fix the issue following the suggestion in the finding
- For false positives, consider adding a
# nosemgrep inline comment with justification
4. Scan specific files
semgrep scan --config auto --json --quiet -- path/to/file.py
Common Issues
- Too many findings: Use
--severity ERROR to focus on critical issues first
- Slow scan: Use
--config auto instead of multiple rule packs to avoid re-scanning
- Missing rules: Install additional rules with
semgrep registry
- False positives: Add
# nosemgrep: rule-id with a comment explaining why