torusguard 2.0.0-alpha → 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 (227) hide show
  1. package/.torusguard/.manifest.json +94 -30
  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/rules/container/TG-CONT-001-root-user-execution.md +50 -0
  44. package/.torusguard/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
  45. package/.torusguard/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
  46. package/.torusguard/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
  47. package/.torusguard/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
  48. package/.torusguard/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
  49. package/.torusguard/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
  50. package/.torusguard/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
  51. package/.torusguard/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
  52. package/.torusguard/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
  53. package/.torusguard/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
  54. package/.torusguard/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
  55. package/.torusguard/rules_catalog.json +96 -0
  56. package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
  57. package/.torusguard/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
  58. package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
  59. package/.torusguard/scripts/__pycache__/rules_sync.cpython-314.pyc +0 -0
  60. package/.torusguard/scripts/audit_runner.py +108 -10
  61. package/.torusguard/scripts/finding_scorer.py +43 -13
  62. package/.torusguard/scripts/manifest_builder.py +1 -1
  63. package/.torusguard/scripts/skill_profiler.py +26 -0
  64. package/.torusguard/skills/torusguard/SKILL.md +74 -25
  65. package/.torusguard/skills/torusguard/bootstrap.py +57 -24
  66. package/.torusguard/skills/torusguard-ai-guard/SKILL.md +95 -0
  67. package/.torusguard/skills/torusguard-apply/SKILL.md +60 -34
  68. package/.torusguard/skills/torusguard-audit/SKILL.md +131 -57
  69. package/.torusguard/skills/torusguard-authorize/SKILL.md +48 -6
  70. package/.torusguard/skills/torusguard-container/SKILL.md +94 -0
  71. package/.torusguard/skills/torusguard-exploit-check/SKILL.md +50 -6
  72. package/.torusguard/skills/torusguard-full/SKILL.md +62 -19
  73. package/.torusguard/skills/torusguard-git-mine/SKILL.md +92 -0
  74. package/.torusguard/skills/torusguard-harden/SKILL.md +81 -50
  75. package/.torusguard/skills/torusguard-init/SKILL.md +61 -14
  76. package/.torusguard/skills/torusguard-ocr-scan/SKILL.md +94 -0
  77. package/.torusguard/skills/torusguard-recheck/SKILL.md +71 -18
  78. package/.torusguard/skills/torusguard-redos/SKILL.md +91 -0
  79. package/.torusguard/skills/torusguard-report/SKILL.md +50 -9
  80. package/.torusguard/skills/torusguard-status/SKILL.md +63 -10
  81. package/.torusguard/skills/torusguard-verify/SKILL.md +52 -10
  82. package/.torusguard/skills/torusguard-web-validate/SKILL.md +53 -8
  83. package/.torusguard/workflows/ai-guard.md +31 -0
  84. package/.torusguard/workflows/apply.md +32 -55
  85. package/.torusguard/workflows/audit.md +35 -49
  86. package/.torusguard/workflows/authorize.md +27 -50
  87. package/.torusguard/workflows/container.md +29 -0
  88. package/.torusguard/workflows/exploit-check.md +28 -50
  89. package/.torusguard/workflows/git-mine.md +25 -0
  90. package/.torusguard/workflows/harden.md +29 -48
  91. package/.torusguard/workflows/init.md +27 -50
  92. package/.torusguard/workflows/memory.md +18 -23
  93. package/.torusguard/workflows/ocr-scan.md +25 -0
  94. package/.torusguard/workflows/recheck.md +28 -46
  95. package/.torusguard/workflows/redos.md +27 -0
  96. package/.torusguard/workflows/report.md +33 -52
  97. package/.torusguard/workflows/status.md +31 -52
  98. package/.torusguard/workflows/verify.md +29 -49
  99. package/.torusguard/workflows/web-validate.md +22 -45
  100. package/README.md +96 -60
  101. package/package.json +7 -2
  102. package/skills/torusguard/SKILL.md +75 -24
  103. package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
  104. package/skills/torusguard/bootstrap.py +60 -71
  105. package/skills/torusguard/payload/.manifest.json +94 -31
  106. package/skills/torusguard/payload/core/__init__.py +146 -0
  107. package/skills/torusguard/payload/core/agent_roles.py +104 -0
  108. package/skills/torusguard/payload/core/ast_walker.py +283 -0
  109. package/skills/torusguard/payload/core/authorization.py +218 -0
  110. package/skills/torusguard/payload/core/browser_verifier.py +128 -0
  111. package/skills/torusguard/payload/core/bundle.py +141 -0
  112. package/skills/torusguard/payload/core/call_graph.py +184 -0
  113. package/skills/torusguard/payload/core/clustering.py +275 -0
  114. package/skills/torusguard/payload/core/confidence.py +120 -0
  115. package/skills/torusguard/payload/core/cross_file_taint.py +101 -0
  116. package/skills/torusguard/payload/core/exploit_checker.py +317 -0
  117. package/skills/torusguard/payload/core/formatter.py +351 -0
  118. package/skills/torusguard/payload/core/governance.py +210 -0
  119. package/skills/torusguard/payload/core/identity.py +104 -0
  120. package/skills/torusguard/payload/core/import_resolver.py +91 -0
  121. package/skills/torusguard/payload/core/incremental.py +102 -0
  122. package/skills/torusguard/payload/core/lifecycle.py +137 -0
  123. package/skills/torusguard/payload/core/models.py +425 -0
  124. package/skills/torusguard/payload/core/parallel.py +56 -0
  125. package/skills/torusguard/payload/core/parser.py +202 -0
  126. package/skills/torusguard/payload/core/rechecker.py +107 -0
  127. package/skills/torusguard/payload/core/replay_trace.py +178 -0
  128. package/skills/torusguard/payload/core/rules_registry.py +131 -0
  129. package/skills/torusguard/payload/core/run_folder.py +60 -0
  130. package/skills/torusguard/payload/core/run_manager.py +163 -0
  131. package/skills/torusguard/payload/core/runtime_evidence.py +175 -0
  132. package/skills/torusguard/payload/core/runtime_validator.py +246 -0
  133. package/skills/torusguard/payload/core/safety_gate.py +139 -0
  134. package/skills/torusguard/payload/core/sarif.py +189 -0
  135. package/skills/torusguard/payload/core/stack_profiler.py +184 -0
  136. package/skills/torusguard/payload/core/symbol_table.py +91 -0
  137. package/skills/torusguard/payload/core/taint.py +133 -0
  138. package/skills/torusguard/payload/core/taint_graph.py +235 -0
  139. package/skills/torusguard/payload/core/taint_rules.py +268 -0
  140. package/skills/torusguard/payload/core/v070_reporter.py +102 -0
  141. package/skills/torusguard/payload/core/v070_workflow.py +339 -0
  142. package/skills/torusguard/payload/core/v6_reporter.py +180 -0
  143. package/skills/torusguard/payload/core/v6_workflow.py +221 -0
  144. package/skills/torusguard/payload/core/watcher.py +58 -0
  145. package/skills/torusguard/payload/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
  146. package/skills/torusguard/payload/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
  147. package/skills/torusguard/payload/rules/container/TG-CONT-001-root-user-execution.md +50 -0
  148. package/skills/torusguard/payload/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
  149. package/skills/torusguard/payload/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
  150. package/skills/torusguard/payload/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
  151. package/skills/torusguard/payload/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
  152. package/skills/torusguard/payload/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
  153. package/skills/torusguard/payload/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
  154. package/skills/torusguard/payload/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
  155. package/skills/torusguard/payload/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
  156. package/skills/torusguard/payload/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
  157. package/skills/torusguard/payload/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
  158. package/skills/torusguard/payload/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
  159. package/skills/torusguard/payload/rules_catalog.json +338 -518
  160. package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
  161. package/skills/torusguard/payload/scripts/audit_runner.py +108 -10
  162. package/skills/torusguard/payload/scripts/finding_scorer.py +43 -13
  163. package/skills/torusguard/payload/scripts/manifest_builder.py +1 -1
  164. package/skills/torusguard/payload/skills/torusguard/SKILL.md +74 -25
  165. package/skills/torusguard/payload/skills/torusguard/bootstrap.py +57 -24
  166. package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -41
  167. package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -41
  168. package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -40
  169. package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -25
  170. package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -40
  171. package/skills/torusguard/payload/skills/torusguard-ai-guard/SKILL.md +95 -0
  172. package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +60 -34
  173. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +131 -57
  174. package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +48 -6
  175. package/skills/torusguard/payload/skills/torusguard-container/SKILL.md +94 -0
  176. package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +50 -6
  177. package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +62 -19
  178. package/skills/torusguard/payload/skills/torusguard-git-mine/SKILL.md +92 -0
  179. package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +81 -50
  180. package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +61 -14
  181. package/skills/torusguard/payload/skills/torusguard-ocr-scan/SKILL.md +94 -0
  182. package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +71 -18
  183. package/skills/torusguard/payload/skills/torusguard-redos/SKILL.md +91 -0
  184. package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +50 -9
  185. package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +63 -10
  186. package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +52 -10
  187. package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +53 -8
  188. package/skills/torusguard/payload/workflows/ai-guard.md +31 -0
  189. package/skills/torusguard/payload/workflows/apply.md +31 -62
  190. package/skills/torusguard/payload/workflows/audit.md +35 -55
  191. package/skills/torusguard/payload/workflows/authorize.md +27 -50
  192. package/skills/torusguard/payload/workflows/container.md +29 -0
  193. package/skills/torusguard/payload/workflows/exploit-check.md +28 -50
  194. package/skills/torusguard/payload/workflows/git-mine.md +25 -0
  195. package/skills/torusguard/payload/workflows/harden.md +28 -52
  196. package/skills/torusguard/payload/workflows/init.md +27 -56
  197. package/skills/torusguard/payload/workflows/memory.md +18 -23
  198. package/skills/torusguard/payload/workflows/ocr-scan.md +25 -0
  199. package/skills/torusguard/payload/workflows/recheck.md +28 -46
  200. package/skills/torusguard/payload/workflows/redos.md +27 -0
  201. package/skills/torusguard/payload/workflows/report.md +39 -62
  202. package/skills/torusguard/payload/workflows/status.md +31 -55
  203. package/skills/torusguard/payload/workflows/torusguard-audit.md +35 -55
  204. package/skills/torusguard/payload/workflows/verify.md +29 -49
  205. package/skills/torusguard/payload/workflows/web-validate.md +22 -45
  206. package/skills/torusguard/references/csharp-security.md +41 -0
  207. package/skills/torusguard/references/go-security.md +41 -0
  208. package/skills/torusguard/references/java-security.md +40 -0
  209. package/skills/torusguard/references/polyglot-security-matrix.md +25 -0
  210. package/skills/torusguard/references/rust-security.md +40 -0
  211. package/skills/torusguard-ai-guard/SKILL.md +95 -0
  212. package/skills/torusguard-apply/SKILL.md +60 -34
  213. package/skills/torusguard-audit/SKILL.md +130 -57
  214. package/skills/torusguard-authorize/SKILL.md +48 -6
  215. package/skills/torusguard-container/SKILL.md +94 -0
  216. package/skills/torusguard-exploit-check/SKILL.md +50 -6
  217. package/skills/torusguard-full/SKILL.md +62 -19
  218. package/skills/torusguard-git-mine/SKILL.md +92 -0
  219. package/skills/torusguard-harden/SKILL.md +81 -50
  220. package/skills/torusguard-init/SKILL.md +61 -14
  221. package/skills/torusguard-ocr-scan/SKILL.md +94 -0
  222. package/skills/torusguard-recheck/SKILL.md +71 -18
  223. package/skills/torusguard-redos/SKILL.md +91 -0
  224. package/skills/torusguard-report/SKILL.md +50 -9
  225. package/skills/torusguard-status/SKILL.md +63 -10
  226. package/skills/torusguard-verify/SKILL.md +52 -10
  227. package/skills/torusguard-web-validate/SKILL.md +53 -8
