skills/opengrep/SKILL.md
Run Opengrep static analysis for fast security scanning with open-source rules. Use when scanning with truly open-source SAST, avoiding proprietary rule licenses, using community rules freely, or requiring commercial tool integration.
npx skillsauth add igbuend/grimbard opengrepInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Opengrep is a fork of Semgrep CE (Community Edition), launched in early 2025 by a consortium including JIT, Aikido Security, Endor Labs, and other companies. It was created in response to Semgrep's licensing changes that restricted community-contributed rules from being used in commercial products.
Key Differences from Semgrep:
Ideal scenarios:
Consider CodeQL instead when:
Do NOT use this skill for:
# Homebrew
brew install opengrep
# pip
pip install opengrep
# pipx (recommended)
pipx install opengrep
# Docker
docker pull ghcr.io/opengrep/opengrep:latest
# From source
git clone https://github.com/opengrep/opengrep.git
cd opengrep
pip install -e .
# Verify
opengrep --version
# Auto scan with default rules
opengrep scan .
# Scan with specific ruleset
opengrep scan -f p/security-audit .
# Multiple rulesets
opengrep scan -f p/owasp-top-ten -f p/cwe-top-25 .
# Generate SARIF report
opengrep scan --sarif -o results.sarif .
# SARIF with specific rules
opengrep scan -f p/security-audit --sarif -o results.sarif .
# Filter by severity in SARIF
opengrep scan \
--severity=WARNING \
--severity=ERROR \
--sarif \
-o results.sarif \
.
# Enable dataflow traces
opengrep scan --dataflow-traces .
# Taint analysis (intra-file)
opengrep scan --taint-intrafile .
# Experimental features
opengrep scan --experimental .
# Combined: dataflow + taint + experimental
opengrep scan \
--dataflow-traces \
--taint-intrafile \
--experimental \
.
# Local rule files
opengrep scan -f /path/to/rules .
# Multiple rule directories
opengrep scan -f ./rules -f ./custom-rules .
# Exclude specific rules
opengrep scan \
-f p/security-audit \
--exclude-rule="rule-id-to-skip" \
.
| Ruleset | Description |
|---------|-------------|
| p/default | General security and code quality |
| p/security-audit | Comprehensive security rules |
| p/owasp-top-ten | OWASP Top 10 vulnerabilities |
| p/cwe-top-25 | CWE Top 25 vulnerabilities |
| p/trailofbits | Trail of Bits security rules |
| p/python | Python-specific security |
| p/javascript | JavaScript/TypeScript security |
| p/golang | Go-specific security |
| p/java | Java security patterns |
| p/ruby | Ruby security patterns |
# Clone community rules
git clone https://github.com/opengrep/opengrep-rules.git
# Use community rules
opengrep scan -f opengrep-rules/ .
# Trail of Bits rules (fully open)
git clone https://github.com/trailofbits/semgrep-rules.git
opengrep scan -f semgrep-rules/rules .
# Text output (default)
opengrep scan .
# SARIF (for CI/CD)
opengrep scan --sarif .
# JSON
opengrep scan --json .
# JUnit XML
opengrep scan --junit-xml .
# GitLab SAST format
opengrep scan --gitlab-sast .
# Vim quickfix
opengrep scan --vim .
# Emacs format
opengrep scan --emacs .
Create .opengrepignore:
tests/fixtures/
**/testdata/
generated/
vendor/
node_modules/
__pycache__/
*.test.js
*.spec.ts
Create .opengrep.yml:
rules:
- id: custom-hardcoded-secret
languages: [python, javascript]
message: "Hardcoded secret detected"
severity: ERROR
pattern: |
$VAR = "$SECRET"
metadata:
cwe: "CWE-798"
owasp: "A07:2021 - Identification and Authentication Failures"
- id: sql-injection-risk
languages: [python]
message: "Potential SQL injection"
severity: ERROR
mode: taint
pattern-sources:
- pattern: request.args.get(...)
pattern-sinks:
- pattern: cursor.execute($QUERY)
pattern-sanitizers:
- pattern: int(...)
exclude:
- tests/
- vendor/
Use config:
opengrep scan --config .opengrep.yml .
name: Opengrep Security Scan
on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 0 * * 1' # Weekly
jobs:
opengrep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Opengrep
run: pip install opengrep
- name: Run Opengrep
run: |
opengrep scan \
-f p/security-audit \
-f p/owasp-top-ten \
--dataflow-traces \
--taint-intrafile \
--experimental \
--sarif \
-o opengrep-results.sarif \
--severity=WARNING \
--severity=ERROR \
--exclude=test \
--exclude=tests \
.
- name: Upload SARIF
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: opengrep-results.sarif
category: opengrep
- name: Upload Results
if: always()
uses: actions/upload-artifact@v4
with:
name: opengrep-results
path: opengrep-results.sarif
rules:
- id: dangerous-eval
languages: [javascript, python]
message: "Use of eval() is dangerous"
severity: ERROR
patterns:
- pattern: eval($CODE)
- pattern-not: eval("...") # Literal strings okay
| Syntax | Description | Example |
|--------|-------------|---------|
| ... | Match anything | func(...) |
| $VAR | Capture metavariable | $FUNC($INPUT) |
| <... ...> | Deep expression match | <... user_input ...> |
| Operator | Description |
|----------|-------------|
| pattern | Match exact pattern |
| patterns | All must match (AND) |
| pattern-either | Any matches (OR) |
| pattern-not | Exclude matches |
| pattern-inside | Match only inside context |
| pattern-not-inside | Match only outside context |
| pattern-regex | Regex matching |
| metavariable-regex | Regex on captured value |
rules:
- id: xss-vulnerability
languages: [javascript]
message: "User input flows to innerHTML (XSS risk)"
severity: ERROR
mode: taint
pattern-sources:
- pattern: req.query.$PARAM
- pattern: req.body.$PARAM
pattern-sinks:
- pattern: $ELEMENT.innerHTML = $DATA
pattern-sanitizers:
- pattern: escapeHtml(...)
- pattern: DOMPurify.sanitize(...)
# Multi-ruleset scan
opengrep scan \
-f p/security-audit \
-f p/owasp-top-ten \
-f p/cwe-top-25 \
--dataflow-traces \
--experimental \
--sarif \
-o security-audit.sarif \
.
# Python security
opengrep scan \
-f p/python \
--taint-intrafile \
--sarif \
-o python-security.sarif \
./src
# JavaScript/TypeScript security
opengrep scan \
-f p/javascript \
-f p/typescript \
--dataflow-traces \
--sarif \
-o js-security.sarif \
./frontend
# Scan staged files only
git diff --cached --name-only --diff-filter=ACMR | \
grep -E '\.(py|js|ts|go|java|rb)$' | \
xargs opengrep scan -f p/security-audit
# Scan only modified files
git diff --name-only origin/main...HEAD | \
xargs opengrep scan -f p/security-audit --sarif -o diff-scan.sarif
# nosemgrep: rule-id
password = get_from_vault()
# Multiple rules
eval(safe_code) # nosemgrep: dangerous-eval, code-injection
// nosemgrep: xss-vulnerability
element.innerHTML = sanitizedContent;
# .opengrep.yml
exclude-rules:
- rule-id-1
- rule-id-2
exclude-paths:
- tests/
- generated/
# Limit to specific file types
opengrep scan --include='*.py' --include='*.js' .
# Exclude large directories
opengrep scan --exclude=node_modules --exclude=vendor .
# Set timeout per file
opengrep scan --timeout 60 .
# Disable experimental features for speed
opengrep scan -f p/security-audit . # No --experimental
Opengrep maintains compatibility with Semgrep CE:
| Feature | Opengrep | Semgrep CE | |---------|----------|------------| | License | LGPL 2.1 (fully open) | LGPL 2.1 (engine), restrictive rules | | Rules | Fully open, no restrictions | Community rules have usage restrictions | | Governance | Community consortium | r2c/Semgrep Inc. | | Commercial Use | Unrestricted | Restricted for community rules | | Pro Features | Being migrated to open | Proprietary | | Development | Community-driven | Company-driven |
# Rules are compatible - just change binary
alias opengrep=semgrep # For testing
opengrep scan -f p/security-audit .
# Update CI/CD configs
sed -i 's/semgrep/opengrep/g' .github/workflows/security.yml
| Shortcut | Why It's Wrong | |----------|----------------| | "Opengrep found nothing = code is secure" | Pattern-based analysis can miss context-specific vulnerabilities | | "Just use default rules" | Default rules are generic; custom rules for your stack are essential | | "Skip dataflow/taint analysis for speed" | These features catch vulnerabilities simple patterns miss | | "Semgrep and Opengrep are identical" | Licensing differences matter for commercial use; feature sets diverging | | "Don't need both Opengrep and CodeQL" | Complementary: Opengrep is fast/broad, CodeQL is deep/precise |
Articles:
development
Security anti-pattern for Cross-Site Scripting vulnerabilities (CWE-79). Use when generating or reviewing code that renders HTML, handles user input in web pages, uses innerHTML/document.write, or builds dynamic web content. Covers Reflected, Stored, and DOM-based XSS. AI code has 86% XSS failure rate.
development
Security anti-pattern for XPath injection vulnerabilities (CWE-643). Use when generating or reviewing code that queries XML documents, constructs XPath expressions, or handles user input in XML operations. Detects unescaped quotes and special characters in XPath queries.
development
Security anti-pattern for weak password hashing (CWE-327, CWE-759). Use when generating or reviewing code that stores or verifies user passwords. Detects use of MD5, SHA1, SHA256 without salt, or missing password hashing entirely. Recommends bcrypt, Argon2, or scrypt.
development
Security anti-pattern for weak encryption (CWE-326, CWE-327). Use when generating or reviewing code that encrypts data, handles encryption keys, or uses cryptographic modes. Detects DES, ECB mode, static IVs, and custom crypto implementations.