torusguard 1.4.0 → 2.1.0

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 (160) hide show
  1. package/.torusguard/.manifest.json +50 -28
  2. package/.torusguard/auth.json +5 -0
  3. package/.torusguard/rules/container/TG-CONT-001-root-user-execution.md +50 -0
  4. package/.torusguard/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
  5. package/.torusguard/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
  6. package/.torusguard/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
  7. package/.torusguard/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
  8. package/.torusguard/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
  9. package/.torusguard/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
  10. package/.torusguard/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
  11. package/.torusguard/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
  12. package/.torusguard/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
  13. package/.torusguard/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
  14. package/.torusguard/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
  15. package/.torusguard/rules_catalog.json +338 -518
  16. package/.torusguard/scripts/__pycache__/apply_runner.cpython-314.pyc +0 -0
  17. package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
  18. package/.torusguard/scripts/__pycache__/harden_runner.cpython-314.pyc +0 -0
  19. package/.torusguard/scripts/__pycache__/html_reporter.cpython-314.pyc +0 -0
  20. package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
  21. package/.torusguard/scripts/__pycache__/recipes_runner.cpython-314.pyc +0 -0
  22. package/.torusguard/scripts/__pycache__/report_sync.cpython-314.pyc +0 -0
  23. package/.torusguard/scripts/manifest_builder.py +1 -1
  24. package/.torusguard/skills/torusguard/SKILL.md +69 -24
  25. package/.torusguard/skills/torusguard/bootstrap.py +57 -24
  26. package/.torusguard/skills/torusguard-ai-guard/SKILL.md +95 -0
  27. package/.torusguard/skills/torusguard-apply/SKILL.md +60 -34
  28. package/.torusguard/skills/torusguard-audit/SKILL.md +73 -24
  29. package/.torusguard/skills/torusguard-authorize/SKILL.md +48 -6
  30. package/.torusguard/skills/torusguard-container/SKILL.md +94 -0
  31. package/.torusguard/skills/torusguard-exploit-check/SKILL.md +50 -6
  32. package/.torusguard/skills/torusguard-full/SKILL.md +62 -19
  33. package/.torusguard/skills/torusguard-git-mine/SKILL.md +92 -0
  34. package/.torusguard/skills/torusguard-harden/SKILL.md +81 -50
  35. package/.torusguard/skills/torusguard-init/SKILL.md +61 -14
  36. package/.torusguard/skills/torusguard-ocr-scan/SKILL.md +94 -0
  37. package/.torusguard/skills/torusguard-recheck/SKILL.md +71 -18
  38. package/.torusguard/skills/torusguard-redos/SKILL.md +91 -0
  39. package/.torusguard/skills/torusguard-report/SKILL.md +50 -9
  40. package/.torusguard/skills/torusguard-status/SKILL.md +63 -10
  41. package/.torusguard/skills/torusguard-verify/SKILL.md +52 -10
  42. package/.torusguard/skills/torusguard-web-validate/SKILL.md +53 -8
  43. package/.torusguard/snapshots/20260921-182638/go.mod.bak +11 -0
  44. package/.torusguard/snapshots/20260921-185213/file.go.bak +5 -0
  45. package/.torusguard/workflows/ai-guard.md +31 -0
  46. package/.torusguard/workflows/apply.md +32 -55
  47. package/.torusguard/workflows/audit.md +28 -46
  48. package/.torusguard/workflows/authorize.md +27 -50
  49. package/.torusguard/workflows/container.md +29 -0
  50. package/.torusguard/workflows/exploit-check.md +28 -50
  51. package/.torusguard/workflows/git-mine.md +25 -0
  52. package/.torusguard/workflows/harden.md +29 -48
  53. package/.torusguard/workflows/init.md +27 -50
  54. package/.torusguard/workflows/memory.md +18 -23
  55. package/.torusguard/workflows/ocr-scan.md +25 -0
  56. package/.torusguard/workflows/recheck.md +28 -46
  57. package/.torusguard/workflows/redos.md +27 -0
  58. package/.torusguard/workflows/report.md +33 -52
  59. package/.torusguard/workflows/status.md +31 -52
  60. package/.torusguard/workflows/verify.md +29 -49
  61. package/.torusguard/workflows/web-validate.md +22 -45
  62. package/README.md +336 -386
  63. package/package.json +1 -1
  64. package/skills/torusguard/SKILL.md +71 -24
  65. package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
  66. package/skills/torusguard/bootstrap.py +60 -71
  67. package/skills/torusguard/payload/.manifest.json +50 -28
  68. package/skills/torusguard/payload/TORUSGUARD.md +145 -145
  69. package/skills/torusguard/payload/agents/auditor.md +41 -41
  70. package/skills/torusguard/payload/agents/profiler.md +49 -49
  71. package/skills/torusguard/payload/agents/remediator.md +41 -41
  72. package/skills/torusguard/payload/agents/reviewer.md +39 -39
  73. package/skills/torusguard/payload/agents/validator.md +46 -46
  74. package/skills/torusguard/payload/config/scope.json +24 -24
  75. package/skills/torusguard/payload/references/csharp-security.md +41 -41
  76. package/skills/torusguard/payload/references/go-security.md +41 -41
  77. package/skills/torusguard/payload/references/java-security.md +40 -40
  78. package/skills/torusguard/payload/references/polyglot-security-matrix.md +25 -25
  79. package/skills/torusguard/payload/references/rust-security.md +40 -40
  80. package/skills/torusguard/payload/rules/container/TG-CONT-001-root-user-execution.md +50 -0
  81. package/skills/torusguard/payload/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
  82. package/skills/torusguard/payload/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
  83. package/skills/torusguard/payload/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
  84. package/skills/torusguard/payload/rules/custom/.gitkeep +1 -1
  85. package/skills/torusguard/payload/rules/custom/README.md +30 -30
  86. package/skills/torusguard/payload/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
  87. package/skills/torusguard/payload/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
  88. package/skills/torusguard/payload/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
  89. package/skills/torusguard/payload/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
  90. package/skills/torusguard/payload/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
  91. package/skills/torusguard/payload/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
  92. package/skills/torusguard/payload/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
  93. package/skills/torusguard/payload/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
  94. package/skills/torusguard/payload/rules_catalog.json +338 -518
  95. package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
  96. package/skills/torusguard/payload/scripts/manifest_builder.py +1 -1
  97. package/skills/torusguard/payload/scripts/rules_sync.py +321 -321
  98. package/skills/torusguard/payload/scripts/safety_gate.py +64 -64
  99. package/skills/torusguard/payload/skills/torusguard/SKILL.md +69 -24
  100. package/skills/torusguard/payload/skills/torusguard/bootstrap.py +57 -24
  101. package/skills/torusguard/payload/skills/torusguard-ai-guard/SKILL.md +95 -0
  102. package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +60 -34
  103. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +73 -24
  104. package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +48 -6
  105. package/skills/torusguard/payload/skills/torusguard-container/SKILL.md +94 -0
  106. package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +50 -6
  107. package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +62 -19
  108. package/skills/torusguard/payload/skills/torusguard-git-mine/SKILL.md +92 -0
  109. package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +81 -50
  110. package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +61 -14
  111. package/skills/torusguard/payload/skills/torusguard-ocr-scan/SKILL.md +94 -0
  112. package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +71 -18
  113. package/skills/torusguard/payload/skills/torusguard-redos/SKILL.md +91 -0
  114. package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +50 -9
  115. package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +63 -10
  116. package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +52 -10
  117. package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +53 -8
  118. package/skills/torusguard/payload/templates/audit-report.template.md +54 -54
  119. package/skills/torusguard/payload/templates/authorization.template.md +34 -34
  120. package/skills/torusguard/payload/templates/finding-card.template.md +32 -32
  121. package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -35
  122. package/skills/torusguard/payload/workflows/ai-guard.md +31 -0
  123. package/skills/torusguard/payload/workflows/apply.md +31 -62
  124. package/skills/torusguard/payload/workflows/audit.md +27 -51
  125. package/skills/torusguard/payload/workflows/authorize.md +27 -50
  126. package/skills/torusguard/payload/workflows/container.md +29 -0
  127. package/skills/torusguard/payload/workflows/exploit-check.md +28 -50
  128. package/skills/torusguard/payload/workflows/git-mine.md +25 -0
  129. package/skills/torusguard/payload/workflows/harden.md +28 -52
  130. package/skills/torusguard/payload/workflows/init.md +27 -56
  131. package/skills/torusguard/payload/workflows/memory.md +18 -23
  132. package/skills/torusguard/payload/workflows/ocr-scan.md +25 -0
  133. package/skills/torusguard/payload/workflows/recheck.md +28 -46
  134. package/skills/torusguard/payload/workflows/redos.md +27 -0
  135. package/skills/torusguard/payload/workflows/report.md +39 -62
  136. package/skills/torusguard/payload/workflows/status.md +31 -55
  137. package/skills/torusguard/payload/workflows/verify.md +29 -49
  138. package/skills/torusguard/payload/workflows/web-validate.md +22 -45
  139. package/skills/torusguard/references/csharp-security.md +41 -0
  140. package/skills/torusguard/references/go-security.md +41 -0
  141. package/skills/torusguard/references/java-security.md +40 -0
  142. package/skills/torusguard/references/polyglot-security-matrix.md +25 -0
  143. package/skills/torusguard/references/rust-security.md +40 -0
  144. package/skills/torusguard-ai-guard/SKILL.md +95 -0
  145. package/skills/torusguard-apply/SKILL.md +60 -34
  146. package/skills/torusguard-audit/SKILL.md +73 -24
  147. package/skills/torusguard-authorize/SKILL.md +48 -6
  148. package/skills/torusguard-container/SKILL.md +94 -0
  149. package/skills/torusguard-exploit-check/SKILL.md +50 -6
  150. package/skills/torusguard-full/SKILL.md +62 -19
  151. package/skills/torusguard-git-mine/SKILL.md +92 -0
  152. package/skills/torusguard-harden/SKILL.md +81 -50
  153. package/skills/torusguard-init/SKILL.md +61 -14
  154. package/skills/torusguard-ocr-scan/SKILL.md +94 -0
  155. package/skills/torusguard-recheck/SKILL.md +71 -18
  156. package/skills/torusguard-redos/SKILL.md +91 -0
  157. package/skills/torusguard-report/SKILL.md +50 -9
  158. package/skills/torusguard-status/SKILL.md +63 -10
  159. package/skills/torusguard-verify/SKILL.md +52 -10
  160. package/skills/torusguard-web-validate/SKILL.md +53 -8