@@ -1,16 +1,16 @@
1
1
  ---
2
2
  description: Governed remediation formulation under strict Ponytail Protocol bounds (<= 35 additions, <= 25 deletions) and bundle packaging.
3
- tools: Read, Grep, Glob, Bash, Write
4
- version: 1.4.0
3
+ tools: Read, Grep, Glob, Bash, Write, run_command
4
+ version: 2.0.0
5
5
  agent: remediator
6
6
  lifecycle-phase: Phase 4 (Remediation Formulation)
7
7
  required-skills:
8
8
  - torusguard-harden
9
9
  scripts-binding:
10
- - .torusguard/scripts/harden_runner.py
11
- - .torusguard/scripts/report_sync.py
12
- - .torusguard/scripts/run_manager.py
13
- - .torusguard/scripts/diff_guard.py
10
+ - internal/harden/patch.go
11
+ - internal/harden/reflection.go
12
+ - cmd/torusguard/main.go
13
+ - cmd/torusguard/mcp.go
14
14
  ---
15
15
 
16
16
  # /torusguard harden — Governed Remediation & Bundle Packaging
@@ -20,36 +20,29 @@ $ARGUMENTS
20
20
  ---
21
21
 
22
22
  ## Objective
23
- Governed remediation formulation under strict Ponytail Protocol bounds (<=35 add, <=25 del).
23
+ Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$ additions, $\le 25$ deletions), packaging unified diffs or semantic reflection patches into auditable remediation bundles ready for review.
24
24
 
