hypnguyen1209/offensive-claude / skills/vulnerability-analysis
vulnerability-analysis
UnverifiedUse when auditing source code for vulnerabilities — drive CodeQL/Semgrep/Joern to taint untrusted data source-to-sink across injection, memory safety, deserialization/prototype-pollution, secrets/crypto/authz/race, and supply-chain risks
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.4 KB |
| references/deserialization-prototype-pollution.md | markdown | 8.3 KB |
| references/injection-source-patterns.md | markdown | 8.6 KB |
| references/memory-safety-c-cpp.md | markdown | 7.7 KB |
| references/secrets-crypto-authz-concurrency.md | markdown | 8.6 KB |
| references/supply-chain-dependency-audit.md | markdown | 7.3 KB |
| references/taint-engines-static-analysis.md | markdown | 11.0 KB |
| references/variant-hunting.md | markdown | 3.4 KB |
| scripts/dep_audit.py | script | 10.9 KB |
| scripts/deser_gadget_scan.py | script | 7.7 KB |
| scripts/evidence_kit.py | script | 13.0 KB |
| scripts/finding_dedup.py | script | 4.2 KB |
| scripts/joern_taint.sc | other | 3.6 KB |
| scripts/merge_runtime_evidence.py | script | 6.1 KB |
| scripts/path_conditions.py | script | 10.6 KB |
| scripts/provenance.py | script | 2.8 KB |
| scripts/sast_runner.py | script | 7.8 KB |
| scripts/secret_crypto_audit.py | script | 8.1 KB |
| scripts/taint_trace.py | script | 14.9 KB |
| scripts/validate_findings.py | script | 22.8 KB |
| scripts/variant_hunt.py | script | 11.8 KB |
| scripts/vocab_gate.py | script | 7.5 KB |
scripts/sast_runner.py
View on GitHub#!/usr/bin/env python3
"""
sast_runner.py - Orchestrate CodeQL, Semgrep, and Joern over a target, then
normalize/dedupe their SARIF/JSON output into a single ranked finding list.
This is the "production" companion to taint_trace.py: it drives the real
interprocedural engines and merges results so you triage one list, not three.
Subcommands:
codeql build a CodeQL DB and run a query suite, emit SARIF
semgrep run Semgrep (CE or --pro interfile) with a config/registry pack
joern run a CPGQL taint-tracking script over a Joern CPG
merge load N SARIF/JSON files, dedupe by (rule,file,line), rank by severity
Dependencies (install the engines you use):
CodeQL : https://github.com/github/codeql-cli-binaries (codeql in PATH)
Semgrep : pip install semgrep (>= 1.x; --pro needs login for interfile)
Joern : https://joern.io (joern, joern-parse in PATH)
Python : 3.8+ stdlib only for merge.
Usage:
python3 sast_runner.py codeql --src ./app --lang python --out cq.sarif \\
--suite codeql/python-queries:codeql-suites/python-security-extended.qls
python3 sast_runner.py semgrep --src ./app --config p/owasp-top-ten --pro --out sg.sarif
python3 sast_runner.py joern --src ./app --script taint.sc --out joern.json
python3 sast_runner.py merge cq.sarif sg.sarif --out merged.json
LEGAL: authorized assessments only.
"""
import argparse
import json
import os
import subprocess
import sys
SEV_RANK = {"critical": 5, "error": 4, "high": 4, "warning": 3, "medium": 3,
"note": 2, "low": 2, "info": 1, "none": 0}
def run(cmd):
print(f"[*] {' '.join(cmd)}", file=sys.stderr)
return subprocess.call(cmd)
def cmd_codeql(args):
db = args.db or os.path.join(args.out_dir or ".", "codeql-db")
# 1. Create database (autobuild for compiled langs; none-build for interpreted)
create = ["codeql", "database", "create", db, "--language", args.lang,
"--source-root", args.src, "--overwrite"]
if args.command:
create += ["--command", args.command]
if run(create) != 0:
sys.exit("[!] codeql database create failed")
# 2. Analyze with a query suite -> SARIF
analyze = ["codeql", "database", "analyze", db, args.suite,
"--format", "sarifv2.1.0", "--output", args.out,
"--threads", str(args.threads), "--rerun"]
sys.exit(run(analyze))
def cmd_semgrep(args):
cmd = ["semgrep", "scan", "--config", args.config, "--sarif",
"--output", args.out, "--metrics", "off", args.src]
if args.pro:
cmd.insert(2, "--pro") # interfile + cross-function dataflow
if args.baseline:
cmd += ["--baseline-commit", args.baseline]
sys.exit(run(cmd))
def cmd_joern(args):
# joern-parse builds the CPG; joern --script runs the CPGQL taint query.
cpg = os.path.join(args.out_dir or ".", "cpg.bin")
if run(["joern-parse", args.src, "--output", cpg]) != 0:
sys.exit("[!] joern-parse failed")
env = dict(os.environ, JOERN_CPG=cpg, JOERN_OUT=args.out)
print(f"[*] joern --script {args.script} (CPG={cpg})", file=sys.stderr)
sys.exit(subprocess.call(["joern", "--script", args.script,
"--param", f"cpgPath={cpg}",
"--param", f"outPath={args.out}"], env=env))
# ---------------------------------------------------------------------------
# SARIF / JSON normalization + merge
# ---------------------------------------------------------------------------
def load_sarif(path):
with open(path, encoding="utf-8") as fh:
doc = json.load(fh)
out = []
# SARIF v2.1.0
if isinstance(doc, dict) and "runs" in doc:
for run_ in doc["runs"]:
tool = run_.get("tool", {}).get("driver", {}).get("name", "sast")
rules = {r["id"]: r for r in run_.get("tool", {}).get("driver", {}).get("rules", [])}
for res in run_.get("results", []):
rid = res.get("ruleId", "?")
sev = res.get("level", "warning")
# CodeQL packs severity in rule properties
rp = rules.get(rid, {}).get("properties", {})
sev = rp.get("problem.severity", rp.get("security-severity", sev)) or sev
for loc in res.get("locations", [{}]):
pl = loc.get("physicalLocation", {})
out.append({
"tool": tool, "rule": rid, "severity": str(sev).lower(),
"file": pl.get("artifactLocation", {}).get("uri", "?"),
"line": pl.get("region", {}).get("startLine", 0),
"message": res.get("message", {}).get("text", "")[:200],
})
# Plain JSON list (e.g. from joern.sc or taint_trace.py)
elif isinstance(doc, list):
for r in doc:
out.append({
"tool": r.get("tool", "joern"),
"rule": r.get("rule", r.get("cwe", "?")),
"severity": str(r.get("severity", "warning")).lower(),
"file": r.get("file", "?"),
"line": r.get("line", r.get("sink_line", 0)),
"message": r.get("message", r.get("sink_code", ""))[:200],
})
return out
def cmd_merge(args):
seen, merged = {}, []
for path in args.files:
for f in load_sarif(path):
key = (f["rule"], f["file"], f["line"])
if key in seen:
if f["tool"] not in seen[key]["tools"]:
seen[key]["tools"].append(f["tool"])
seen[key]["corroboration"] = len(seen[key]["tools"])
continue
f["tools"] = [f.pop("tool")]
f["corroboration"] = 1
seen[key] = f
merged.append(f)
# Rank: multi-tool corroboration first, then severity, then file.
merged.sort(key=lambda f: (-f["corroboration"], -SEV_RANK.get(f["severity"], 0), f["file"]))
with open(args.out, "w", encoding="utf-8") as fh:
json.dump(merged, fh, indent=2)
for f in merged[:args.top]:
tools = "+".join(f["tools"])
star = " *CORROBORATED*" if f["corroboration"] > 1 else ""
print(f"[{f['severity']:>8}] {f['rule']:<40} {f['file']}:{f['line']} ({tools}){star}")
print(f"\n[+] {len(merged)} unique findings -> {args.out}", file=sys.stderr)
def main():
ap = argparse.ArgumentParser(description="SAST engine orchestrator + merge")
sub = ap.add_subparsers(dest="cmd", required=True)
c = sub.add_parser("codeql")
c.add_argument("--src", required=True)
c.add_argument("--lang", required=True, help="python|javascript|java|cpp|csharp|go|ruby|swift")
c.add_argument("--suite", required=True)
c.add_argument("--out", required=True)
c.add_argument("--db"); c.add_argument("--out-dir")
c.add_argument("--command", help="build command for compiled languages")
c.add_argument("--threads", type=int, default=0)
c.set_defaults(func=cmd_codeql)
s = sub.add_parser("semgrep")
s.add_argument("--src", required=True)
s.add_argument("--config", required=True, help="registry pack (p/...), file, or dir")
s.add_argument("--out", required=True)
s.add_argument("--pro", action="store_true", help="interfile/cross-function dataflow")
s.add_argument("--baseline", help="git ref for diff-aware scan")
s.set_defaults(func=cmd_semgrep)
j = sub.add_parser("joern")
j.add_argument("--src", required=True)
j.add_argument("--script", required=True, help=".sc CPGQL taint script")
j.add_argument("--out", required=True); j.add_argument("--out-dir")
j.set_defaults(func=cmd_joern)
m = sub.add_parser("merge")
m.add_argument("files", nargs="+", help="SARIF or JSON finding files")
m.add_argument("--out", default="merged.json")
m.add_argument("--top", type=int, default=40)
m.set_defaults(func=cmd_merge)
args = ap.parse_args()
args.func(args)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |