Semgrep
Outil d'analyse statique pour trouver des problèmes de sécurité dans le code source. Supporte 30+ langages avec des ensembles de règles personnalisables. Static analysis tool for finding security issues in source code. Supports 30+ languages with customizable rule sets.
↗ https://semgrep.devOverview
Semgrep is a fast, open-source static analysis tool that finds bugs and security vulnerabilities in source code. It’s pattern-based — rules look like the code they match, making them easy to write and understand.
Common Usage
Scan with auto-detected rules (based on languages found)
semgrep --config auto .
# Use official security ruleset
semgrep --config p/security-audit .
semgrep --config p/owasp-top-ten .
semgrep --config p/secrets .
Scan specific directory
semgrep --config auto src/
# Output formats
semgrep --config auto . --json -o results.json
semgrep --config auto . --sarif -o results.sarif
Scan a specific file
semgrep --config auto app/controllers/auth.js
# Use community rules for a specific framework
semgrep --config p/django .
semgrep --config p/flask .
semgrep --config p/nodejs .
Useful Rule Packs
| Pack | Purpose |
|---|---|
p/security-audit | General security issues |
p/secrets | Hardcoded credentials and API keys |
p/owasp-top-ten | OWASP Top 10 vulnerabilities |
p/injection | Injection vulnerabilities |
p/xss | Cross-site scripting |
Help / Man page
semgrep [options] [path]
CONFIGURATION:
--config CONFIG Rules to use:
auto Auto-detect
p/<pack> Rule pack (semgrep.dev/r)
r/<rule-id> Single rule
<file>.yaml Local rule file
<directory> Directory of rules
FILTERING:
--include GLOB Only scan matching files
--exclude GLOB Exclude matching files
--lang LANG Force language
OUTPUT:
--json JSON output
--sarif SARIF format (for CI/CD)
--text Human-readable (default)
-o, --output FILE Save output to file
--severity SEV Filter: INFO, WARNING, ERROR
PERFORMANCE:
--jobs N Parallel jobs (default: CPU count)
--timeout N Per-rule timeout in seconds
--max-memory N Max memory in MB
MISC:
--verbose Verbose output
--no-git-ignore Don't respect .gitignore
--validate Validate rule files
Vue d’ensemble
Semgrep est un outil d’analyse statique rapide et open-source qui détecte les bugs et vulnérabilités de sécurité dans le code source. Il est basé sur des patterns : les règles ressemblent au code qu’elles cherchent, les rendant faciles à écrire et comprendre.
Utilisation courante
# Scanner avec détection automatique des règles (basé sur les langages trouvés)
semgrep --config auto .
# Utiliser le jeu de règles de sécurité officiel
semgrep --config p/security-audit .
semgrep --config p/owasp-top-ten .
semgrep --config p/secrets .
# Scanner un répertoire spécifique
semgrep --config auto src/
# Formats de sortie
semgrep --config auto . --json -o results.json
semgrep --config auto . --sarif -o results.sarif
# Scanner un fichier spécifique
semgrep --config auto app/controllers/auth.js
# Utiliser des règles communautaires pour un framework spécifique
semgrep --config p/django .
semgrep --config p/flask .
semgrep --config p/nodejs .
Packs de règles utiles
| Pack | Utilité |
|---|---|
p/security-audit | Problèmes de sécurité généraux |
p/secrets | Credentials codés en dur et clés API |
p/owasp-top-ten | Vulnérabilités OWASP Top 10 |
p/injection | Vulnérabilités d’injection |
p/xss | Cross-site scripting |
Aide / Page de manuel
semgrep [options] [path]
CONFIGURATION:
--config CONFIG Rules to use:
auto Auto-detect
p/<pack> Rule pack (semgrep.dev/r)
r/<rule-id> Single rule
<file>.yaml Local rule file
<directory> Directory of rules
FILTERING:
--include GLOB Only scan matching files
--exclude GLOB Exclude matching files
--lang LANG Force language
OUTPUT:
--json JSON output
--sarif SARIF format (for CI/CD)
--text Human-readable (default)
-o, --output FILE Save output to file
--severity SEV Filter: INFO, WARNING, ERROR
PERFORMANCE:
--jobs N Parallel jobs (default: CPU count)
--timeout N Per-rule timeout in seconds
--max-memory N Max memory in MB
MISC:
--verbose Verbose output
--no-git-ignore Don't respect .gitignore
--validate Validate rule files