25
- Supported CLI flags:
26
- - `npx torusguard harden [--target <dir>]` : Specify project root directory
27
- - `npx torusguard harden --dry-run` : Preview candidate patches without modifying disk files
28
- - `npx torusguard harden --severity <critical|high|medium|low>` : Filter findings by minimum severity floor
25
+ ---
26
+
27
+ ## Tri-Mode Execution
28
+
29
+ | Mode | Command / Tool | Execution Method |
30
+ | :--- | :--- | :--- |
31
+ | **Mode A: Terminal CLI** | `torusguard harden <candidate.patch \| patch.json>` | Shell validation of patch against Ponytail bounds. |
32
+ | **Mode B: AI Chat Slash** | `/torusguard harden` | Formulate semantic patch with Line-Level Reflection. |
33
+ | **Mode C: Native MCP Tool** | `torusguard_harden` | Automated validation of patch file or `find_snippet` / `replace_snippet`. |
29
34
 
30
35
  ---
31
36
 
32
37
  ## Mandatory Pre-Flight Context Inspection
33
38
 
34
39
  Inspect finding targets and patch constraints before generating diffs:
35
- 1. **Target Finding (`findings.md`):** Identify prioritized verified findings.
40
+ 1. **Target Finding (`security_report.md`):** Identify prioritized verified findings.
36
41
  2. **Ponytail Protocol:** Enforce hard limit ($\le 35$ additions, $\le 25$ deletions). Ban rewrites.
37
- 3. **Sensitive Path Review:** Flag changes touching `auth/` or `settings.py` for human sign-off.
42
+ 3. **Sensitive Path Review:** Flag changes touching `auth/` or credentials for explicit sign-off.
38
43
  4. **Behavior Preservation:** Ensure patch addresses flaw without breaking public APIs.
39
44
  5. **Dry-Run Rule:** Do NOT apply changes to disk during harden; emit bundle for review.
