torusguard 2.1.0 β†’ 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/.torusguard/.manifest.json +47 -5
  2. package/.torusguard/core/__init__.py +146 -0
  3. package/.torusguard/core/agent_roles.py +104 -0
  4. package/.torusguard/core/ast_walker.py +283 -0
  5. package/.torusguard/core/authorization.py +218 -0
  6. package/.torusguard/core/browser_verifier.py +128 -0
  7. package/.torusguard/core/bundle.py +141 -0
  8. package/.torusguard/core/call_graph.py +184 -0
  9. package/.torusguard/core/clustering.py +275 -0
  10. package/.torusguard/core/confidence.py +120 -0
  11. package/.torusguard/core/cross_file_taint.py +101 -0
  12. package/.torusguard/core/exploit_checker.py +317 -0
  13. package/.torusguard/core/formatter.py +351 -0
  14. package/.torusguard/core/governance.py +210 -0
  15. package/.torusguard/core/identity.py +104 -0
  16. package/.torusguard/core/import_resolver.py +91 -0
  17. package/.torusguard/core/incremental.py +102 -0
  18. package/.torusguard/core/lifecycle.py +137 -0
  19. package/.torusguard/core/models.py +425 -0
  20. package/.torusguard/core/parallel.py +56 -0
  21. package/.torusguard/core/parser.py +202 -0
  22. package/.torusguard/core/rechecker.py +107 -0
  23. package/.torusguard/core/replay_trace.py +178 -0
  24. package/.torusguard/core/rules_registry.py +131 -0
  25. package/.torusguard/core/run_folder.py +60 -0
  26. package/.torusguard/core/run_manager.py +163 -0
  27. package/.torusguard/core/runtime_evidence.py +175 -0
  28. package/.torusguard/core/runtime_validator.py +246 -0
  29. package/.torusguard/core/safety_gate.py +139 -0
  30. package/.torusguard/core/sarif.py +189 -0
  31. package/.torusguard/core/stack_profiler.py +184 -0
  32. package/.torusguard/core/symbol_table.py +91 -0
  33. package/.torusguard/core/taint.py +133 -0
  34. package/.torusguard/core/taint_graph.py +235 -0
  35. package/.torusguard/core/taint_rules.py +268 -0
  36. package/.torusguard/core/v070_reporter.py +102 -0
  37. package/.torusguard/core/v070_workflow.py +339 -0
  38. package/.torusguard/core/v6_reporter.py +180 -0
  39. package/.torusguard/core/v6_workflow.py +221 -0
  40. package/.torusguard/core/watcher.py +58 -0
  41. package/.torusguard/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
  42. package/.torusguard/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
  43. package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
  44. package/.torusguard/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
  45. package/.torusguard/scripts/__pycache__/rules_sync.cpython-314.pyc +0 -0
  46. package/.torusguard/scripts/audit_runner.py +108 -10
  47. package/.torusguard/scripts/finding_scorer.py +43 -13
  48. package/.torusguard/scripts/skill_profiler.py +26 -0
  49. package/.torusguard/skills/torusguard/SKILL.md +6 -2
  50. package/.torusguard/skills/torusguard-audit/SKILL.md +109 -84
  51. package/.torusguard/workflows/audit.md +21 -17
  52. package/README.md +19 -11
  53. package/package.json +7 -2
  54. package/skills/torusguard/SKILL.md +6 -2
  55. package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
  56. package/skills/torusguard/bootstrap.py +3 -3
  57. package/skills/torusguard/payload/.manifest.json +48 -7
  58. package/skills/torusguard/payload/core/__init__.py +146 -0
  59. package/skills/torusguard/payload/core/agent_roles.py +104 -0
  60. package/skills/torusguard/payload/core/ast_walker.py +283 -0
  61. package/skills/torusguard/payload/core/authorization.py +218 -0
  62. package/skills/torusguard/payload/core/browser_verifier.py +128 -0
  63. package/skills/torusguard/payload/core/bundle.py +141 -0
  64. package/skills/torusguard/payload/core/call_graph.py +184 -0
  65. package/skills/torusguard/payload/core/clustering.py +275 -0
  66. package/skills/torusguard/payload/core/confidence.py +120 -0
  67. package/skills/torusguard/payload/core/cross_file_taint.py +101 -0
  68. package/skills/torusguard/payload/core/exploit_checker.py +317 -0
  69. package/skills/torusguard/payload/core/formatter.py +351 -0
  70. package/skills/torusguard/payload/core/governance.py +210 -0
  71. package/skills/torusguard/payload/core/identity.py +104 -0
  72. package/skills/torusguard/payload/core/import_resolver.py +91 -0
  73. package/skills/torusguard/payload/core/incremental.py +102 -0
  74. package/skills/torusguard/payload/core/lifecycle.py +137 -0
  75. package/skills/torusguard/payload/core/models.py +425 -0
  76. package/skills/torusguard/payload/core/parallel.py +56 -0
  77. package/skills/torusguard/payload/core/parser.py +202 -0
  78. package/skills/torusguard/payload/core/rechecker.py +107 -0
  79. package/skills/torusguard/payload/core/replay_trace.py +178 -0
  80. package/skills/torusguard/payload/core/rules_registry.py +131 -0
  81. package/skills/torusguard/payload/core/run_folder.py +60 -0
  82. package/skills/torusguard/payload/core/run_manager.py +163 -0
  83. package/skills/torusguard/payload/core/runtime_evidence.py +175 -0
  84. package/skills/torusguard/payload/core/runtime_validator.py +246 -0
  85. package/skills/torusguard/payload/core/safety_gate.py +139 -0
  86. package/skills/torusguard/payload/core/sarif.py +189 -0
  87. package/skills/torusguard/payload/core/stack_profiler.py +184 -0
  88. package/skills/torusguard/payload/core/symbol_table.py +91 -0
  89. package/skills/torusguard/payload/core/taint.py +133 -0
  90. package/skills/torusguard/payload/core/taint_graph.py +235 -0
  91. package/skills/torusguard/payload/core/taint_rules.py +268 -0
  92. package/skills/torusguard/payload/core/v070_reporter.py +102 -0
  93. package/skills/torusguard/payload/core/v070_workflow.py +339 -0
  94. package/skills/torusguard/payload/core/v6_reporter.py +180 -0
  95. package/skills/torusguard/payload/core/v6_workflow.py +221 -0
  96. package/skills/torusguard/payload/core/watcher.py +58 -0
  97. package/skills/torusguard/payload/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
  98. package/skills/torusguard/payload/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
  99. package/skills/torusguard/payload/rules/container/TG-CONT-001-root-user-execution.md +50 -50
  100. package/skills/torusguard/payload/rules/container/TG-CONT-002-docker-socket-mount.md +47 -47
  101. package/skills/torusguard/payload/rules/container/TG-CONT-003-privileged-container-mode.md +53 -53
  102. package/skills/torusguard/payload/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -43
  103. package/skills/torusguard/payload/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -44
  104. package/skills/torusguard/payload/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -41
  105. package/skills/torusguard/payload/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -40
  106. package/skills/torusguard/payload/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -72
  107. package/skills/torusguard/payload/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -51
  108. package/skills/torusguard/payload/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -51
  109. package/skills/torusguard/payload/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -46
  110. package/skills/torusguard/payload/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -43
  111. package/skills/torusguard/payload/scripts/audit_runner.py +108 -10
  112. package/skills/torusguard/payload/scripts/finding_scorer.py +43 -13
  113. package/skills/torusguard/payload/skills/torusguard/SKILL.md +6 -2
  114. package/skills/torusguard/payload/skills/torusguard/bootstrap.py +3 -3
  115. package/skills/torusguard/payload/skills/torusguard-ai-guard/SKILL.md +95 -95
  116. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +109 -84
  117. package/skills/torusguard/payload/skills/torusguard-container/SKILL.md +94 -94
  118. package/skills/torusguard/payload/skills/torusguard-git-mine/SKILL.md +92 -92
  119. package/skills/torusguard/payload/skills/torusguard-ocr-scan/SKILL.md +94 -94
  120. package/skills/torusguard/payload/skills/torusguard-redos/SKILL.md +91 -91
  121. package/skills/torusguard/payload/workflows/ai-guard.md +31 -31
  122. package/skills/torusguard/payload/workflows/audit.md +21 -17
  123. package/skills/torusguard/payload/workflows/container.md +29 -29
  124. package/skills/torusguard/payload/workflows/git-mine.md +25 -25
  125. package/skills/torusguard/payload/workflows/ocr-scan.md +25 -25
  126. package/skills/torusguard/payload/workflows/redos.md +27 -27
  127. package/skills/torusguard/payload/workflows/torusguard-audit.md +35 -55
  128. package/skills/torusguard/references/csharp-security.md +41 -41
  129. package/skills/torusguard/references/go-security.md +41 -41
  130. package/skills/torusguard/references/java-security.md +40 -40
  131. package/skills/torusguard/references/polyglot-security-matrix.md +25 -25
  132. package/skills/torusguard/references/rust-security.md +40 -40
  133. package/skills/torusguard-audit/SKILL.md +107 -83
