semgrep-rule-variant-creator

Ports existing Semgrep rules to target languages with test-driven validation.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/marumo333/atrox --skill semgrep-rule-variant-creator-marumo333
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: semgrep-rule-variant-creator
Source: https://github.com/marumo333/atrox/tree/main/.claude/skills/trailofbits/plugins/semgrep-rule-variant-creator/skills/semgrep-rule-variant-creator
Command: npx skills add https://github.com/marumo333/atrox --skill semgrep-rule-variant-creator-marumo333

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Porting a Semgrep rule from one programming language to another is error-prone: AST structures differ, equivalent APIs have different semantics, and naive syntax translation produces rules that miss vulnerabilities or generate false positives. This Skill provides a strict, structured workflow for creating correct language variants of existing rules. ## Core Features & Use Cases - Applicability Analysis: Determines whether a vulnerability pattern meaningfully applies to each target language before any porting work begins, with documented verdicts (APPLICABLE, APPLICABLE_WITH_ADAPTATION, NOT_APPLICABLE). - Test-First Porting Workflow: Enforces a four-phase cycle per language—applicability analysis, test creation, rule creation, and validation—requiring 100% test pass before moving to the next language. - Language Translation Guidance: Provides reference material on AST analysis, metavariable adaptation, source/sink/sanitizer translation, and language-specific idioms. - Use Case: You have a Python SQL injection taint rule and need coverage for Go and Java. Provide the rule and target languages, and receive independent rule+test directories (e.g., sql-injection-golang/, sql-injection-java/) with validated, passing tests for each. ## Quick Start Port my existing Semgrep rule python-command-injection.yaml to Go and Java, creating a tested rule variant directory for each applicable language.

Frequently Asked Questions about semgrep-rule-variant-creator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I port a Semgrep rule to another language?▼

Provide the existing rule YAML and target languages, then follow the four-phase cycle per language: applicability analysis, test creation, rule creation, and validation. Each language completes independently before starting the next, and all tests must pass.

How to translate Semgrep taint rules between languages?▼

Identify the original rule's sources, sinks, and sanitizers, then research equivalent constructs in the target language such as exec.Command in Go or Runtime.exec in Java. Dump the target language AST with semgrep --dump-ast to verify pattern structure before writing the rule.

When should a Semgrep rule not be ported to a language?▼

Skip porting when the vulnerability class does not exist in the target language, such as C buffer overflows in Python, or when no equivalent construct exists. The applicability analysis phase produces a NOT_APPLICABLE verdict with documented reasoning.

Why does my ported Semgrep rule fail its tests?▼

Failures usually come from assuming identical AST structure across languages or patterns that are too broad or too specific. Use semgrep --dump-ast to compare structure and semgrep --dataflow-traces to debug taint propagation issues.

What is the difference between semgrep-rule-creator and semgrep-rule-variant-creator?▼

semgrep-rule-creator builds a new rule from a bug pattern description, while the variant creator takes an existing rule plus target languages and produces multiple independent rule and test directories. The variant creator adds a per-language applicability analysis phase.