40
- 6. **Backup Readiness:** Ensure rollback procedures are prepared before staging patch.
41
-
42
- ---
43
-
44
- ## When to Use /torusguard harden
45
-
46
- | Trigger Scenario | Recommended Action |
47
- | :--- | :--- |
48
- | Formulating minimal patches for verified findings | Run `/torusguard harden` |
49
- | Packaging a 4-artifact remediation bundle for review | Run `/torusguard harden` |
50
- | Writing and applying changes to code files | Run `/torusguard apply` |
51
- | Differentially re-scanning code after patch application | Run `/torusguard recheck` |
52
- | Discovering new vulnerabilities | Run `/torusguard audit` |
45
+ 6. **Zero Bypasses:** Reject `# nosec`, `verify=False`, or `InsecureSkipVerify` under rule `TG-DIFF-001`.
53
46
 
54
47
  ---
55
48
 
@@ -57,30 +50,15 @@ Inspect finding targets and patch constraints before generating diffs:
57
50
  - Candidate patches transition findings in `security_report.md` into `CANDIDATE 🟡` status.
58
51
  - Every patch strictly conforms to Ponytail bounds (<= 35 additions, <= 25 deletions).
59
52
 
60
- ## Execution Steps
61
-
62
- 1. **Select Target Finding:** Choose verified flaw from active run directory.
63
- 2. **Examine Live Code Context:** Read surrounding lines (±15) of vulnerable sink.
64
- 3. **Draft Unified Diff:** Formulate minimal fix adhering to Ponytail Protocol limits.
65
- 4. **Audit Patch Safety:** Run `python .torusguard/scripts/diff_guard.py <patch.diff>`.
66
- 5. **Package 4-Artifact Bundle:** Write `patch.diff`, `plan.md`, `verification.md`, `rollback.md` to `.torusguard/runs/<run_id>/remediation/<finding_id>/`.
67
-
68
53
  ---
69
54
 
70
- ## Failure Recovery
71
-
72
- - **Line Churn Exceeded (>35 add or >25 del):** Decompose patch into smaller sequential sub-fixes.
73
- - **Sensitive Path Conflict:** Mark bundle with `Requires Sensitive-Path Sign-Off` in `plan.md`.
74
- - **Finding Not Found:** Ensure finding ID exists in active `findings.md`.
75
- - **Halt Trigger:** Abort if target source file cannot be read from disk.
76
-
77
- ---
78
-
79
- ## Hallucination Guard
55
+ ## Execution Steps
80
56
 
81
- - ❌ Never generate full-file replacements or unconstrained cosmetic code refactoring.
82
- - ❌ Never modify imports, variables, or functions unrelated to the vulnerability.
83
- - ✅ Always calculate addition and deletion line counts before emitting `patch.diff`.
57
+ 1. **Select Target Finding:** Choose verified flaw from `security_report.md`.
58
+ 2. **Examine Live Code Context:** Read surrounding lines ($\pm 3$) using bounded context extraction.
59
+ 3. **Formulate Minimal Semantic Patch:** Formulate `find_snippet` and `replace_snippet`.
60
+ 4. **Audit Patch Safety:** Run `torusguard harden` or call `torusguard_harden`.
61
+ 5. **Package Bundle:** Prepare candidate patch ready for the Human Gate.
84
62
 
85
63
  ---
86
64
 
@@ -89,10 +67,8 @@ Inspect finding targets and patch constraints before generating diffs:
89
67
  ```markdown
90
68
  ### 🛠️ TorusGuard Remediation Bundle
91
69
  - **Finding Target:** `TG-XXX-HASH` ([Vulnerability Name])
92
- - **File Affected:** `src/path/to/file.py`
70
+ - **File Affected:** `src/path/to/file`
93
71
  - **Line Churn:** +[Additions] / -[Deletions] (Ponytail: PASS)
94
- - **Sensitive Path:** [Yes (Sign-Off Needed) / No (Standard)]
95
- - **Bundle Path:** `.torusguard/runs/<run_id>/remediation/<finding_id>/`
96
72
  - **Status:** READY FOR REVIEW — run `/torusguard apply` to execute
97
73
  ```
98
74
 
@@ -100,5 +76,5 @@ Inspect finding targets and patch constraints before generating diffs:
100
76
 
101
77
  ## Next Steps
102
78
 
103
- 1. Review proposed diff in `.torusguard/runs/<run_id>/remediation/<finding_id>/patch.diff`.
104
- 2. Run `/torusguard apply` to execute the governed patch with automatic rollback backup.
79
+ 1. Review proposed diff or semantic reflection snippet.
80
+ 2. Run `/torusguard apply` or `torusguard apply` with Human Gate approval.
@@ -1,14 +1,15 @@
1
1
  ---
2
2
  description: Baseline project discovery, workspace scaffolding, stack detection, and framework-tailored security rule activation.
3
- tools: Read, Grep, Glob, Bash, Write
4
- version: 1.4.0
3
+ tools: Read, Grep, Glob, Bash, Write, run_command
4
+ version: 2.0.0
5
5
  agent: profiler
6
6
  lifecycle-phase: Phase 0 (Baseline Setup)
7
7
  required-skills:
8
8
  - torusguard-init
9
9
  scripts-binding:
10
- - .torusguard/scripts/report_sync.py
11
- - .torusguard/scripts/stack_detect.py
10
+ - internal/workspace/workspace.go
11
+ - cmd/torusguard/main.go
12
+ - cmd/torusguard/mcp.go
12
13
  ---