@@ -1,107 +1,121 @@
1
1
  ---
2
2
  name: torusguard-audit
3
- description: Static AST security scanning, line-shift invariant fingerprinting, root-cause clustering, and 0-100 confidence scoring via CLI or AI Agent.
3
+ description: Taint-aware static AST security scanning, cross-file interprocedural dataflow, 86+ rules across 22 families, line-shift invariant fingerprinting, and 7-signal calibrated confidence scoring via CLI or AI Agent.
4
4
  version: 2.0.0
5
5
  workflow: .torusguard/workflows/audit.md
6
6
  tools: Read, Grep, Glob, Write, run_command
7
7
  scripts-binding:
8
- - internal/scanner/scanner.go
9
- - cmd/torusguard/main.go
8
+ - .torusguard/scripts/audit_runner.py
9
+ - .torusguard/scripts/finding_scorer.py
10
+ - core/taint_graph.py
11
+ - core/cross_file_taint.py
12
+ - core/confidence.py
13
+ - core/parser.py
14
+ - core/incremental.py
10
15
  ---
11
16
 
12
- # TorusGuard Audit β€” Static Code Security Analysis
17
+ # TorusGuard Audit β€” Deep Taint-Aware Static Code Security Analysis
13
18
 
14
19
  ## Objective
15
- Execute static AST analysis across polyglot project files, evaluate code against 74 canonical security rules across 18 families, assign stable line-shift invariant fingerprints, cluster architectural root causes, synchronize findings with `security_report.md`, and score findings with auditable 0–100 confidence ratings.
20
+ Execute deep static analysis combining **Tree-sitter polyglot AST parsing**, **source-to-sink taint tracking**, and **interprocedural call-graph analysis** across Python, JavaScript/TypeScript, Go, Rust, Java, Ruby, PHP, and C#. Evaluates code against 86+ canonical rules across 22 architectural families, generates line-shift invariant fingerprints, clusters systemic root causes, and computes 7-signal evidence-chain confidence ratings.
16
21
 
