semgrep-rule-author
Use after a defect pattern is confirmed and you need a reusable Semgrep detector for sibling instances: derive syntactic or taint rules from vulnerable and safe fixtures, encode project sanitizers, and measure repository-wide false positives. Not for choosing generic rulesets or scanning only a change.
- License 许可
- MIT
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- semgrep-rule-author
- audience
- specialist
- description
- Use after a defect pattern is confirmed and you need a reusable Semgrep detector for sibling instances: derive syntactic or taint rules from vulnerable and safe fixtures, encode project sanitizers, and measure repository-wide false positives. Not for choosing generic rulesets or scanning only a change.
03 SKILL.md 正文
Semgrep Rule Author
Turn a confirmed defect pattern into a Semgrep rule that finds its siblings without drowning the caller in false positives.
Steps
- Start from a confirmed instance, not from an idea. Write down the minimal vulnerable snippet and the minimal safe snippet that must not match.
- Decide the rule's shape: syntactic
patternfor a fixed misuse,patternswithpattern-inside/pattern-notfor context-dependent misuse, andmode: taintwithpattern-sources/pattern-sinkswhen the defect is a data-flow problem rather than a shape. - Prefer taint mode for injection classes. A syntactic rule for a data-flow bug produces the false-positive rate that gets rules disabled.
- Write
pattern-notclauses for the sanitizers and safe wrappers this codebase actually uses; generic sanitizer lists miss project-specific ones. - Use metavariables to bind the attacker-controlled value and
metavariable-patternto constrain it, so the rule expresses the condition rather than the syntax. - Set
severityand write amessagethat names the consequence and the fix, not the pattern. The message is what a reader acts on. - Test against a corpus: the known instances must all match, the known-safe snippets must not, and a full run over the repo must have a triageable hit count.
- Measure and record the false-positive rate on that run. A rule shipped without a measured rate is unverified.
- Version the rule with the defect class it came from, so
variant-analysiscan reuse it and future reviewers know its provenance.
Acceptance
- The rule was derived from a confirmed instance, with vulnerable and safe fixtures committed alongside.
- Data-flow defects use taint mode rather than syntactic matching.
- Project-specific sanitizers are excluded via
pattern-not. - All known instances match, all safe fixtures do not, and the repo-wide false-positive rate is measured and recorded.
- The message states consequence and fix, and the rule records its originating defect class.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.