/qa-security-scanning:semgrep-rulesfrom qa-security-scanning
Writes and runs Semgrep SAST rules using YAML pattern-DSL. Covers registry rulesets, custom rules, semgrep ci with diff-aware baselines, nosemgrep suppressions, and SARIF/JUnit output.
Ships in qa-security-scanning. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Per semgrep.dev/docs/getting-started/quickstart:
Semgrep is a fast pattern-based static analyzer covering 30+
languages with a registry of community + paid rulesets and
straightforward YAML rule authoring. The semgrep ci subcommand
adds CI-aware features (baseline-diff, organization policies,
metrics).
Per semgrep.dev/docs/cli-reference:
"
semgrep scan: Local scans without account requirement; doesn't return failing codes by default.
semgrep ci: Pipeline execution with organization policies, diff-aware scanning, returns failing codes on findings."
.semgrep.yml / .semgrep/ directory or wants
zero-config registry rulesets.Per sg-quick:
# macOS
brew install semgrep
# Linux/macOS
pipx install semgrep
# or
uv tool install semgrep
# Windows (PowerShell)
pipx install semgrep
# Docker (CI-friendly)
docker pull semgrep/semgrep
semgrep scan --config auto
Per sg-cli, --config auto "Auto-fetch rules from
registry based on project." Specific rulesets:
semgrep scan --config p/owasp-top-ten # OWASP Top 10
semgrep scan --config p/default # broad community ruleset
semgrep scan --config p/python --config p/javascript # multiple: repeat --config
A minimal Semgrep rule in .semgrep.yml:
rules:
- id: hardcoded-jwt-secret
pattern: jwt.sign($PAYLOAD, "...")
message: Hardcoded JWT secret detected
languages: [javascript, typescript]
severity: ERROR
metadata:
cwe: "CWE-798: Use of Hard-coded Credentials"
Pattern operators: pattern, pattern-either, pattern-not,
metavariable-pattern, pattern-inside. Validate rule syntax:
semgrep validate --config .semgrep.yml
(Per sg-cli subcommand list.)
Keep custom rules in rules/, one file per rule, and put a test file
next to each with the same basename (rules/hardcoded-jwt-secret.yaml →
rules/hardcoded-jwt-secret.js). Each annotation is a comment on the
line just before the code it describes: ruleid: must match (guards
against false negatives), ok: must not (guards against false
positives) (sg-test):
// ruleid: hardcoded-jwt-secret
jwt.sign(payload, "s3cr3t");
// ok: hardcoded-jwt-secret
jwt.sign(payload, process.env.JWT_SECRET);
semgrep --test rules/
Add one ruleid: line per variant the rule must catch (aliased import,
template literal, wrapped call). todoruleid: / todook: record known
gaps without failing the run (sg-test).
Per sg-cli: "--baseline-commit=VAL - Only show results that
are not found in this commit hash". Diff-aware mode fails only NEW
findings on the PR; pre-existing findings are tracked but don't block -
critical for legacy adoption. The baseline commit must exist locally,
so check out full history. semgrep scan exits 0 on findings unless
--error is set ("Exit 1 if there are findings").
jobs:
semgrep:
runs-on: ubuntu-latest
container:
image: semgrep/semgrep
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- run: >
semgrep scan --config p/default --config rules/
--baseline-commit "${{ github.event.pull_request.base.sha }}"
--error --sarif --output semgrep.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: semgrep.sarif }
With a Semgrep AppSec Platform token, semgrep ci runs the rules
configured there, takes the same --baseline-commit, and fails on
findings by default; it does not accept --config (sg-cli).
There is no --baseline-ref flag.
Suppression mechanisms in priority order:
| Mechanism | Example | When to use |
|---|---|---|
Per-line nosemgrep comment | # nosemgrep: hardcoded-password | Justified single-line exception |
nosemgrep block | # nosemgrep: rule-id above a code block | Multi-line exception |
paths.exclude in config | exclude: ["**/*_pb.go"] | Generated files / vendored code |
| Baseline ref | --baseline-commit <PR base SHA> (Step 4) | Legacy debt; ratchet |
| Organization-level rule disable | Semgrep AppSec Platform UI | Team-wide policy |
Justification template (mandatory in code):
# nosemgrep: hardcoded-password
# Reason: Test fixture; password never reaches production runtime
# Reviewer: [email protected] (2026-05-15)
# Expires: 2026-12-15
TEST_PASSWORD = "test-only-password-do-not-deploy"
Per sg-cli severity filter for triage workflow:
semgrep scan --severity ERROR --json # only critical findings
Cadence: every quarter, audit nosemgrep suppressions for
staleness. Expired ones removed; persistent ones reviewed for
escalation.
Gate on exit 0 = clean, 1 = findings, 2 = fatal error. The full
output-format flags, performance-tuning flags, and complete exit-code
table are in references/cli-reference.md.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
--config=auto everywhere | Rulesets drift; no ownership | Pin specific rulesets (Step 2) |
nosemgrep without justification | Becomes invisible debt | Required justification template (Step 5) |
| No baseline ref | Every legacy finding blocks; team disables | --baseline-commit <PR base SHA> (Step 4) |
Custom rule with no ruleid: / ok: test file | A pattern edit silently stops matching a variant | semgrep --test rules/ in CI (Step 3) |
semgrep scan in CI | Doesn't return failing exit code by default | Use semgrep ci (Step 1 quote) |
Mix --severity ERROR with --baseline-commit poorly | Can mask real new findings | Severity filter at output stage, not scan stage |
codeql-queries.evals/new-hire-deleted-every-suppression-comment/criteria.json (opens in a new tab)evals/new-hire-deleted-every-suppression-comment/task.md (opens in a new tab)evals/nine-year-old-monolith-about-to-turn-scanning-on/criteria.json (opens in a new tab)evals/nine-year-old-monolith-about-to-turn-scanning-on/task.md (opens in a new tab)evals/pattern-that-would-flag-our-own-sanctioned-helper/criteria.json (opens in a new tab)evals/pattern-that-would-flag-our-own-sanctioned-helper/task.md (opens in a new tab)evals/security-check-passes-a-file-we-planted-a-hole-in/criteria.json (opens in a new tab)evals/security-check-passes-a-file-we-planted-a-hole-in/task.md (opens in a new tab)evals/twenty-two-minute-check-someone-wants-tuned-down/criteria.json (opens in a new tab)evals/twenty-two-minute-check-someone-wants-tuned-down/task.md (opens in a new tab)references/cli-reference.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub testland/qa --plugin qa-security-scanning17 skills in this plugin
/codeql-queriesUse for any question or task about CodeQL or deep semantic static analysis (SAST) on a GitHub repo, including setting up code scanning and finding injection that flows through helper functions across files: codeql database create and analyze per language, query packs, SARIF upload to code scanning, and suppressions./cve-exploitability-triageUse when a dependency, image or SBOM scan returned more CVEs than the team can fix and someone must decide what to fix first. Ranks each CVE by EPSS exploit probability and CISA KEV status, applies VEX and reachability, and sorts findings into Fix-Now, This-Sprint, Backlog or Accept-Risk./Other plugins' skills for the same job