17
22
  ---
18
23
 
19
- ## Tri-Mode Execution
24
+ ## Tri-Mode Execution Parity
20
25
 
21
- ### Mode A: Automated CLI Execution
26
+ ### Mode A: Automated Terminal CLI
22
27
  Run the static security audit from your terminal:
23
28
  ```bash
24
- # Scan current repository
29
+ # Full codebase audit with taint dataflow analysis
25
30
  torusguard audit
26
31
 
27
- # Scan specific directory or example app
32
+ # Incremental scan (sub-second diff on changed files only)
33
+ torusguard audit --incremental
34
+
35
+ # Continuous watch mode (re-scan debounced on file save)
36
+ torusguard audit --watch
37
+
38
+ # Audit specific directory or microservice
28
39
  torusguard audit ./examples/vulnerable-react-express
29
40
 
30
- # Include test fixtures and spec directories
31
- torusguard audit --include-tests
41
+ # Export findings to OASIS SARIF v2.1.0 format
42
+ torusguard audit --sarif --sarif-out ./report.sarif
32
43
 
33
- # Output machine-readable JSON
44
+ # Machine-readable JSON output
34
45
  torusguard audit --json
35
46
  ```
36
- **Under the Hood:** Executes compiled Go static analysis engine (`internal/scanner`).
37
- - Auto-detects repository stack and skips build/cache directories (`node_modules`, `.git`, `.venv`, `dist`, `build`).
38
- - Evaluates files across 18 canonical security families:
39
- - `TG-SEC-*`: Hardcoded credentials, private keys, JWT secrets, client env leaks.
40
- - `TG-INPUT-*`: SQL injection, command injection, path traversal, unsafe HTML rendering.
41
- - `TG-DB-*`: Missing tenant isolation, service role keys in client code.
42
- - `TG-AUTH-*`: Plaintext passwords, missing cookie security flags (httpOnly, secure, sameSite).
43
- - `TG-PLATFORM-*`: Permissive wildcard CORS with credentials, missing security headers.
44
- - `TG-DIFF-*`: Disabled TLS verification (`verify=False`, `InsecureSkipVerify: true`).
45
- - `TG-NPE-*`: Null-pointer exceptions, unchecked nil error dereferences.
46
- - `TG-CONC-*`: Concurrency hazards, goroutine loop variable capture.
47
- - Writes findings directly to `security_report.md` at workspace root.
48
- - Displays standardized 75-column terminal cards.
49
-
50
- ### Mode B: In-Session AI Chat Agent Scan
51
- When auditing files directly in AI chat:
52
- 1. **Discover Sinks:** Use `grep_search` and `view_file` to search for dangerous patterns across server and client code.
53
- 2. **Cluster Root Causes:** Group findings by causal architecture (e.g. `cluster-tenant-isolation`, `cluster-credentials-exposure`, `cluster-injection`).
54
- 3. **Audit Evidence Sufficiency:** Ensure that user-controlled input reaches the vulnerable sink without prior sanitization or schema validation.
55
- 4. **Context Minimization (1/9th Token Strategy):** Inspect only bounded AST context windows ($\pm 3$ lines) via `scanner.ExtractContext` rather than ingesting entire files.
56
- 5. **Present Actionable Findings:** Display finding cards with severity, rule ID, file, line, and remediation recommendation.
57
- 6. **Prompt Next Phase:** Guide the operator to `/torusguard harden` or `torusguard harden`.
58
-
59
- ### Mode C: Native MCP Tool Execution
60
- For autonomous AI coding agents (Antigravity, Cursor, Windsurf, Claude Code):
61
- - **Tool Invocation:** Call `torusguard_audit` with target arguments:
62
- ```json
63
- {
64
- "target": ".",
65
- "include_ocr": true,
66
- "max_image_mb": 10
67
- }
68
- ```
69
- - **Programmatic Return:** Receives formatted finding summaries, active rule counts, and confirmation that `security_report.md` is updated on disk.
70
- - **Resource Companion:** Inspect the living report via resource `torusguard://security_report` or rules catalog via `torusguard://rules_catalog`.
47
+
48
+ ### Mode B: In-Session AI Chat Slash Command (`/torusguard audit`)
49
+ When executing audits directly in AI chat:
50
+ 1. **Trace Dataflow (Sources β†’ Sinks):** Track user inputs (`request.GET`, `req.body`, `r.URL.Query()`) through assignments and helper functions to dangerous sinks (`execute()`, `innerHTML`, `open()`).
51
+ 2. **Verify Sanitizer Absence:** Confirm that input is not cleansed by `int()`, `escape()`, `shlex.quote()`, or `zod.safeParse()`.
52
+ 3. **Cross-File Correlation:** Trace calls across module boundaries up to 5 interprocedural hops using `CrossFileTaintAnalyzer`.
53
+ 4. **Cluster Root Causes:** Group findings into architectural failure patterns (e.g. `cluster-prompt-injection`, `cluster-tenant-isolation`, `cluster-supply-chain`).
54
+ 5. **Calibrate Confidence:** Score findings via the 7-signal evidence chain model.
55
+ 6. **Synchronize Ground Truth:** Record active findings in `security_report.md` at workspace root.
56
+
57
+ ### Mode C: Native MCP Tool Calling
58
+ MCP agents invoke `torusguard_audit(target_root, incremental, use_taint)` via JSON-RPC 2.0 stdio to receive structured findings with verified taint paths and confidence scores.
71
59
 