13
14
 
14
15
  # /torusguard init — Project Baseline & Workspace Initialization
@@ -18,71 +19,42 @@ $ARGUMENTS
18
19
  ---
19
20
 
20
21
  ## Objective
21
- Baseline project discovery, workspace scaffolding, stack detection, and security rule activation.
22
-
23
- Supported CLI flags:
24
- - `npx torusguard init [--target <dir>]` : Scaffold workspace into specified root directory
25
- - `npx torusguard init --template <golang|nextjs|fastapi|express|django|react>` : Guide stack configuration explicitly
26
- - `npx torusguard init --audit` : Run immediate baseline audit post-initialization
27
- - `npx torusguard init --force` : Force overwrite existing workspace and re-scaffold baseline
22
+ Baseline project discovery, workspace scaffolding across polyglot stacks, and activation of 74 canonical security rules across 18 families.
28
23
 
29
24
  ---
30
25
 
31
- ## Mandatory Pre-Flight Context Inspection
26
+ ## Tri-Mode Execution
32
27
 
33
- Inspect workspace state before running initialization:
34
- 1. **Config State (`.torusguard/config/torusguard.json`):** Check if workspace is already initialized. If active, prompt before re-writing.
35
- 2. **Project Manifests:** Check root for `package.json`, `manage.py`, `requirements.txt`, `pyproject.toml`, `go.mod`, or `Cargo.toml`.
36
- 3. **Disclosure Policy (`SECURITY.md`):** Check for existing responsible disclosure policy.
37
- 4. **Bootstrapper:** If `.torusguard/` is absent, invoke `python skills/torusguard/bootstrap.py` to unpack offline assets.
38
- 5. **Runtime Preconditions:** Ensure Python 3.10+ is available in the current execution shell.
28
+ | Mode | Command / Tool | Execution Method |
29
+ | :--- | :--- | :--- |
30
+ | **Mode A: Terminal CLI** | `torusguard init [--force] [--stack <name>]` | Terminal execution of workspace scaffolder. |
31
+ | **Mode B: AI Chat Slash** | `/torusguard init` | Conversational stack profiling and rule activation. |
32
+ | **Mode C: Native MCP Tool** | Administrative Command | Agents execute `torusguard init` via shell and monitor via `torusguard_status`. |
39
33
 
40
34
  ---
41
35
 
42
- ## When to Use /torusguard init
36
+ ## Mandatory Pre-Flight Context Inspection
43
37
 
44
- | Trigger Scenario | Recommended Command |
45
- | :--- | :--- |
46
- | First-time onboarding in any repository | Run `/torusguard init` |
47
- | Framework upgrade or major dependency changes | Run `/torusguard init` to refresh tailored rules |
48
- | Repository already configured | Run `/torusguard audit` |
49
- | Inspecting existing configuration | Run `/torusguard status` |
50
- | Testing legal boundaries | Run `/torusguard authorize` |
38
+ Inspect workspace state before running initialization:
39
+ 1. **Config State (`.torusguard/config/torusguard.json`):** Check if workspace is already initialized.
40
+ 2. **Project Manifests:** Check root for `package.json`, `go.mod`, `Cargo.toml`, `requirements.txt`, `pyproject.toml`.
41
+ 3. **Disclosure Policy (`SECURITY.md`):** Check for existing responsible disclosure policy.
51
42
 
52
43
  ---
53
44
 
54
45
  ## Living Report Invariant
55
- - Provisions baseline `security_report.md` single-source-of-truth ledger.
46
+ - Provisions baseline `SECURITY.md` responsible disclosure policy.
56
47
  - Activates tailored rules across 18 families based on detected stack.
57
48
 
58
- ## Execution Steps
59
-
60
- 1. **Scaffold Directory Topology:** Verify `.torusguard/` structure (`config/`, `rules/active/`, `runs/`, `scripts/`, `workflows/`, `templates/`, `schemas/`).
61
- 2. **Execute Stack Detection:**
62
- ```bash
63
- python .torusguard/scripts/stack_detect.py .
64
- ```
65
- 3. **Activate Tailored Rules:** Symlink or copy matching security rules from `.torusguard/rules/` into `.torusguard/rules/active/`.
66
- 4. **Write Configuration (`.torusguard/config/torusguard.json`):**
67
- Record detected stack, enabled rules count, timestamp, and runtime constraints.
68
- 5. **Verify Initialization:** Assert `.torusguard/config/torusguard.json` and `.torusguard/config/scope.json` exist.
69
-
70
49
  ---
71
50
 
72
- ## Failure Recovery
73
-
74
- - **Script Exit 1 (Detection Failed):** Check Python version (`python --version` >= 3.10) and verify read access to root manifests.
75
- - **Permission Error:** Verify write permissions for `.torusguard/config/` and `.torusguard/rules/active/`.
76
- - **Missing Directories:** Re-run directory scaffolding if any subfolder creation fails.
77
- - **Halt Condition:** If root directory is empty, halt and prompt user to open the project root.
78
-
79
- ---
80
-
81
- ## Hallucination Guard
51
+ ## Execution Steps
82
52
 
