Find similar vulnerabilities and bugs across codebases using pattern-based analysis...
Find the other instances of a bug you have already found. One root cause usually has several manifestations, and they are rarely in the module where you found the first one.
Read the reference for a step when you reach it.
1. Understand the original issue. Extract the root cause ā why the code is wrong, not what it does ā and enumerate the directions a variant could hide in: related identifiers, other manifestations of the same mistake, data-type edge cases. ā references/root-cause.md
2. Create an exact match. Write a pattern matching ONLY the known instance and confirm it hits. A pattern that matches nothing means you have misunderstood the bug, and every search built on it is calibrated against the wrong code.
3ā4. Generalize one element at a time. Climb from the exact match toward the pattern family, running and reading all matches after each single change. Stop when more than half the matches are noise. ā references/searching.md ā abstraction ladder, tool selection, false-positive filters
5. Triage. Decide which candidates are real, and say so with a severity attached. ā references/triage.md
Then write it up, including the patterns that failed and a CI rule to prevent regression. ā references/reporting.md
This plugin ships /variant-analysis:variants, which runs the five steps across parallel
subagents ā one per expansion axis, looping until the sweep stops finding anything new.
Each stage reads the reference above that matches its job.
Use the workflow when the codebase is large or the root cause has many manifestations. Work the steps directly when the search is narrow or you want a say in each generalization.
The first three are covered in root-cause.md and searching.md, the fourth in triage.md.
CodeQL (resources/codeql/): python.ql, javascript.ql, java.ql, go.ql, cpp.ql
Semgrep (resources/semgrep/): python.yaml, javascript.yaml, java.yaml, go.yaml, cpp.yaml
Report: resources/variant-report-template.md