72
60
  ---
73
61
 
74
- ## Canonical Rule Families
75
- | Family | Scope | Example Violations |
62
+ ## Architectural Rule Taxonomy (86 Rules Across 22 Families)
63
+
64
+ | Family Code | Security Domain | Core Invariant Enforced |
76
65
  | :--- | :--- | :--- |
77
- | **TG-SEC** | Secrets & Credentials | Hardcoded JWT secret, API key strings, token logging |
78
- | **TG-INPUT** | Injection & Input Validation | Raw SQL interpolation, DOM `innerHTML`, `path.join` traversal |
79
- | **TG-DB** | Database & Tenant Scoping | Unscoped `.objects.get(id=...)`, Prisma missing `tenantId` |
80
- | **TG-AUTH** | Authentication & Cookies | Insecure cookies (missing httpOnly/secure/sameSite) |
81
- | **TG-PLATFORM** | Server & Platform Config | Wildcard CORS (`origin: '*'`) with credentials |
82
- | **TG-DIFF** | Security Bypasses | Disabled TLS verification (`verify=False`, `# nosec`) |
83
- | **TG-NPE** | Null Dereference / NPE | Unchecked optional chaining, unhandled nil error returns |
84
- | **TG-CONC** | Concurrency & Thread-Safety | Goroutine loop variable capture, unmutexed map mutations |
66
+ | **`TG-SEC`** | Secrets & Credentials | Zero hardcoded API keys, private certificates, or JWT secrets. |
67
+ | **`TG-AUTH`** | Authentication & Session | Enforce timing-safe compares, strong password hashing, algorithm verification. |
68
+ | **`TG-DB`** | Database & Tenancy | Parameterized SQL queries and tenant partition scoping across all lookups. |
69
+ | **`TG-INPUT`** | Input & Sanitization | Strict path sanitization, command argument escaping, safe template rendering. |
70
+ | **`TG-RATE`** | Rate Limiting | Rate-limiting middleware on auth endpoints and payload size bounds. |
71
+ | **`TG-AGENT`** | AI Agents & Prompts | Structural prompt isolation, inert XML delimiters, MCP tool schema validation. |
72
+ | **`TG-SSRF`** | Outbound Net & SSRF | Hostname whitelisting, private IP blocklist (127.0.0.1, 169.254.169.254). |
73
+ | **`TG-WEBHOOK`**| Webhook Verification | Cryptographic HMAC-SHA256 signature verification and replay prevention. |
74
+ | **`TG-WS`** | WebSockets | Origin verification, handshake authentication, inbound frame size limits. |
75
+ | **`TG-CSRF`** | CSRF Protection | SameSite cookie attributes and anti-CSRF token verification on state mutations. |
76
+ | **`TG-GQL`** | GraphQL Safety | Query depth limiting (max depth 6) and production schema introspection suppression. |
77
+ | **`TG-SUPPLY`** | Supply Chain & CI/CD | Immutable commit SHA pinning in GitHub Actions, lockfile integrity audits. |
78
+ | **`TG-BIZ`** | Business Logic | Non-negative quantity asserts, transaction locks, server-side discount bounds. |
79
+ | **`TG-CACHE`** | Cache Poisoning | Cache-Control headers on sensitive responses, unkeyed header sanitization. |
80
+ | **`TG-CLIENT`** | Client Bundle Secrets | Zero private environment variables (`process.env.SUPABASE_SERVICE_ROLE`) in client. |
81
+ | **`TG-PLATFORM`**| Platform Hardening | Helmet security headers, debug mode suppression, cookie secure flags. |
82
+ | **`TG-DIFF`** | Security Bypasses | Block `# nosec`, `InsecureSkipVerify`, and enforce Ponytail line budgets. |
83
+ | **`TG-EDGE`** | Edge & Serverless | Subrequest fan-out limits and serverless execution timeouts. |
84
+ | **`TG-CONT`** | Container Safety | Enforce non-root execution, zero docker socket mounts, no privileged mode. |
85
+ | **`TG-GIT`** | Git History Secrets | Zero historical committed credentials, no tokens in remote URLs. |
86
+ | **`TG-REDOS`** | ReDoS Prevention | Zero nested quantifiers `(a+)+` or catastrophic backtracking regular expressions. |
87
+ | **`TG-RAG`** | RAG & Vector DB | Mandatory tenant scoping on vector similarity search and inert ingestion. |
85
88
 