83
- - ❌ Never invent framework dependencies not present in `package.json` or `requirements.txt`.
84
- - ❌ Never overwrite an existing `.torusguard/config/scope.json` containing authorized domains.
85
- - ✅ Always execute `.torusguard/scripts/stack_detect.py` to ground detected technologies.
53
+ 1. **Scaffold Directory Topology:** Create `.torusguard/` structure (`config/`, `rules/active/`, `runs/`, `snapshots/`, `memory/`).
54
+ 2. **Detect Stack:** Automatically identify frameworks across 16+ polyglot languages.
55
+ 3. **Persist Configuration:** Write `.torusguard/config/torusguard.json`.
56
+ 4. **Provision Policy:** Generate baseline `SECURITY.md` at workspace root.
57
+ 5. **Recommend Audit:** Direct user to `/torusguard audit` or `torusguard audit`.
86
58
 
87
59
  ---
88
60
 
@@ -90,11 +62,10 @@ Inspect workspace state before running initialization:
90
62
 
91
63
  ```markdown
92
64
  ### 🛡️ TorusGuard Workspace Initialization
93
- - **Primary Framework:** [Detected Stack or None]
94
- - **Components:** [Backend / Frontend / Database]
95
- - **Active Rules:** [Count] rules enabled in `.torusguard/rules/active/`
65
+ - **Primary Framework:** [Detected Stack]
66
+ - **Active Rules:** 74 rules enabled across 18 families
96
67
  - **Config:** `.torusguard/config/torusguard.json` generated
97
- - **Scope Template:** `.torusguard/config/scope.json` ready
68
+ - **Policy:** `SECURITY.md` provisioned
98
69
  - **Status:** READY — run `/torusguard audit` to scan codebase
99
70
  ```
100
71
 
@@ -1,14 +1,15 @@
1
1
  ---
2
2
  description: TorusGuard Adaptive Security Memory Engine — view memory stats, export/import intelligence, apply TTL decay, and manage false positives.
3
- tools: Read, Grep, Glob, Bash
4
- version: 1.3.6
3
+ tools: Read, Grep, Glob, Bash, Write, run_command
4
+ version: 2.0.0
5
5
  agent: reviewer
6
6
  lifecycle-phase: Intelligence / Memory
7
7
  required-skills:
8
8
  - torusguard
9
9
  scripts-binding:
10
- - .torusguard/scripts/report_sync.py
11
- - .torusguard/scripts/memory_engine.py
10
+ - internal/memory/recipes.go
11
+ - cmd/torusguard/main.go
12
+ - cmd/torusguard/mcp.go
12
13
  ---
13
14
 
14
15
  # /torusguard memory — Adaptive Security Memory Engine & Intelligence Management
@@ -18,37 +19,31 @@ $ARGUMENTS
18
19
  ---
19
20
 
20
21
  ## Objective
21
- Inspect, manage, export, import, or compact persistent local security memory patterns, context window cards, and false positive suppressions.
22
+ Inspect, manage, export, import, or compact persistent local security memory patterns, context window cards, and Golden Fix Recipes.
22
23
 
23
24
  ---
24
25
 
25
- ## Subcommands & Usage
26
+ ## Tri-Mode Execution
26
27
 
27
- | Command | Action | Description |
28
+ | Mode | Command / Tool | Execution Method |
28
29
  | :--- | :--- | :--- |
29
- | `npx torusguard memory` | Status | Display memory stats, pattern count, and context token estimate |
30
- | `npx torusguard memory context` | Context Dump | Output the active pre-computed context window cards |
31
- | `npx torusguard memory fp --rule <RULE_ID>` | False Positive | Suppress rule as false positive across future scans |
32
- | `npx torusguard memory decay [--ttl 90]` | TTL Decay | Apply confidence decay to stale, unconfirmed patterns |
33
- | `npx torusguard memory export --path <FILE>` | Export | Export memory bundle for team sharing |
34
- | `npx torusguard memory import --path <FILE>` | Import | Merge external memory bundle into local project intelligence |
35
- | `npx torusguard memory compact` | Compaction | Archive raw events older than 30 days into single archive |
30
+ | **Mode A: Terminal CLI** | `torusguard recipes [list \| show \| export]` | Terminal management of Golden Fix Recipes. |
31
+ | **Mode B: AI Chat Slash** | `/torusguard recipes` | Interactive exploration of verified remediation patterns. |
32
+ | **Mode C: Native MCP Tool** | `torusguard://rules_catalog` | Programmatic access to catalog rules and distilled patterns. |
36
33
 
37
34
  ---
38
35
 
39
- ## Execution Steps
36
+ ## Subcommands & Usage
40
37
 
41
- 1. **Verify Memory Subsystem:** Confirm `.torusguard/memory/` exists and is shielded by `.gitignore`.
42
- 2. **Execute Requested Action:** Invoke `.torusguard/scripts/memory_engine.py` with appropriate action flag:
43
- ```bash
44
- python .torusguard/scripts/memory_engine.py --action status
45
- ```
46
- 3. **Verify Context Token Budget:** Confirm `context.json` remains within token budget ($\le 2,000$ tokens).
47
- 4. **Display Intelligence Card:** Render summary card to user.
38
+ | Command | Action | Description |
39
+ | :--- | :--- | :--- |
40
+ | `torusguard recipes` | List | Display Golden Fix recipes library |
41
+ | `torusguard recipes list` | Catalog | Enumerate verified fix patterns |
42
+ | `torusguard recipes export` | Export | Export memory bundle for team sharing |
48
43
 