@@ -1,54 +1,54 @@
1
- # TorusGuard Security Audit & Runtime Verification Report
2
-
3
- > **TorusGuard Version:** `{{torusguard_version}}`
4
- > **Target:** `{{target_name}}`
5
- > **Run ID:** `{{run_id}}`
6
- > **Timestamp:** `{{timestamp}}`
7
-
8
- ---
9
-
10
- ## Detected Stack
11
- - **Language:** {{stack_language}}
12
- - **Framework:** {{stack_framework}}
13
- - **Data Layer:** {{stack_data_layer}}
14
- - **Dependency Files:** {{stack_dependency_files}}
15
- - **Detection Confidence:** {{stack_confidence}}
16
-
17
- ---
18
-
19
- ## Executive Posture
20
- **Posture:** {{posture_indicator}}
21
- **Average Confidence Score:** `{{avg_confidence_score}}/100`
22
-
23
- ### Finding Summary
24
- | Severity | Count | Confirmed | Needs Review | Remediated |
25
- | :--- | :---: | :---: | :---: | :---: |
26
- | 🔴 **Critical** | {{critical_count}} | {{critical_confirmed}} | {{critical_review}} | {{critical_fixed}} |
27
- | 🟠 **High** | {{high_count}} | {{high_confirmed}} | {{high_review}} | {{high_fixed}} |
28
- | 🟡 **Medium** | {{medium_count}} | {{medium_confirmed}} | {{medium_review}} | {{medium_fixed}} |
29
- | 🔵 **Low** | {{low_count}} | {{low_confirmed}} | {{low_review}} | {{low_fixed}} |
30
-
31
- ---
32
-
33
- ## Root-Cause Clusters
34
- {{cluster_summary_table}}
35
-
36
- ---
37
-
38
- ## Detailed Findings
39
- {{finding_cards_section}}
40
-
41
- ---
42
-
43
- ## Governance & Safety Audit Statement
44
- This execution complied with TorusGuard v0.8.0 governance rules:
45
- - **Authorization Gate:** {{authorization_status}}
46
- - **Patch Governance (Ponytail):** Additions $\le 35$, Deletions $\le 25$.
47
- - **Token Redaction:** All captured authorization headers, bearer tokens, and passwords were redacted.
48
-
49
- ---
50
-
51
- ## Prioritized Next Steps
52
- 1. **Remediate Confirmed Sinks:** Run `/torusguard harden` to package remediation bundles.
53
- 2. **Apply Governed Fixes:** Run `/torusguard apply <bundle_id>` to apply targeted fixes.
54
- 3. **Verify Fixes:** Run `/torusguard recheck` to ensure no regressions exist.
1
+ # TorusGuard Security Audit & Runtime Verification Report
2
+
3
+ > **TorusGuard Version:** `{{torusguard_version}}`
4
+ > **Target:** `{{target_name}}`
5
+ > **Run ID:** `{{run_id}}`
6
+ > **Timestamp:** `{{timestamp}}`
7
+
8
+ ---
9
+
10
+ ## Detected Stack
11
+ - **Language:** {{stack_language}}
12
+ - **Framework:** {{stack_framework}}
13
+ - **Data Layer:** {{stack_data_layer}}
14
+ - **Dependency Files:** {{stack_dependency_files}}
15
+ - **Detection Confidence:** {{stack_confidence}}
16
+
17
+ ---
18
+
19
+ ## Executive Posture
20
+ **Posture:** {{posture_indicator}}
21
+ **Average Confidence Score:** `{{avg_confidence_score}}/100`
22
+
23
+ ### Finding Summary
24
+ | Severity | Count | Confirmed | Needs Review | Remediated |
25
+ | :--- | :---: | :---: | :---: | :---: |
26
+ | 🔴 **Critical** | {{critical_count}} | {{critical_confirmed}} | {{critical_review}} | {{critical_fixed}} |
27
+ | 🟠 **High** | {{high_count}} | {{high_confirmed}} | {{high_review}} | {{high_fixed}} |
28
+ | 🟡 **Medium** | {{medium_count}} | {{medium_confirmed}} | {{medium_review}} | {{medium_fixed}} |
29
+ | 🔵 **Low** | {{low_count}} | {{low_confirmed}} | {{low_review}} | {{low_fixed}} |
30
+
31
+ ---
32
+
33
+ ## Root-Cause Clusters
34
+ {{cluster_summary_table}}
35
+
36
+ ---
37
+
38
+ ## Detailed Findings
39
+ {{finding_cards_section}}
40
+
41
+ ---
42
+
43
+ ## Governance & Safety Audit Statement
44
+ This execution complied with TorusGuard v0.8.0 governance rules:
45
+ - **Authorization Gate:** {{authorization_status}}
46
+ - **Patch Governance (Ponytail):** Additions $\le 35$, Deletions $\le 25$.
47
+ - **Token Redaction:** All captured authorization headers, bearer tokens, and passwords were redacted.
48
+
49
+ ---
50
+
51
+ ## Prioritized Next Steps
52
+ 1. **Remediate Confirmed Sinks:** Run `/torusguard harden` to package remediation bundles.
53
+ 2. **Apply Governed Fixes:** Run `/torusguard apply <bundle_id>` to apply targeted fixes.
54
+ 3. **Verify Fixes:** Run `/torusguard recheck` to ensure no regressions exist.
@@ -1,34 +1,34 @@
1
- # TorusGuard Target Authorization Record
2
-
3
- **Authorization ID:** `{{authorization_id}}`
4
- **Generated At:** `{{timestamp}}`
5
- **Valid Until:** `{{valid_until}}`
6
-
7
- ---
8
-
9
- ## 1. Target Identification
10
- - **Project / Application:** `{{target_name}}`
11
- - **Target URL / Hosts:** `{{target_hosts}}`
12
- - **Scope Type:** `{{scope_type}}`
13
-
14
- ---
15
-
16
- ## 2. Permitted Boundaries
17
- - **Allowed Path Prefixes:**
18
- {{allowed_path_prefixes_list}}
19
-
20
- - **Explicitly Forbidden / Excluded Paths:**
21
- {{forbidden_paths_list}}
22
-
23
- - **Max Navigation Depth:** `{{max_depth}}`
24
- - **Max Request Budget:** `{{max_requests}}`
25
- - **Allow State-Changing Methods:** `{{allow_state_changing_methods}}`
26
-
27
- ---
28
-
29
- ## 3. Owner Confirmation & Legal Statement
30
- > [!IMPORTANT]
31
- > The target application owner has confirmed that this testing environment is authorized for non-destructive, bounded runtime security validation.
32
-
33
- - **Authorized By:** `{{authorized_by}}`
34
- - **Confirmation Status:** `Owner Confirmed`
1
+ # TorusGuard Target Authorization Record
2
+
3
+ **Authorization ID:** `{{authorization_id}}`
4
+ **Generated At:** `{{timestamp}}`
5
+ **Valid Until:** `{{valid_until}}`
6
+
7
+ ---
8
+
9
+ ## 1. Target Identification
10
+ - **Project / Application:** `{{target_name}}`
11
+ - **Target URL / Hosts:** `{{target_hosts}}`
12
+ - **Scope Type:** `{{scope_type}}`
13
+
14
+ ---
15
+
16
+ ## 2. Permitted Boundaries
17
+ - **Allowed Path Prefixes:**
18
+ {{allowed_path_prefixes_list}}
19
+
20
+ - **Explicitly Forbidden / Excluded Paths:**
21
+ {{forbidden_paths_list}}
22
+
23
+ - **Max Navigation Depth:** `{{max_depth}}`
24
+ - **Max Request Budget:** `{{max_requests}}`
25
+ - **Allow State-Changing Methods:** `{{allow_state_changing_methods}}`
26
+
27
+ ---
28
+
29
+ ## 3. Owner Confirmation & Legal Statement
30
+ > [!IMPORTANT]
31
+ > The target application owner has confirmed that this testing environment is authorized for non-destructive, bounded runtime security validation.
32
+
33
+ - **Authorized By:** `{{authorized_by}}`
34
+ - **Confirmation Status:** `Owner Confirmed`
@@ -1,32 +1,32 @@
1
- ### [{{rule_id}}] {{finding_title}}
2
-
3
- **Severity:** `{{severity_badge}}` | **Auditable Confidence:** `{{confidence_score}}/100 {{confidence_band_badge}}`
4
- **Finding ID:** `{{finding_id}}` | **Fingerprint:** `{{fingerprint_hash}}`
5
- **Target Location:** `{{file_path}}:{{line_number}}` (`{{code_symbol}}`)
6
- **Lifecycle Status:** `{{lifecycle_status}}` | **Exploitability:** `{{exploitability_status}}`
7
-
8
- ---
9
-
10
- #### 1. Provenance Chain
11
- - **Detection Rule:** `{{rule_id}}` (CWE-{{cwe_id}})
12
- - **Triggering Input:** `{{triggering_source}}`
13
- - **Sink Path:** `{{sink_expression}}`
14
-
15
- #### 2. Raw Verified Evidence
16
- ```{{code_language}}
17
- {{raw_evidence_snippet}}
18
- ```
19
- > **Evidence Checksum (SHA-256):** `{{evidence_sha256}}`
20
-
21
- #### 3. Objective Facts vs AI Interpretation
22
- - **Verified Facts:** {{raw_facts_summary}}
23
- - **AI Risk Analysis:** {{ai_interpretation}}
24
-
25
- #### 4. Remediation Diff (Minimal Churn)
26
- ```diff
27
- {{remediation_diff_preview}}
28
- ```
29
-
30
- #### 5. Retest & Verification
31
- - **Verification Method:** {{verification_method}}
32
- - **Current Retest Status:** `{{retest_status}}`
1
+ ### [{{rule_id}}] {{finding_title}}
2
+
3
+ **Severity:** `{{severity_badge}}` | **Auditable Confidence:** `{{confidence_score}}/100 {{confidence_band_badge}}`
4
+ **Finding ID:** `{{finding_id}}` | **Fingerprint:** `{{fingerprint_hash}}`
5
+ **Target Location:** `{{file_path}}:{{line_number}}` (`{{code_symbol}}`)
6
+ **Lifecycle Status:** `{{lifecycle_status}}` | **Exploitability:** `{{exploitability_status}}`
7
+
8
+ ---
9
+
10
+ #### 1. Provenance Chain
11
+ - **Detection Rule:** `{{rule_id}}` (CWE-{{cwe_id}})
12
+ - **Triggering Input:** `{{triggering_source}}`
13
+ - **Sink Path:** `{{sink_expression}}`
14
+
15
+ #### 2. Raw Verified Evidence
16
+ ```{{code_language}}
17
+ {{raw_evidence_snippet}}
18
+ ```
19
+ > **Evidence Checksum (SHA-256):** `{{evidence_sha256}}`
20
+
21
+ #### 3. Objective Facts vs AI Interpretation
22
+ - **Verified Facts:** {{raw_facts_summary}}
23
+ - **AI Risk Analysis:** {{ai_interpretation}}
24
+
25
+ #### 4. Remediation Diff (Minimal Churn)
26
+ ```diff
27
+ {{remediation_diff_preview}}
28
+ ```
29
+
30
+ #### 5. Retest & Verification
31
+ - **Verification Method:** {{verification_method}}
32
+ - **Current Retest Status:** `{{retest_status}}`
@@ -1,35 +1,35 @@
1
- # Remediation Bundle: `{{bundle_id}}`
2
-
3
- **Cluster ID:** `{{cluster_id}}`
4
- **Target Rule:** `{{rule_id}}` (`{{rule_title}}`)
5
- **Affected Files:** `{{affected_files}}`
6
-
7
- ---
8
-
9
- ## 1. Problem Statement & Risk
10
- {{problem_statement}}
11
-
12
- **Adversarial Abuse & Practical Impact:**
13
- {{risk_explanation}}
14
-
15
- ---
16
-
17
- ## 2. Governed Minimal Patch Plan
18
- - **Max Additions Boundary:** $\le 35$ lines (Proposed: `+{{additions_count}}`)
19
- - **Max Deletions Boundary:** $\le 25$ lines (Proposed: `-{{deletions_count}}`)
20
- - **Governance Review Level:** `{{governance_review_level}}`
21
-
22
- ### Framework-Native Diff
23
- ```diff
24
- {{candidate_patch_diff}}
25
- ```
26
-
27
- ---
28
-
29
- ## 3. Verification & Retest Method
30
- {{verification_method}}
31
-
32
- ---
33
-
34
- ## 4. Residual Risk & Edge Cases
35
- {{residual_risk_notes}}
1
+ # Remediation Bundle: `{{bundle_id}}`
2
+
3
+ **Cluster ID:** `{{cluster_id}}`
4
+ **Target Rule:** `{{rule_id}}` (`{{rule_title}}`)
5
+ **Affected Files:** `{{affected_files}}`
6
+
7
+ ---
8
+
9
+ ## 1. Problem Statement & Risk
10
+ {{problem_statement}}
11
+
12
+ **Adversarial Abuse & Practical Impact:**
13
+ {{risk_explanation}}
14
+
15
+ ---
16
+
17
+ ## 2. Governed Minimal Patch Plan
18
+ - **Max Additions Boundary:** $\le 35$ lines (Proposed: `+{{additions_count}}`)
19
+ - **Max Deletions Boundary:** $\le 25$ lines (Proposed: `-{{deletions_count}}`)
20
+ - **Governance Review Level:** `{{governance_review_level}}`
21
+
22
+ ### Framework-Native Diff
23
+ ```diff
24
+ {{candidate_patch_diff}}
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 3. Verification & Retest Method
30
+ {{verification_method}}
31
+
32
+ ---
33
+
34
+ ## 4. Residual Risk & Edge Cases
35
+ {{residual_risk_notes}}
@@ -0,0 +1,31 @@
1
+ # /torusguard-ai-guard — AI Application & RAG Pipeline Guard
2
+
3
+ $ARGUMENTS
4
+
5
+ ---
6
+
7
+ ## Objective
8
+ Detect and remediate prompt injection, unsandboxed autonomous tool executions, and cross-tenant vector contamination across AI agent and RAG architectures.
9
+
10
+ ---
11
+
12
+ ## Tri-Mode Parity
13
+ - **Mode A (Terminal CLI):** `torusguard ai-guard [target]`
14
+ - **Mode B (AI Chat Slash Command):** `/torusguard ai-guard [target]`
15
+ - **Mode C (Native MCP Tool):** `torusguard_ai_guard`
16
+
17
+ ---
18
+
19
+ ## Execution Steps
20
+
21
+ 1. **Discover LLM & Agent Call Sites:** Locate AI framework usage (OpenAI, Anthropic, LangChain, LlamaIndex, Vercel AI SDK).
22
+ 2. **Audit Prompt Templates:**
23
+ - Detect raw user string concatenation into system instructions (`TG-AGENT-001`).
24
+ - Flag raw document chunk ingestion in RAG without inert delimiters (`TG-RAG-002`).
25
+ 3. **Audit Tool Registry & Dispatchers:**
26
+ - Check for unsandboxed shell, file, or database tool calls lacking Human Gates (`TG-AGENT-002`).
27
+ - Enforce Zod/Pydantic schema validation on all tool argument payloads (`TG-AGENT-003`).
28
+ 4. **Audit Vector Store Queries:**
29
+ - Assert all similarity searches (`pgvector`, `pinecone`, `qdrant`, `chroma`) include tenant/user metadata filters (`TG-RAG-001`).
30
+ - Flag ingestion of unvalidated external document payloads (`TG-RAG-003`).
31
+ 5. **Formulate Patches & Synchronize:** Propose surgical fixes and record findings in `security_report.md`.
@@ -1,16 +1,14 @@
1
1
  ---
2
2
  description: Governed patch application with pre-apply rollback snapshots and Human Gate authorization.
3
- tools: Read, Grep, Glob, Bash, Edit, Write
4
- version: 1.4.0
3
+ tools: Read, Grep, Glob, Bash, Edit, Write, run_command
4
+ version: 2.0.0
5
5
  agent: remediator
6
6
  lifecycle-phase: Phase 5 (Patch Application)
7
7
  required-skills:
8
8
  - torusguard-apply
9
9
  scripts-binding:
10
- - .torusguard/scripts/apply_runner.py
11
- - .torusguard/scripts/report_sync.py
12
- - .torusguard/scripts/run_manager.py
13
- - .torusguard/scripts/diff_guard.py
10
+ - internal/apply/apply.go
11
+ - cmd/torusguard/main.go
14
12
  ---
15
13
 
16
14
  # /torusguard apply — Governed Patch Application & Rollback Snapshot
@@ -20,91 +18,62 @@ $ARGUMENTS
20
18
  ---
21
19
 
22
20
  ## Objective
23
- Governed patch application with pre-apply rollback snapshots and Human Gate authorization.
21
+ Safely apply approved remediation bundles to disk source files, creating an automated byte-for-byte pre-apply backup snapshot (`.bak`) in `.torusguard/snapshots/<run_id>/`, asserting syntax validity, and distilling passing patterns into Golden Fix Recipes.
24
22
 
25
- Supported CLI flags:
26
- - `npx torusguard apply [--target <dir>]` : Apply candidate patches with confirmation prompt
27
- - `npx torusguard apply --diff` : Preview unified diffs without modifying files on disk
28
- - `npx torusguard apply --selective` : Interactively review and approve patches one by one
29
- - `npx torusguard apply --verify` : Trigger immediate differential AST recheck post-apply
30
- - `npx torusguard apply --list-snapshots` : List available historical pre-apply backup snapshots
31
- - `npx torusguard apply --yes` / `-y` : Non-interactive auto-approval mode
23
+ ---
24
+
25
+ ## Tri-Mode Execution
26
+
27
+ | Mode | Command / Tool | Execution Method |
28
+ | :--- | :--- | :--- |
29
+ | **Mode A: Terminal CLI** | `torusguard apply candidate.patch [--yes]` | Shell execution of patch applier with snapshot creation. |
30
+ | **Mode B: AI Chat Slash** | `/torusguard apply` | Guided conversational application with explicit Human Gate approval. |
31
+ | **Mode C: Native MCP Tool** | Autonomous Agent Flow | Formulates patch with `torusguard_harden`, awaits Human Gate, invokes CLI. |
32
32
 
33
33
  ---
34
34
 
35
35
  ## Mandatory Pre-Flight Context Inspection
36
36
 
37
37
  Inspect bundle validity and file safety before modifying disk code:
38
- 1. **Bundle Verification:** Assert `patch.diff` exists in active run's remediation folder.
39
- 2. **Pre-Apply Snapshot:** Save a byte-for-byte backup copy (`.bak` or `.torusguard/snapshots/<run_id>/`) prior to editing.
38
+ 1. **Bundle Verification:** Assert `candidate.patch` or semantic `patch.json` exists.
39
+ 2. **Pre-Apply Snapshot:** Save a byte-for-byte backup copy (`.torusguard/snapshots/<run_id>/<rel_path>.bak`) prior to editing.
40
40
  3. **Uncommitted Changes:** Check git status; ensure target file has clean baseline.
41
41
  4. **Ponytail Check:** Re-verify that patch additions $\le 35$ and deletions $\le 25$.
42
42
  5. **Human Gate:** Confirm operator approval before committing edits to disk.
43
- 6. **Workspace Cleanliness:** Verify git working tree has no uncommitted merge conflicts.
44
- 7. **Execution Privilege:** Verify write access to targeted file locations.
45
-
46
- ---
47
-
48
- ## When to Use /torusguard apply
49
-
50
- | Trigger Scenario | Recommended Action |
51
- | :--- | :--- |
52
- | Applying an approved remediation patch to disk | Run `/torusguard apply` |
53
- | Generating patch diff without modifying disk | Run `/torusguard harden` |
54
- | Verifying that patch eliminated flaw without regression | Run `/torusguard recheck` |
55
- | Reverting an applied patch | Restore from `.bak` snapshot |
56
- | Checking workspace status | Run `/torusguard status` |
57
43
 
58
44
  ---
59
45
 
60
46
  ## Living Report Invariant
61
47
  - Applied patches create pre-apply `.bak` snapshots in `.torusguard/snapshots/<run_id>/`.
62
48
  - Finding statuses transition in `security_report.md` to `APPLIED 🔵`.
63
- - Instant rollback available via `npx torusguard rollback`.
64
-
65
- ## Execution Steps
66
-
67
- 1. **Load Remediation Bundle:** Read `patch.diff` and metadata from active run directory.
68
- 2. **Audit Patch Invariants:** Run `python .torusguard/scripts/diff_guard.py <patch.diff>`.
69
- 3. **Create Rollback Backup:** Copy target file to `.torusguard/runs/<run_id>/.torusguard/snapshots/<run_id>/<filename>.bak`.
70
- 4. **Apply Minimal Diff:** Execute precise surgical edit using `replace_file_content` or `patch`.
71
- 5. **Assert Syntax & Integrity:** Check that modified file compiles cleanly without syntax errors.
72
- 6. **Log Application Ledger:** Record timestamp, original SHA-256, and patched SHA-256 in `apply-log.json`.
49
+ - Instant rollback available via `torusguard rollback`.
73
50
 
74
51
  ---
75
52
 
76
- ## Failure Recovery
77
-
78
- - **Syntax Error After Patch:** Instantly revert target file from `.bak` backup snapshot.
79
- - **Merge / Context Conflict:** Re-run `/torusguard harden` to regenerate diff against latest disk lines.
80
- - **Missing Backup File:** Do not apply patch if backup copy cannot be written.
81
- - **Halt Trigger:** Abort if git working tree is dirty on conflicting lines.
82
-
83
- ---
84
-
85
- ## Hallucination Guard
53
+ ## Execution Steps
86
54
 
87
- - ❌ Never apply code changes without creating an exact pre-apply rollback backup first.
88
- - ❌ Never touch files not explicitly listed in the approved `patch.diff`.
89
- - ✅ Always verify syntax compilation immediately after modifying source files.
55
+ 1. **Load Remediation Bundle:** Read `candidate.patch` or `patch.json`.
56
+ 2. **Obtain Human Gate:** Confirm user approval to modify target source file.
57
+ 3. **Create Rollback Backup:** Capture `.bak` in `.torusguard/snapshots/<run_id>/`.
58
+ 4. **Apply Surgical Edit:** Run `torusguard apply <patch> --yes` or apply semantic reflection.
59
+ 5. **Assert Syntax & Integrity:** Check that modified file compiles cleanly (`go test ./...`, syntax lint).
60
+ 6. **Recommend Recheck:** Run `torusguard recheck` or `/torusguard recheck`.
90
61
 
91
62
  ---
92
63
 
93
64
  ## Output Card Format
94
65
 
95
66
  ```markdown
