viper-semgrep-rule-author
Skill22 starsChanged 15 days agoMITView on GitHub
Custom SAST & Semgrep Rule Authoring Guide (modeled on semgrep/skills). Converts verified CWE findings into deterministic, low-noise CI guardrail rules with unit tests.
In this repository72 other files it gives its agents.
- llms.txtllms.txt
- viper-agent-skill-supplychainSkill
- viper-ai-llm-guardrailsSkill
- viper-api-gateway-apigee-kongSkill
- viper-auth-oauth-jwtSkill
- viper-aws-iam-cloud-auditSkill
- viper-bola-idorSkill
- viper-browser-extension-mv3Skill
- viper-browseros-agentSkill
- viper-cicd-hardeningSkill
- viperclawSkill
- viper-container-k8s-auditSkill
- viper-crypto-tls-auditSkill
- viper-csrf-samesite-auditSkill
- viper-dependency-sbomSkill
- viper-deserialization-parserSkill
- viper-diff-pr-reviewSkill
- viper-dns-email-domainSkill
- viper-electron-tauri-desktopSkill
- viper-fastapi-django-flaskSkill
- viper-file-upload-storageSkill
- viper-gcp-azure-cloud-auditSkill
- viper-github-repo-governanceSkill
- viper-go-service-auditSkill
- viper-graphql-wsSkill
- viper-grpc-protobuf-auditSkill
- viper-headers-csp-corsSkill
- viper-iac-terraform-auditSkill
- viper-incident-forensics-triageSkill
- viper-injection-oracleSkill
- viper-java-spring-auditSkill
- viper-js-harvesterSkill
- viper-kafka-rabbitmq-queueSkill
- viper-linux-systemd-hostSkill
- viper-logging-pii-complianceSkill
- viper-mcp-server-auditSkill
- viper-mobile-api-configSkill
- viper-multitenant-isolationSkill
- viper-nextjs-react-rscSkill
- viper-nginx-envoy-gatewaySkill
- viper-nodejs-express-nestjsSkill
- viper-oauth-oidc-complianceSkill
- viper-openapi-rest-schemaSkill
- viper-orchestratorSkill
- viper-payment-stripe-pciSkill
- viper-php-laravel-wordpressSkill
- viper-postgres-redis-mongoSkill
- viper-privacy-gdpr-hipaaSkill
- viper-proof-judgeSkill
- viper-proxy-fingerprintSkill
- viper-proxy-parser-alignmentSkill
- viper-race-logicSkill
- viper-rag-vector-auditSkill
- viper-rate-limit-dos-resilienceSkill
- viper-remediation-patch-verifierSkill
- viper-ruby-rails-auditSkill
- viper-rust-memory-unsafeSkill
- viper-saml-sso-enterpriseSkill
- viper-sbom-slsa-provenanceSkill
- viper-secrets-auditSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 58
Run semgrep --test on positive and negative fixtures before enabling any rule in CI.
- Very specific: line 96
Run viperclaw taint . alongside custom Semgrep rules in CI.
- Distinctive: line 97
Verify zero regressions before promoting a rule to blocking status.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Custom SAST & Semgrep Rule Authoring Guide (viper-semgrep-rule-author)
1. Executive Scope, Standards & CWE/OWASP Mapping
- Frameworks & Standards: Semgrep Rule Syntax v2, OWASP SAMM Security Testing, CWE Top 25
- Primary CWE Mapping: CWE-89 (SQL Injection), CWE-78 (OS Command Injection), CWE-79 (XSS), CWE-918 (SSRF)
- ViperClaw MCP Tools:
viper_taint_scan,viper_verify_and_report - ViperClaw CLI Command:
viperclaw taint ./src --db .viperclaw/graph.db
2. Threat Model & Root-Cause Architecture
flowchart LR
Bug["Verified Code Finding"] --> Pattern["Minimal AST / Taint Rule"] --> Tests["ruleid + ok Test Fixtures"] --> CI["Blocking Pre-Merge Gate"]Root-Cause Analysis
Fixing a vulnerability in one controller does not prevent the same insecure API pattern from reappearing in another service. Encoding every verified root cause into a deterministic AST or taint rule stops whole vulnerability classes permanently in CI.
3. Deterministic Discovery & Grep/AST Audit Commands
# 1. Identify recurring sink patterns across the repository
viperclaw taint ./src --db .viperclaw/graph.db
# 2. Locate existing Semgrep / custom lint rule directories
rg --files -g "*semgrep*" -g "*.rules.yml"4. Senior Security Engineer 8-Point Audit Checklist
| Control ID | Audit Verification Target | Pass Criteria | Fail / Vulnerability Indicator |
RULE-01 | Prefer mode: taint for Dataflow Bugs | Injection rules model pattern-sources, pattern-sanitizers, and pattern-sinks instead of fragile regexes. | Regex-only rule flags hardcoded constant strings as SQLi. |
RULE-02 | Explicit Sanitizer Modeling | Safe casts (int(), UUID(), parameterized bindings) are declared in pattern-sanitizers. | High false-positive rate causes engineers to disable the CI rule. |
RULE-03 | Paired ruleid: and ok: Tests | Every custom rule ships with test fixtures containing both vulnerable (ruleid:) and hardened (ok:) cases. | Untested rule shipped directly to CI. |
RULE-04 | Actionable Fix Guidance | Rule message explains the exact safe internal wrapper or API to use instead. | Generic message ("Unsafe call detected") with no migration guidance. |
RULE-05 | Complete Metadata (CWE/OWASP/Confidence) | Every rule specifies cwe, owasp, category: security, confidence, and impact. | Unclassified findings break SARIF triage dashboards. |
RULE-06 | Scoped Language & Path Filters | Rules exclude generated vendored files and test mocks where appropriate (paths.exclude). | Alerts fire on unit-test fixtures instead of production routes. |
RULE-07 | Low-Noise Blocking Threshold | Only HIGH confidence rules block PR merges; experimental rules run in audit mode first. | Noisy rules block unrelated pull requests. |
RULE-08 | Periodic Precision Measurement | Track true-positive vs. false-positive rate on PR comments quarterly. | Stale rules silently ignored via inline nosemgrep comments. |
5. False-Positive Elimination & CVSS v3.1 Triage Rubric
False-Positive Gate
- Run
semgrep --teston positive and negative fixtures before enabling any rule in CI. - Audit
nosemgrepsuppressions during PR review to ensure real issues are not silenced.
| Severity Tier | Baseline CVSS v3.1 Vector | Qualifying Security Impact |
| HIGH (7.5) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N | Unenforced guardrail allowing recurring injection or auth-boundary regressions across services. |
| MEDIUM (5.3) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N | Missing sanitizer definitions or untested CI rules permitting drift. |
| LOW (3.1) | CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:N/A:N | Incomplete CWE/OWASP metadata in SARIF rule exports. |
6. Production Remediation Patterns (Vulnerable vs. Hardened Code)
# ✅ HARDENED: Precision taint rule with explicit sanitizer and CWE metadata
rules:
- id: python-raw-sql-taint
mode: taint
languages: [python]
severity: ERROR
message: "User-controlled data reaches cursor.execute() without parameterization. Use bound parameters."
metadata:
cwe: "CWE-89"
owasp: "A03:2021"
confidence: HIGH
pattern-sources:
- pattern: request.args.get(...)
- pattern: request.form.get(...)
pattern-sanitizers:
- pattern: int(...)
pattern-sinks:
- pattern: $CURSOR.execute($QUERY)7. Regression Testing & Continuous Verification
- Validate every rule against paired
ruleid:andok:unit test cases. - Run
viperclaw taint .alongside custom Semgrep rules in CI. - Verify zero regressions before promoting a rule to blocking status.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