49
44
  ---
50
45
 
51
46
  ## Privacy & Security Invariants
52
47
  - Memory files remain strictly local under `.torusguard/memory/` and are always gitignored.
53
- - Memory files are never packaged into npm release tarballs.
48
+ - Memory files are never packaged into release tarballs.
54
49
  - Export operations only occur when explicitly invoked by user command.
@@ -0,0 +1,25 @@
1
+ # /torusguard-ocr-scan — Multi-Modal OCR Secret Scanning
2
+
3
+ $ARGUMENTS
4
+
5
+ ---
6
+
7
+ ## Objective
8
+ Detect optical leaks of private API keys, AWS credentials, database URIs, GitHub personal access tokens, and private certificates embedded inside visual artifacts (`.png`, `.jpg`, `.jpeg`, `.webp`, `.bmp`, `.tiff`) up to 10MB using Tesseract OCR and deterministic regex signatures.
9
+
10
+ ---
11
+
12
+ ## Tri-Mode Parity
13
+ - **Mode A (Terminal CLI):** `torusguard ocr-scan <target>`
14
+ - **Mode B (AI Chat Slash Command):** `/torusguard ocr-scan <target>`
15
+ - **Mode C (Native MCP Tool):** `torusguard_ocr_scan`
16
+
17
+ ---
18
+
19
+ ## Execution Steps
20
+
21
+ 1. **Verify Target:** Check target image or directory exists on disk.
22
+ 2. **Inspect File Size:** Reject images exceeding 10MB (`DefaultMaxImageSize`) to preserve DoS resilience.
23
+ 3. **Execute OCR Extraction:** Run Tesseract optical text analysis via Go scanner or MCP tool.
24
+ 4. **Pattern Match Secrets:** Evaluate optical text against `TG-SEC-001` through `TG-SEC-007` signatures.
25
+ 5. **Redact & Report:** Emit sanitized finding cards and synchronize into `security_report.md`.
@@ -1,16 +1,15 @@
1
1
  ---
2
2
  description: Targeted differential AST re-scan, fix closure verification, and regression state machine transitions.
3
- tools: Read, Grep, Glob, Bash, Write
4
- version: 1.3.6
3
+ tools: Read, Grep, Glob, Bash, Write, run_command
4
+ version: 2.0.0
5
5
  agent: reviewer
6
6
  lifecycle-phase: Phase 6 (Targeted Recheck & Verification)
7
7
  required-skills:
8
8
  - torusguard-recheck
9
9
  scripts-binding:
10
- - .torusguard/scripts/recheck_runner.py
11
- - .torusguard/scripts/report_sync.py
12
- - .torusguard/scripts/run_manager.py
13
- - .torusguard/scripts/finding_scorer.py
10
+ - internal/recheck/recheck.go
11
+ - cmd/torusguard/main.go
12
+ - cmd/torusguard/mcp.go
14
13
  ---
15
14
 
16
15
  # /torusguard recheck — Targeted Differential Recheck & Regression Audit
@@ -20,31 +19,28 @@ $ARGUMENTS
20
19
  ---
21
20
 
22
21
  ## Objective
23
- Targeted differential AST re-scan, fix closure verification, and regression state transitions.
22
+ Targeted differential AST re-scan, fix closure verification, and regression state machine transitions across modified files.
23
+
24
+ ---
25
+
26
+ ## Tri-Mode Execution
27
+
28
+ | Mode | Command / Tool | Execution Method |
29
+ | :--- | :--- | :--- |
30
+ | **Mode A: Terminal CLI** | `torusguard recheck` | Terminal execution of differential AST scanner. |
31
+ | **Mode B: AI Chat Slash** | `/torusguard recheck` | Conversational differential review and regression verification. |
32
+ | **Mode C: Native MCP Tool** | `torusguard_recheck` | Agent tool call with `{"target": "."}` returning diff assertions. |
24
33
 
25
34
  ---
26
35
 
27
36
  ## Mandatory Pre-Flight Context Inspection
28
37
 
29
38
  Inspect applied patch history and target file scope before re-checking:
30
- 1. **Applied Patch Record:** Verify `apply-log.json` or modified file list exists in the active run.
39
+ 1. **Applied Patch Record:** Inspect git status or diff for modified files.
31
40
  2. **Scope Limitation:** Restrict differential scan strictly to modified files to conserve token budget.
32
- 3. **Rollback Availability:** Confirm `.bak` snapshot exists in `pre_apply/` in case regression is detected.
41
+ 3. **Rollback Availability:** Confirm `.bak` snapshot exists in `.torusguard/snapshots/` in case regression is detected.
33
42
  4. **4-State Transition Engine:** Prepare to transition findings to `Fixed`, `Partially Fixed`, `Not Fixed`, or `Regression`.
34
43
  5. **Fresh Syntax Validation:** Ensure no compiler or syntax errors exist before re-evaluating rules.