86
89
  ---
87
90
 
88
- ## Output Card Format
89
- ```markdown
90
- ### πŸ›‘οΈ TorusGuard Static Security Audit Completed
91
- - **Run ID:** `run-20260910-121618-audit`
92
- - **Scope:** 7 files evaluated across 18 canonical families
93
- - **Status:** βœ– CRITICAL FINDINGS DETECTED
94
- - **Findings:** 2 Critical, 2 High, 2 Medium/Low (6 total)
95
- - **Clusters:** 3 architectural root causes identified
96
- - **Artifacts:** `security_report.md`
97
- - **Next Action:** Run `torusguard harden` or `/torusguard harden`
91
+ ## Evidence-Chain Confidence Scoring (0–100)
92
+
93
+ Findings are evaluated against 7 empirical signals:
94
+
95
+ ```
96
+ Final Score = Ξ£ weighted signals:
97
+ - rule_severity_base (0.20): Critical=90, High=75, Medium=50, Low=25
98
+ - taint_path_confirmed (0.25): 100 if source→sink reachability is confirmed, 0 otherwise
99
+ - taint_depth (0.10): direct=100, 1-hop=80, 2-hop=60, 3+=40
100
+ - sanitizer_absence (0.15): 100 if no known sanitizer present, 0 if sanitized
101
+ - framework_context_match (0.10): 100 if sink matches detected stack, 50 default
102
+ - evidence_snippet_quality (0.10): 100 for multi-line AST context, 50 for single line
103
+ - test_fixture_penalty (-0.10): -50 penalty if located in test suite or fixtures
104
+ - memory_boost: -30 (false positive class) to +15 (regression watch)
105
+
106
+ Classification Bands:
107
+ - 90–100: Confirmed (High priority for automated Ponytail hardening)
108
+ - 70–89: High Confidence (Requires review & remediation)
109
+ - 50–69: Medium Confidence (Context verification needed)
110
+ - 0–49: Needs Review (Suppressed or test fixture)
98
111
  ```
99
112
 
100
113
  ---
101
114
 
102
- ## πŸ›οΈ OpenCodeReview Precision & Context Minimization
103
- - **1/9th Token Minimization:** Use `scanner.ExtractContext` to extract only the bounded $\pm 3$ lines context window instead of ingesting entire files.
104
- - **Line-Level Pinning:** Every finding is reported with exact 1-indexed line numbers, line content, severity, and suggested remediation.
115
+ ## πŸ›οΈ Context Minimization & Performance Invariants
116
+ - **1/9th Token Strategy:** Never ingest entire files into agent context. Always inspect bounded AST context windows ($\pm 3$ lines) via `scanner.ExtractContext`.
117
+ - **Incremental Cache:** Uses cryptographic content hashes in `.torusguard/cache/ast_cache.json` to complete repeat audits in under 1 second.
118
+ - **Fail-Closed Safety:** Incomplete parses or syntax anomalies in non-standard files gracefully degrade to fallback token parsing without aborting the audit.
105
119
 
106
120
  ---
107
121
 
@@ -109,28 +123,38 @@ For autonomous AI coding agents (Antigravity, Cursor, Windsurf, Claude Code):
109
123
 
110
124
  | Pattern | What AI Does Wrong | What Is Actually Correct |
111
125
  | :--- | :--- | :--- |
112
- | **Unbounded File Reading** | Reads entire 800+ line files to diagnose a 1-line vulnerability. | Read only the bounded context ($\pm 3$ lines) around the finding's line number. |
113
- | **Ignoring NPE / Concurrency** | Focuses only on secrets and misses thread-safety and null-pointer hazards. | Enforce `TG-NPE-001` and `TG-CONC-001` checks during audit review. |
114
- | **False Positive Escalation** | Flags documentation strings or mock test fixtures as production vulnerabilities. | Skip test files (`*_test.go`, `.test.ts`) and verify sink exploitability before reporting. |
115
- | **Missing Sync to Ground Truth** | Produces analysis in chat without checking or updating `security_report.md`. | Always reconcile against `security_report.md` at workspace root. |
126
+ | **Grepping Without Taint** | Flags `db.execute(query)` even when `query` is hardcoded or parameterized. | Verify user input reaches the sink via `core.taint_graph` before reporting. |
127
+ | **Ignoring Sanitizers** | Reports injection even though `int(user_id)` or `shlex.quote()` cleans the input. | Check if any node in the dataflow path acts as a registered sanitizer. |
128
+ | **Single-File Blindness** | Misses vulnerabilities when input enters `utils.py` and reaches a sink in `views.py`. | Trace interprocedural call chains using `CrossFileTaintAnalyzer` (up to 5 hops). |
129
+ | **Unbounded File Dumps** | Reads entire 1,000-line source files into chat context. | Read only the bounded context ($\pm 3$ lines) around the finding's line number. |
130
+ | **Missing Ground Truth Sync** | Produces analysis in chat without synchronizing `security_report.md`. | Always update `security_report.md` with active findings and run IDs. |
116
131
 
117
132
  ---
118
133
 
119
134
  ## βœ… Pre-Flight Self-Audit
120
135
 
121
- Before completing an audit pass, verify:
122
- - [ ] Did I run `torusguard audit` or inspect `security_report.md` first?
123
- - [ ] Are all reported findings pinned to precise line numbers?
124
- - [ ] Did I verify user input reaches the sink without prior validation?
125
- - [ ] Did I extract only the minimal AST context window ($\pm 3$ lines) to conserve tokens?
126
- - [ ] Did I evaluate against all 18 families including NPE and concurrency rules?
136
+ Before finishing an audit pass, confirm:
137
+ - [ ] Did I run `torusguard audit` or inspect `security_report.md`?
138
+ - [ ] Are all reported findings backed by confirmed taint paths or verified regex patterns?
139
+ - [ ] Did I verify user input reaches the sink without prior sanitization?
140
+ - [ ] Are findings pinned to exact 1-indexed line numbers with stable region hashes?
141
+ - [ ] Did I synchronize discovering state into `security_report.md`?
127
142
 
128
143
  ---
129
144
 
130
145
  ## πŸ” VBC Protocol (Verify β†’ Build β†’ Confirm)
131
146
 
132
147
  ```
133
- VERIFY: Scan source code and image assets using torusguard audit or torusguard_audit MCP tool.
134
- BUILD: Synthesize findings clustered by root cause with exact line numbers and bounded AST snippets.
135
- CONFIRM: Synchronize living findings into security_report.md and guide operator to /torusguard harden.
148
+ VERIFY: Scan source code with polyglot AST parser and trace dataflow reachability from sources to sinks.
149
+ BUILD: Group findings by root cause, compute 7-signal calibrated confidence scores, and format 75-column terminal cards.
150
+ CONFIRM: Synchronize all findings to security_report.md at workspace root and guide operator to /torusguard harden.
136
151
  ```
152
+
153
+ ---
154
+
155
+ ## πŸ”„ Rollback Defaults
156
+
157
+ If audit data becomes corrupted or a run needs to be reverted:
158
+ 1. Historical runs are preserved immutably in `.torusguard/runs/<run_id>/`.
159
+ 2. AST cache can be cleared anytime by deleting `.torusguard/cache/ast_cache.json`.
160
+ 3. Pre-apply code snapshots remain intact in `.torusguard/snapshots/`.