96
- ### 🚀 TorusGuard Patch Application
97
- - **Finding Addressed:** `TG-XXX-HASH`
98
- - **File Patched:** `src/path/to/file.py`
99
- - **Rollback Backup:** `.torusguard/runs/<run_id>/.torusguard/snapshots/<run_id>/<file>.bak`
100
- - **Churn Applied:** +[Additions] / -[Deletions] lines
101
- - **Syntax Check:** PASSED (clean compile)
102
- - **Status:** APPLIED — run `/torusguard recheck` to verify fix
67
+ ### 🚀 TorusGuard Patch Applied Successfully
68
+ - **Target File:** `src/path/to/file`
69
+ - **Backup Snapshot:** `.torusguard/snapshots/<run_id>/<file>.bak`
70
+ - **Rollback Command:** `torusguard rollback`
71
+ - **Next Step:** Run `/torusguard recheck` to verify closure
103
72
  ```
104
73
 
105
74
  ---
106
75
 
107
76
  ## Next Steps
108
77
 
109
- 1. Run `/torusguard recheck` to perform differential audit on the modified file.
110
- 2. Run test suites to verify that business logic and regressions remain intact.
78
+ 1. Run `/torusguard recheck` or `torusguard recheck` to verify closure and zero regressions.
79
+ 2. If unexpected behavior occurs, run `torusguard rollback`.
@@ -1,16 +1,15 @@
1
1
  ---
2
2
  description: Static security AST scanning, stable line-shift invariant fingerprinting, root-cause clustering, and 0-100 confidence scoring.
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: auditor
6
6
  lifecycle-phase: Phase 2 (Static Audit & Clustering)
7
7
  required-skills:
8
8
  - torusguard-audit
9
9
  scripts-binding:
10
- - .torusguard/scripts/audit_runner.py
11
- - .torusguard/scripts/report_sync.py
12
- - .torusguard/scripts/run_manager.py
13
- - .torusguard/scripts/finding_scorer.py
10
+ - internal/scanner/scanner.go
11
+ - cmd/torusguard/main.go
12
+ - cmd/torusguard/mcp.go
14
13
  ---
15
14
 
16
15
  # /torusguard audit — Static Security Code Scan & Clustering
@@ -20,36 +19,27 @@ $ARGUMENTS
20
19
  ---
21
20
 
22
21
  ## Objective
23
- Static security AST scanning, stable fingerprinting, root-cause clustering, throughput telemetry, and 0-100 scoring.
22
+ 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.
24
23
 
25
- Supported CLI flags:
26
- - `npx torusguard audit [--target <dir>]` : Specify project root directory
27
- - `npx torusguard audit --watch` / `-w` : Continuous watch mode, re-scanning on file change
28
- - `npx torusguard audit --sarif` : Automatically export OASIS SARIF v2.1.0 log
29
- - `npx torusguard audit --severity <critical|high|medium|low>` : Floor filter for findings
24
+ ---
25
+
26
+ ## Tri-Mode Execution
27
+
28
+ | Mode | Command / Tool | Execution Method |
29
+ | :--- | :--- | :--- |
30
+ | **Mode A: Terminal CLI** | `torusguard audit [--include-tests] [--json]` | Shell execution of compiled Go binary. |
31
+ | **Mode B: AI Chat Slash** | `/torusguard audit` | Conversational guided audit with bounded context inspection. |
32
+ | **Mode C: Native MCP Tool** | `torusguard_audit` | Autonomous agent tool invocation via stdio JSON-RPC. |
30
33
 
31
34
  ---
32
35
 
33
36
  ## Mandatory Pre-Flight Context Inspection
34
37
 
35
38
  Inspect workspace prerequisites before launching static audit:
36
- 1. **Init State (`torusguard.json`):** Assert repository is initialized.
39
+ 1. **Init State (`torusguard.json`):** Assert repository is initialized or run `torusguard init`.
37
40
  2. **Active Rules (`rules/active/`):** Confirm rule definitions exist.
38
41
  3. **Exclusions:** Assert `node_modules/`, `.venv/`, `dist/`, `.git/` are skipped.
39
- 4. **Run Folder:** Allocate isolated folder in `.torusguard/runs/`.
40
- 5. **Syntax Check:** Check for syntax errors before parsing ASTs.
41
-
42
- ---
43
-
44
- ## When to Use /torusguard audit
45
-
46
- | Trigger Scenario | Recommended Action |
47
- | :--- | :--- |
48
- | First-time scan of repository or new branch | Run `/torusguard audit` |
49
- | Pre-commit review and PR security checks | Run `/torusguard audit` |
50
- | Uninitialized project | Run `/torusguard init` first |
51
- | Live endpoint or runtime probing | Run `/torusguard web-validate` |
52
- | Differential check after patch | Run `/torusguard recheck` |
42
+ 4. **Syntax Check:** Check for syntax errors before parsing ASTs.
53
43
 
54
44
  ---
55
45
 
@@ -57,31 +47,18 @@ Inspect workspace prerequisites before launching static audit:
57
47
  - Audit discoveries automatically synchronize to `security_report.md` at workspace root.
58
48
  - Findings transition into `OPEN 🔴` status with stable invariant fingerprints.
59
49
 
60
- ## Execution Steps
61
-
62
- 1. **Allocate Run Folder:** Run `python .torusguard/scripts/run_manager.py create audit`.
63
- 2. **Scan Codebase ASTs:** Match active rules against source trees.
64
- 3. **Compute Stable Fingerprints:** Hash AST context to produce stable IDs.
65
- 4. **Cluster Root Causes:** Group findings sharing identical sinks.
66
- 5. **Score Confidence (0–100):** Run `python .torusguard/scripts/finding_scorer.py --run <run_dir>`.
67
- 6. **Emit Artifacts:** Write `findings.md`, `findings.json`, and `summary.md`.
68
-
69
50
  ---
70
51
 
71
- ## Failure Recovery
72
-
73
- - **Zero Rules Active:** Re-run `/torusguard init` to activate rules.
74
- - **AST Parse Error:** Log syntax error on malformed file, skip, and continue.
75
- - **Scorer Failure:** Ensure Python 3.10+; verify finding JSON structure.
76
- - **Halt Trigger:** Abort if run folder cannot be allocated or disk write fails.
77
-
78
- ---
79
-
80
- ## Hallucination Guard
52
+ ## Execution Steps
81
53
 
82
- - ❌ Never invent finding IDs without AST line hashing.
83
- - ❌ Never flag test fixtures as critical security flaws.
84
- - ✅ Always calculate scores using `.torusguard/scripts/finding_scorer.py`.
54
+ 1. **Launch Audit Scan:**
55
+ - **Mode A (CLI):** Run `torusguard audit` in terminal.
56
+ - **Mode B (Chat):** Parse AST sinks using `grep_search` and bounded `ExtractContext`.
57
+ - **Mode C (MCP):** Call `torusguard_audit` with `{"target": "."}`.
58
+ 2. **Scan Codebase ASTs:** Match 74 canonical rules across 18 families against source trees.
59
+ 3. **Compute Stable Fingerprints:** Hash AST context to produce stable line-shift invariant IDs.
60
+ 4. **Cluster Root Causes:** Group findings sharing identical sinks or causal architecture.
61
+ 5. **Synchronize Ground Truth:** Update `security_report.md` at workspace root.
85
62
 
86
63
  ---
87
64
 
@@ -89,12 +66,11 @@ Inspect workspace prerequisites before launching static audit:
89
66
 
90
67
  ```markdown
91
68
  ### 🔎 TorusGuard Static Audit Results
92
- - **Run ID:** `run-YYYYMMDD-HHMMSS-audit`
93
69
  - **Files Scanned:** [Count] source files
94
70
  - **Total Findings:** [Count] ([Critical] Critical, [High] High)
95
71
  - **Root Cause Clusters:** [Count] architectural issues
96
72
  - **Confidence:** [Score]/100
97
- - **Artifact:** `.torusguard/runs/<run_id>/findings.md`
73
+ - **Living Report:** `security_report.md`
98
74
  ```
99
75
 
100
76
  ---