35
- 6. **AST Consistency:** Ensure imported dependencies on modified lines resolve correctly.
36
-
37
- ---
38
-
39
- ## When to Use /torusguard recheck
40
-
41
- | Trigger Scenario | Recommended Action |
42
- | :--- | :--- |
43
- | Immediately after applying a remediation patch | Run `/torusguard recheck` |
44
- | Verifying that a specific finding is eliminated | Run `/torusguard recheck` |
45
- | Checking whether a patch introduced new security flaws | Run `/torusguard recheck` |
46
- | Whole repository baseline audit | Run `/torusguard audit` |
47
- | Generating final signed release report | Run `/torusguard report` |
48
44
 
49
45
  ---
50
46
 
@@ -52,32 +48,19 @@ Inspect applied patch history and target file scope before re-checking:
52
48
  - Verified fix closures transition findings in `security_report.md` to `RESOLVED 🟢`.
53
49
  - Regressions transition findings to `REGRESSED ❌`.
54
50
 
55
- ## Execution Steps
56
-
57
- 1. **Identify Modified Files:** Extract list of altered files from latest apply step.
58
- 2. **Execute Differential AST Scan:** Re-run active security rules exclusively against modified files.
59
- 3. **Evaluate Finding Status:**
60
- - If original vulnerable AST pattern is absent and no new sink appears: transition to `Fixed`.
61
- - If new security rule triggers on altered lines: classify as `Regression`.
62
- 4. **Update Finding State:** Record verified resolution status into `findings.json`.
63
- 5. **Emit Recheck Report:** Write `recheck-report.md` into the active run folder.
64
-
65
- ---
66
-
67
- ## Failure Recovery
68
-
69
- - **Finding Still Present (`Not Fixed`):** Review patch diff; the remediation did not neutralize the AST sink.
70
- - **New Vulnerability Detected (`Regression`):** Alert operator; prompt to revert from `.bak` snapshot.
71
- - **File Not Found:** Verify file path matches git repository layout.
72
- - **Halt Trigger:** Abort if diff shows changes outside approved patch scope.
73
-
74
51
  ---
75
52
 
76
- ## Hallucination Guard
53
+ ## Execution Steps
77
54
 
78
- - ❌ Never mark a finding as `Fixed` without re-scanning the actual AST of the patched file.
79
- - ❌ Never ignore new warnings introduced in modified lines.
80
- - ✅ Always provide before/after line comparisons confirming sink removal.
55
+ 1. **Trigger Recheck:**
56
+ - **Mode A (CLI):** Run `torusguard recheck`.
57
+ - **Mode B (Chat):** Review modified files and re-scan AST sinks.
58
+ - **Mode C (MCP):** Call `torusguard_recheck`.
59
+ 2. **Evaluate Finding Status:**
60
+ - If original vulnerable pattern is absent and no new sink appears: transition to `✔ [Confirmed Fixed]`.
61
+ - If new security rule triggers on altered lines: classify as `✖ [Regressed]`.
62
+ 3. **Update Finding State:** Update `security_report.md`.
63
+ 4. **Recommend Posture Report:** Advise running `torusguard report --html`.
81
64
 
82
65
  ---
83
66
 
@@ -89,7 +72,6 @@ Inspect applied patch history and target file scope before re-checking:
89
72
  - **Target Finding:** `TG-XXX-HASH`
90
73
  - **Result:** [FIXED / REGRESSION / PARTIAL]
91
74
  - **Regressions Introduced:** 0
92
- - **Report:** `.torusguard/runs/<run_id>/recheck-report.md`
93
75
  - **Status:** VERIFIED — ready for `/torusguard report`
94
76
  ```
95
77
 
@@ -0,0 +1,27 @@
1
+ # /torusguard-redos — Regular Expression Complexity Scanner
2
+
3
+ $ARGUMENTS
4
+
5
+ ---
6
+
7
+ ## Objective
8
+ Detect and remediate catastrophic exponential ($O(2^n)$) and polynomial backtracking regular expressions in web applications to prevent availability and thread starvation DoS attacks.
9
+
10
+ ---
11
+
12
+ ## Tri-Mode Parity
13
+ - **Mode A (Terminal CLI):** `torusguard redos [target]`
14
+ - **Mode B (AI Chat Slash Command):** `/torusguard redos [target]`
15
+ - **Mode C (Native MCP Tool):** `torusguard_redos`
16
+
17
+ ---
18
+
19
+ ## Execution Steps
20
+
21
+ 1. **Locate Regex Definitions:** Walk source tree to find regex literals and constructor calls (`RegExp`, `re.compile`, `regexp.MustCompile`).
22
+ 2. **Analyze Backtracking Complexity:**
23
+ - Detect nested quantifiers (`(x+)+`, `(x*)*`) causing $O(2^n)$ exponential blowup (`TG-REDOS-001`).
24
+ - Detect overlapping alternations with outer repetition causing polynomial blowup (`TG-REDOS-002`).
25
+ 3. **Audit Input Length Guardrails:** Check if untrusted inputs evaluated against regexes are bounded in character length.
26
+ 4. **Formulate Safe Remediation:** Refactor vulnerable regexes into linear deterministic expressions, anchor tokens, or parser logic.
27
+ 5. **Synchronize Report:** Log all ReDoS findings in `security_report.md`.