torusguard 0.9.2

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 (236) hide show
  1. package/.torusguard/.manifest.json +95 -0
  2. package/.torusguard/ARCHITECTURE.md +168 -0
  3. package/.torusguard/TORUSGUARD.md +145 -0
  4. package/.torusguard/agents/auditor.md +41 -0
  5. package/.torusguard/agents/profiler.md +49 -0
  6. package/.torusguard/agents/remediator.md +41 -0
  7. package/.torusguard/agents/reviewer.md +39 -0
  8. package/.torusguard/agents/validator.md +46 -0
  9. package/.torusguard/config/scope.json +24 -0
  10. package/.torusguard/config/slash-commands.json +102 -0
  11. package/.torusguard/config/torusguard.json +30 -0
  12. package/.torusguard/references/django-security.md +43 -0
  13. package/.torusguard/references/drf-security.md +20 -0
  14. package/.torusguard/references/express-security.md +103 -0
  15. package/.torusguard/references/fastapi-security.md +20 -0
  16. package/.torusguard/references/firebase-security.md +78 -0
  17. package/.torusguard/references/flask-security.md +20 -0
  18. package/.torusguard/references/nextjs-security.md +96 -0
  19. package/.torusguard/references/react-vite-security.md +97 -0
  20. package/.torusguard/references/sqlalchemy-security.md +16 -0
  21. package/.torusguard/references/supabase-security.md +84 -0
  22. package/.torusguard/rules/README.md +62 -0
  23. package/.torusguard/rules/TORUSGUARD.md +145 -0
  24. package/.torusguard/rules/active/.gitkeep +0 -0
  25. package/.torusguard/rules/active/TG-DIFF-001.md +20 -0
  26. package/.torusguard/rules/active/TG-DIFF-002.md +20 -0
  27. package/.torusguard/rules/active/TG-DIFF-003.md +19 -0
  28. package/.torusguard/runs/.gitkeep +0 -0
  29. package/.torusguard/schemas/authorization.schema.json +81 -0
  30. package/.torusguard/schemas/confidence.schema.json +72 -0
  31. package/.torusguard/schemas/evidence.schema.json +66 -0
  32. package/.torusguard/schemas/finding.schema.json +164 -0
  33. package/.torusguard/schemas/provenance.schema.json +46 -0
  34. package/.torusguard/schemas/remediation.schema.json +59 -0
  35. package/.torusguard/schemas/retest.schema.json +53 -0
  36. package/.torusguard/schemas/runtime-evidence.schema.json +72 -0
  37. package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
  38. package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
  39. package/.torusguard/scripts/diff_guard.py +171 -0
  40. package/.torusguard/scripts/finding_scorer.py +86 -0
  41. package/.torusguard/scripts/manifest_builder.py +130 -0
  42. package/.torusguard/scripts/monorepo_detector.py +164 -0
  43. package/.torusguard/scripts/run_manager.py +89 -0
  44. package/.torusguard/scripts/safety_gate.py +64 -0
  45. package/.torusguard/scripts/sarif_exporter.py +116 -0
  46. package/.torusguard/scripts/stack_detect.py +152 -0
  47. package/.torusguard/skills/torusguard/SKILL.md +37 -0
  48. package/.torusguard/skills/torusguard/bootstrap.py +158 -0
  49. package/.torusguard/skills/torusguard/references/auth-and-sessions.md +56 -0
  50. package/.torusguard/skills/torusguard/references/business-logic-and-abuse.md +23 -0
  51. package/.torusguard/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
  52. package/.torusguard/skills/torusguard/references/client-code-exposure.md +55 -0
  53. package/.torusguard/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
  54. package/.torusguard/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
  55. package/.torusguard/skills/torusguard/references/django-security.md +43 -0
  56. package/.torusguard/skills/torusguard/references/drf-security.md +20 -0
  57. package/.torusguard/skills/torusguard/references/fastapi-security.md +20 -0
  58. package/.torusguard/skills/torusguard/references/flask-security.md +20 -0
  59. package/.torusguard/skills/torusguard/references/frontend-no-db.md +53 -0
  60. package/.torusguard/skills/torusguard/references/graphql-security.md +12 -0
  61. package/.torusguard/skills/torusguard/references/input-and-injection.md +51 -0
  62. package/.torusguard/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
  63. package/.torusguard/skills/torusguard/references/platform-hardening.md +56 -0
  64. package/.torusguard/skills/torusguard/references/python-dependencies.md +16 -0
  65. package/.torusguard/skills/torusguard/references/python-security-overview.md +12 -0
  66. package/.torusguard/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
  67. package/.torusguard/skills/torusguard/references/secrets-and-config.md +64 -0
  68. package/.torusguard/skills/torusguard/references/sqlalchemy-security.md +16 -0
  69. package/.torusguard/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
  70. package/.torusguard/skills/torusguard/references/webhook-security.md +15 -0
  71. package/.torusguard/skills/torusguard/references/websocket-security.md +12 -0
  72. package/.torusguard/skills/torusguard-apply/SKILL.md +46 -0
  73. package/.torusguard/skills/torusguard-audit/SKILL.md +70 -0
  74. package/.torusguard/skills/torusguard-authorize/SKILL.md +47 -0
  75. package/.torusguard/skills/torusguard-exploit-check/SKILL.md +64 -0
  76. package/.torusguard/skills/torusguard-full/SKILL.md +70 -0
  77. package/.torusguard/skills/torusguard-harden/SKILL.md +63 -0
  78. package/.torusguard/skills/torusguard-init/SKILL.md +52 -0
  79. package/.torusguard/skills/torusguard-recheck/SKILL.md +53 -0
  80. package/.torusguard/skills/torusguard-report/SKILL.md +54 -0
  81. package/.torusguard/skills/torusguard-status/SKILL.md +42 -0
  82. package/.torusguard/skills/torusguard-verify/SKILL.md +55 -0
  83. package/.torusguard/skills/torusguard-web-validate/SKILL.md +64 -0
  84. package/.torusguard/templates/audit-report.template.md +54 -0
  85. package/.torusguard/templates/authorization.template.md +34 -0
  86. package/.torusguard/templates/finding-card.template.md +32 -0
  87. package/.torusguard/templates/remediation-bundle.template.md +35 -0
  88. package/.torusguard/workflows/apply.md +95 -0
  89. package/.torusguard/workflows/audit.md +93 -0
  90. package/.torusguard/workflows/authorize.md +95 -0
  91. package/.torusguard/workflows/exploit-check.md +97 -0
  92. package/.torusguard/workflows/harden.md +93 -0
  93. package/.torusguard/workflows/init.md +95 -0
  94. package/.torusguard/workflows/recheck.md +95 -0
  95. package/.torusguard/workflows/report.md +95 -0
  96. package/.torusguard/workflows/status.md +95 -0
  97. package/.torusguard/workflows/verify.md +95 -0
  98. package/.torusguard/workflows/web-validate.md +95 -0
  99. package/LICENSE +21 -0
  100. package/README.md +319 -0
  101. package/bin/torusguard.js +110 -0
  102. package/install.py +98 -0
  103. package/package.json +48 -0
  104. package/skills/torusguard/SKILL.md +41 -0
  105. package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
  106. package/skills/torusguard/bootstrap.py +256 -0
  107. package/skills/torusguard/payload/.manifest.json +95 -0
  108. package/skills/torusguard/payload/ARCHITECTURE.md +168 -0
  109. package/skills/torusguard/payload/TORUSGUARD.md +145 -0
  110. package/skills/torusguard/payload/agents/auditor.md +41 -0
  111. package/skills/torusguard/payload/agents/profiler.md +49 -0
  112. package/skills/torusguard/payload/agents/remediator.md +41 -0
  113. package/skills/torusguard/payload/agents/reviewer.md +39 -0
  114. package/skills/torusguard/payload/agents/validator.md +46 -0
  115. package/skills/torusguard/payload/config/scope.json +24 -0
  116. package/skills/torusguard/payload/config/slash-commands.json +102 -0
  117. package/skills/torusguard/payload/config/torusguard.json +30 -0
  118. package/skills/torusguard/payload/references/django-security.md +43 -0
  119. package/skills/torusguard/payload/references/drf-security.md +20 -0
  120. package/skills/torusguard/payload/references/express-security.md +103 -0
  121. package/skills/torusguard/payload/references/fastapi-security.md +20 -0
  122. package/skills/torusguard/payload/references/firebase-security.md +78 -0
  123. package/skills/torusguard/payload/references/flask-security.md +20 -0
  124. package/skills/torusguard/payload/references/nextjs-security.md +96 -0
  125. package/skills/torusguard/payload/references/react-vite-security.md +97 -0
  126. package/skills/torusguard/payload/references/sqlalchemy-security.md +16 -0
  127. package/skills/torusguard/payload/references/supabase-security.md +84 -0
  128. package/skills/torusguard/payload/rules/README.md +62 -0
  129. package/skills/torusguard/payload/rules/TORUSGUARD.md +145 -0
  130. package/skills/torusguard/payload/rules/active/.gitkeep +0 -0
  131. package/skills/torusguard/payload/rules/active/TG-DIFF-001.md +20 -0
  132. package/skills/torusguard/payload/rules/active/TG-DIFF-002.md +20 -0
  133. package/skills/torusguard/payload/rules/active/TG-DIFF-003.md +19 -0
  134. package/skills/torusguard/payload/schemas/authorization.schema.json +81 -0
  135. package/skills/torusguard/payload/schemas/confidence.schema.json +72 -0
  136. package/skills/torusguard/payload/schemas/evidence.schema.json +66 -0
  137. package/skills/torusguard/payload/schemas/finding.schema.json +164 -0
  138. package/skills/torusguard/payload/schemas/provenance.schema.json +46 -0
  139. package/skills/torusguard/payload/schemas/remediation.schema.json +59 -0
  140. package/skills/torusguard/payload/schemas/retest.schema.json +53 -0
  141. package/skills/torusguard/payload/schemas/runtime-evidence.schema.json +72 -0
  142. package/skills/torusguard/payload/scripts/diff_guard.py +171 -0
  143. package/skills/torusguard/payload/scripts/finding_scorer.py +86 -0
  144. package/skills/torusguard/payload/scripts/manifest_builder.py +130 -0
  145. package/skills/torusguard/payload/scripts/monorepo_detector.py +164 -0
  146. package/skills/torusguard/payload/scripts/run_manager.py +89 -0
  147. package/skills/torusguard/payload/scripts/safety_gate.py +64 -0
  148. package/skills/torusguard/payload/scripts/sarif_exporter.py +116 -0
  149. package/skills/torusguard/payload/scripts/stack_detect.py +152 -0
  150. package/skills/torusguard/payload/skills/torusguard/SKILL.md +37 -0
  151. package/skills/torusguard/payload/skills/torusguard/bootstrap.py +158 -0
  152. package/skills/torusguard/payload/skills/torusguard/references/auth-and-sessions.md +56 -0
  153. package/skills/torusguard/payload/skills/torusguard/references/business-logic-and-abuse.md +23 -0
  154. package/skills/torusguard/payload/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
  155. package/skills/torusguard/payload/skills/torusguard/references/client-code-exposure.md +55 -0
  156. package/skills/torusguard/payload/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
  157. package/skills/torusguard/payload/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
  158. package/skills/torusguard/payload/skills/torusguard/references/django-security.md +43 -0
  159. package/skills/torusguard/payload/skills/torusguard/references/drf-security.md +20 -0
  160. package/skills/torusguard/payload/skills/torusguard/references/fastapi-security.md +20 -0
  161. package/skills/torusguard/payload/skills/torusguard/references/flask-security.md +20 -0
  162. package/skills/torusguard/payload/skills/torusguard/references/frontend-no-db.md +53 -0
  163. package/skills/torusguard/payload/skills/torusguard/references/graphql-security.md +12 -0
  164. package/skills/torusguard/payload/skills/torusguard/references/input-and-injection.md +51 -0
  165. package/skills/torusguard/payload/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
  166. package/skills/torusguard/payload/skills/torusguard/references/platform-hardening.md +56 -0
  167. package/skills/torusguard/payload/skills/torusguard/references/python-dependencies.md +16 -0
  168. package/skills/torusguard/payload/skills/torusguard/references/python-security-overview.md +12 -0
  169. package/skills/torusguard/payload/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
  170. package/skills/torusguard/payload/skills/torusguard/references/secrets-and-config.md +64 -0
  171. package/skills/torusguard/payload/skills/torusguard/references/sqlalchemy-security.md +16 -0
  172. package/skills/torusguard/payload/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
  173. package/skills/torusguard/payload/skills/torusguard/references/webhook-security.md +15 -0
  174. package/skills/torusguard/payload/skills/torusguard/references/websocket-security.md +12 -0
  175. package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +46 -0
  176. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +70 -0
  177. package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +47 -0
  178. package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +64 -0
  179. package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +70 -0
  180. package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +63 -0
  181. package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +52 -0
  182. package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +53 -0
  183. package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +54 -0
  184. package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +42 -0
  185. package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +55 -0
  186. package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +64 -0
  187. package/skills/torusguard/payload/templates/audit-report.template.md +54 -0
  188. package/skills/torusguard/payload/templates/authorization.template.md +34 -0
  189. package/skills/torusguard/payload/templates/finding-card.template.md +32 -0
  190. package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -0
  191. package/skills/torusguard/payload/workflows/apply.md +95 -0
  192. package/skills/torusguard/payload/workflows/audit.md +93 -0
  193. package/skills/torusguard/payload/workflows/authorize.md +95 -0
  194. package/skills/torusguard/payload/workflows/exploit-check.md +97 -0
  195. package/skills/torusguard/payload/workflows/harden.md +93 -0
  196. package/skills/torusguard/payload/workflows/init.md +95 -0
  197. package/skills/torusguard/payload/workflows/recheck.md +95 -0
  198. package/skills/torusguard/payload/workflows/report.md +95 -0
  199. package/skills/torusguard/payload/workflows/status.md +95 -0
  200. package/skills/torusguard/payload/workflows/verify.md +95 -0
  201. package/skills/torusguard/payload/workflows/web-validate.md +95 -0
  202. package/skills/torusguard/references/auth-and-sessions.md +56 -0
  203. package/skills/torusguard/references/business-logic-and-abuse.md +23 -0
  204. package/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
  205. package/skills/torusguard/references/client-code-exposure.md +55 -0
  206. package/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
  207. package/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
  208. package/skills/torusguard/references/django-security.md +43 -0
  209. package/skills/torusguard/references/drf-security.md +20 -0
  210. package/skills/torusguard/references/fastapi-security.md +20 -0
  211. package/skills/torusguard/references/flask-security.md +20 -0
  212. package/skills/torusguard/references/frontend-no-db.md +53 -0
  213. package/skills/torusguard/references/graphql-security.md +12 -0
  214. package/skills/torusguard/references/input-and-injection.md +51 -0
  215. package/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
  216. package/skills/torusguard/references/platform-hardening.md +56 -0
  217. package/skills/torusguard/references/python-dependencies.md +16 -0
  218. package/skills/torusguard/references/python-security-overview.md +12 -0
  219. package/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
  220. package/skills/torusguard/references/secrets-and-config.md +64 -0
  221. package/skills/torusguard/references/sqlalchemy-security.md +16 -0
  222. package/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
  223. package/skills/torusguard/references/webhook-security.md +15 -0
  224. package/skills/torusguard/references/websocket-security.md +12 -0
  225. package/skills/torusguard-apply/SKILL.md +46 -0
  226. package/skills/torusguard-audit/SKILL.md +70 -0
  227. package/skills/torusguard-authorize/SKILL.md +47 -0
  228. package/skills/torusguard-exploit-check/SKILL.md +64 -0
  229. package/skills/torusguard-full/SKILL.md +70 -0
  230. package/skills/torusguard-harden/SKILL.md +63 -0
  231. package/skills/torusguard-init/SKILL.md +52 -0
  232. package/skills/torusguard-recheck/SKILL.md +53 -0
  233. package/skills/torusguard-report/SKILL.md +54 -0
  234. package/skills/torusguard-status/SKILL.md +42 -0
  235. package/skills/torusguard-verify/SKILL.md +55 -0
  236. package/skills/torusguard-web-validate/SKILL.md +64 -0
@@ -0,0 +1,145 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # TorusGuard — Master Security Rules & Governance
6
+
7
+ These rules are always active when TorusGuard is installed in the workspace.
8
+ Every security command, every code audit, every runtime probe, and every remediation patch must strictly comply.
9
+
10
+ **Core principle:** If the browser receives it, users can inspect it. Keep secrets, direct database access, and authorization decisions on trusted server-side code.
11
+
12
+ ---
13
+
14
+ ## Step 0 — Security Pre-Flight (Before Everything)
15
+
16
+ Before taking any action or running any `/torusguard` command, enforce this cognitive gate:
17
+
18
+ ### 0a. Scope & Authorization Gate
19
+ ```
20
+ Is the action purely static (read code, analyze ASTs, review configuration)?
21
+ → Permitted without authorization.md.
22
+ Does the action interact with a running application or network endpoint?
23
+ → MANDATORY CHECK: Verify .torusguard/config/scope.json exists and contains:
24
+ - valid target hostname/IP
25
+ - explicit owner_confirmed: true
26
+ - unexpired duration_hours
27
+ → If missing or unconfirmed: HALT. Prompt user to run `/torusguard authorize` first.
28
+ ```
29
+
30
+ ### 0b. Safety & Non-Destruction Gate
31
+ ```
32
+ Is the probe payload destructive (DROP, DELETE, write loops, memory exhaustion)?
33
+ → STRICTLY FORBIDDEN. Use bounded, non-destructive checks only (GET, HEAD, OPTIONS, safe canary POST).
34
+ Does any generated report or captured evidence contain raw API keys, bearer tokens, or database passwords?
35
+ → MANDATORY: Redact to [REDACTED_API_KEY] or sha256 prefix hash. Never write raw credentials to disk.
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Step 1 — Command Routing Table
41
+
42
+ When the user invokes any `/torusguard` slash command, route directly to its workflow:
43
+
44
+ | Command | Lifecycle Phase | Primary Agent | Workflow Path | Modifies Code? |
45
+ | :--- | :--- | :--- | :--- | :---: |
46
+ | `/torusguard init` | Baseline Setup | `profiler` | `.torusguard/workflows/init.md` | ❌ No (Docs/Config only) |
47
+ | `/torusguard authorize` | Legal Scope Gate | `reviewer` | `.torusguard/workflows/authorize.md` | ❌ No |
48
+ | `/torusguard audit` | Detect & Cluster | `auditor` | `.torusguard/workflows/audit.md` | ❌ No |
49
+ | `/torusguard verify` | Verify & Score | `validator` | `.torusguard/workflows/verify.md` | ❌ No |
50
+ | `/torusguard web-validate` | Runtime Probing | `validator` | `.torusguard/workflows/web-validate.md` | ❌ No |
51
+ | `/torusguard exploit-check` | Exploitability | `validator` | `.torusguard/workflows/exploit-check.md` | ❌ No |
52
+ | `/torusguard harden` | Remediate Plan | `remediator` | `.torusguard/workflows/harden.md` | ❌ No (Plan only) |
53
+ | `/torusguard apply` | Governed Apply | `remediator` | `.torusguard/workflows/apply.md` | ✅ Yes (Bounded) |
54
+ | `/torusguard recheck` | Verification | `reviewer` | `.torusguard/workflows/recheck.md` | ❌ No |
55
+ | `/torusguard report` | Export & SARIF | `reviewer` | `.torusguard/workflows/report.md` | ❌ No |
56
+ | `/torusguard status` | Posture Check | *System* | `.torusguard/workflows/status.md` | ❌ No |
57
+
58
+ ---
59
+
60
+ ## Step 2 — Agent Role Routing
61
+
62
+ Every TorusGuard operation activates a specialized role. Each role has strict behavioral boundaries:
63
+
64
+ | Role | Specialist Agent | Domain & Focus | Files / Actions |
65
+ | :--- | :--- | :--- | :--- |
66
+ | **Profiler** | `.torusguard/agents/profiler.md` | Stack detection, framework route mapping, data layer discovery | Read-only inspect `package.json`, `manage.py`, `pyproject.toml` |
67
+ | **Auditor** | `.torusguard/agents/auditor.md` | Static code analysis, rule matching, root-cause clustering | Read-only scan source files, assign stable finding IDs |
68
+ | **Validator** | `.torusguard/agents/validator.md` | Authorized HTTP/browser probes, bounded exploitability confirmation | Execute authorized network probes, capture redacted traces |
69
+ | **Remediator** | `.torusguard/agents/remediator.md` | Remediation bundles, minimal-churn patches, before/after diffs | Generate diffs; apply bounded patches (≤35 add / ≤25 del) |
70
+ | **Reviewer** | `.torusguard/agents/reviewer.md` | Evidence review, regression detection, SARIF export, sign-off | Audit evidence quality, verify recheck results |
71
+
72
+ **Role Announcement Rule:**
73
+ When an agent activates, declare the role:
74
+ ```markdown
75
+ 🛡️ [TorusGuard] Applying knowledge of @[agent-role]...
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Step 3 — Universal Safety & Governance Constraints
81
+
82
+ ### Non-Negotiable Operating Standards
83
+
84
+ 1. **Folder-Per-Run Isolation:**
85
+ - Every operation writes its artifacts into a dedicated folder under `.torusguard/runs/<run-id>/`.
86
+ - Never dump temporary logs, findings, or patches directly into the project root.
87
+ 2. **Patch Governance Limits (Ponytail Protocol):**
88
+ - Maximum lines added per bundle: **35 lines**.
89
+ - Maximum lines deleted per bundle: **25 lines**.
90
+ - If a fix exceeds these limits, break it into smaller atomic bundles or flag as `Requires Manual Architectural Refactor`.
91
+ - Never rewrite an entire file when a targeted edit suffices.
92
+ - Preserve all existing auth checks, tenant isolation, and logging.
93
+ 3. **No Unconfirmed High-Severity Assertions:**
94
+ - Never report a finding as `Confirmed` without an exact AST source code citation or deterministic runtime trace.
95
+ - If a route delegates auth to an internal middleware or domain service, score `< 50` and classify as `Needs Review`.
96
+ 4. **Credential Safety:**
97
+ - Never persist cleartext secrets, bearer tokens, passwords, or connection strings in logs or reports.
98
+ - Sanitize all curl commands and HTTP dumps.
99
+
100
+ ---
101
+
102
+ ## Step 4 — 0–100 Confidence Scoring Rubric
103
+
104
+ TorusGuard scores finding confidence using an objective 5-factor scoring model (Max: 100 pts):
105
+
106
+ | Factor | Max Pts | Criteria |
107
+ | :--- | :---: | :--- |
108
+ | **Evidence Quality** | 35 | Exact AST source match (35) · Regex/Heuristic pattern (20) · Indirect indicator (10) |
109
+ | **Reproduction Success** | 25 | Deterministic test reproduction (25) · Partial reproduction (15) · Static only (0) |
110
+ | **Independent Confirmations** | 15 | Corroborated across 3+ files (15) · 2 files (10) · Single occurrence (5) |
111
+ | **Environmental Clarity** | 15 | Direct code route (15) · Minor layer ambiguity (8) · Complex proxy/lambda unknown (0) |
112
+ | **Manual Review Status** | 10 | Security engineer verified (10) · Agent consensus verified (5) · Unreviewed (0) |
113
+
114
+ **Classification Bands:**
115
+ - `90–100`: 🔒 **`Confirmed`** (Indisputable proof; immediate patch required)
116
+ - `70–89`: 🟢 **`High Confidence`** (Strong indicators; prioritized remediation)
117
+ - `50–69`: 🟡 **`Medium Confidence`** (Probable flaw; runtime confirmation recommended)
118
+ - `< 50`: 🔍 **`Needs Review`** (Architectural ambiguity; requires human confirmation)
119
+
120
+ ---
121
+
122
+ ## Step 5 — Human-First Output Standard
123
+
124
+ Every generated security report must follow the card-style presentation:
125
+
126
+ 1. **Detected Stack Block:**
127
+ ```markdown
128
+ ## Detected Stack
129
+ - Language: Python / TypeScript
130
+ - Framework: FastAPI / Next.js / Django
131
+ - Data layer: SQLAlchemy / Prisma / Supabase
132
+ - Dependency files: pyproject.toml / package.json
133
+ - Detection confidence: Confirmed (manage.py:5)
134
+ ```
135
+ 2. **Executive Posture Indicator:**
136
+ - `🔴 Action Required` (Critical/High findings unmitigated)
137
+ - `🟡 Warnings Found` (Medium findings or unverified boundaries)
138
+ - `🟢 Ready` (All findings verified remediated and rechecked clean)
139
+ 3. **Finding Card Structure:**
140
+ - **Header:** `[TG-RULE-XXX] Title` with Severity & Confidence badges
141
+ - **Provenance Chain:** Discovery Rule → Triggering Input → Decision Path
142
+ - **Raw Evidence:** Exact code excerpt with line numbers and SHA-256 hash
143
+ - **Facts vs Interpretation:** Clearly separate verifiable facts from AI analysis
144
+ - **Remediation Diff:** Framework-native `Before / After` minimal patch
145
+ - **Retest Status:** Verification method and recheck outcome
@@ -0,0 +1,20 @@
1
+ ---
2
+ id: TG-DIFF-001
3
+ name: Accidental Security Check Bypass in Patch
4
+ severity: CRITICAL
5
+ category: Patch Governance / Diff Safety
6
+ cwe: CWE-693
7
+ ---
8
+
9
+ # TG-DIFF-001: Accidental Security Check Bypass in Patch Additions
10
+
11
+ ## Summary
12
+ Flags unified diff additions (`+`) that introduce bypass comments (`# bypass auth`, `// nosec`), disabled certificate checks (`verify=False`), or explicit bypass flags (`skip_auth=True`).
13
+
14
+ ## Detection Invariants
15
+ - Additions containing comments: `bypass auth`, `skip security check`, `disable_token_check`.
16
+ - Additions setting `verify=False` in network HTTP clients.
17
+ - Additions disabling CSRF protection (`@csrf_exempt`).
18
+
19
+ ## Remediation
20
+ Ensure security controls remain active in generated patches. Never disable certificate checks or bypass authentication barriers to make code pass tests.
@@ -0,0 +1,20 @@
1
+ ---
2
+ id: TG-DIFF-002
3
+ name: Secret and Token Ingestion in Patch Additions
4
+ severity: CRITICAL
5
+ category: Patch Governance / Secret Exposure
6
+ cwe: CWE-798
7
+ ---
8
+
9
+ # TG-DIFF-002: Secret and Token Ingestion in Patch Additions
10
+
11
+ ## Summary
12
+ Flags unified diff additions (`+`) that introduce hardcoded live API tokens, JWT strings, private key headers, or credentials into source files during remediation.
13
+
14
+ ## Detection Invariants
15
+ - Additions containing regex patterns matching API keys (`sk_live_`, `ak_live_`).
16
+ - Additions introducing raw Bearer JWT tokens (`eyJ...`).
17
+ - Additions introducing private key blocks (`-----BEGIN PRIVATE KEY-----`).
18
+
19
+ ## Remediation
20
+ Load credentials from environment variables (`os.environ["API_KEY"]` or `process.env.API_KEY`). Never hardcode secrets in remediation diffs.
@@ -0,0 +1,19 @@
1
+ ---
2
+ id: TG-DIFF-003
3
+ name: Unintentional Removal of Tenant Filter in Patch Deletions
4
+ severity: HIGH
5
+ category: Patch Governance / Tenant Isolation
6
+ cwe: CWE-284
7
+ ---
8
+
9
+ # TG-DIFF-003: Unintentional Removal of Tenant Filter in Patch Deletions
10
+
11
+ ## Summary
12
+ Flags unified diff deletions (`-`) where tenant isolation scoping queries (e.g. `.filter(tenant=...)` or `where tenant_id =`) are removed without being reinstated in the corresponding patch additions.
13
+
14
+ ## Detection Invariants
15
+ - Deleted lines matching `.filter(tenant=` or `tenant_id =`.
16
+ - Corresponding added lines omitting equivalent tenant parameter bindings.
17
+
18
+ ## Remediation
19
+ Ensure multi-tenant database queries retain tenant boundary clauses across all refactorings and bug fixes.
@@ -0,0 +1,81 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "TorusGuardAuthorizationScope",
4
+ "description": "Schema for TorusGuard v0.7.0 authorized runtime validation scope and legal boundaries.",
5
+ "type": "object",
6
+ "required": [
7
+ "authorization_id",
8
+ "target_name",
9
+ "authorized_by",
10
+ "target_hosts",
11
+ "allowed_path_prefixes",
12
+ "valid_from",
13
+ "valid_until",
14
+ "max_depth",
15
+ "allow_state_changing_methods"
16
+ ],
17
+ "properties": {
18
+ "authorization_id": {
19
+ "type": "string",
20
+ "pattern": "^AUTH-[A-Za-z0-9_-]+$"
21
+ },
22
+ "target_name": {
23
+ "type": "string"
24
+ },
25
+ "authorized_by": {
26
+ "type": "string"
27
+ },
28
+ "authorization_type": {
29
+ "type": "string",
30
+ "enum": ["target_owner", "written_authorization", "ci_sandboxed_test"]
31
+ },
32
+ "target_hosts": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "string"
36
+ },
37
+ "minItems": 1
38
+ },
39
+ "allowed_path_prefixes": {
40
+ "type": "array",
41
+ "items": {
42
+ "type": "string"
43
+ },
44
+ "minItems": 1
45
+ },
46
+ "forbidden_paths": {
47
+ "type": "array",
48
+ "items": {
49
+ "type": "string"
50
+ }
51
+ },
52
+ "valid_from": {
53
+ "type": "string",
54
+ "format": "date-time"
55
+ },
56
+ "valid_until": {
57
+ "type": "string",
58
+ "format": "date-time"
59
+ },
60
+ "max_depth": {
61
+ "type": "integer",
62
+ "minimum": 1,
63
+ "maximum": 10
64
+ },
65
+ "max_requests": {
66
+ "type": "integer",
67
+ "minimum": 1,
68
+ "maximum": 500
69
+ },
70
+ "allow_state_changing_methods": {
71
+ "type": "boolean"
72
+ },
73
+ "allowed_issue_classes": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "string"
77
+ }
78
+ }
79
+ },
80
+ "additionalProperties": false
81
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://torusguard.dev/schemas/confidence.schema.json",
4
+ "title": "TorusGuardConfidenceScore",
5
+ "description": "Auditable 0-100 confidence scoring rubric and breakdown for TorusGuard v0.5.1 findings.",
6
+ "type": "object",
7
+ "required": [
8
+ "score",
9
+ "band",
10
+ "factors",
11
+ "rationale"
12
+ ],
13
+ "properties": {
14
+ "score": {
15
+ "type": "integer",
16
+ "minimum": 0,
17
+ "maximum": 100,
18
+ "description": "Composite confidence score from 0 to 100."
19
+ },
20
+ "band": {
21
+ "type": "string",
22
+ "enum": ["Confirmed", "High Confidence", "Medium Confidence", "Low Confidence / Unconfirmed"],
23
+ "description": "Classification band derived from score threshold."
24
+ },
25
+ "factors": {
26
+ "type": "object",
27
+ "required": [
28
+ "evidence_quality",
29
+ "reproduction_success",
30
+ "independent_confirmations",
31
+ "environmental_clarity",
32
+ "manual_review_status"
33
+ ],
34
+ "properties": {
35
+ "evidence_quality": {
36
+ "type": "integer",
37
+ "minimum": 0,
38
+ "maximum": 35,
39
+ "description": "Direct source AST / exact snippet vs indirect indication (Max: 35)."
40
+ },
41
+ "reproduction_success": {
42
+ "type": "integer",
43
+ "minimum": 0,
44
+ "maximum": 25,
45
+ "description": "Deterministic reproduction in fixture or local test (Max: 25)."
46
+ },
47
+ "independent_confirmations": {
48
+ "type": "integer",
49
+ "minimum": 0,
50
+ "maximum": 15,
51
+ "description": "Corroboration across multiple manifests/routes (Max: 15)."
52
+ },
53
+ "environmental_clarity": {
54
+ "type": "integer",
55
+ "minimum": 0,
56
+ "maximum": 15,
57
+ "description": "Absence of unverified external service layers or proxies (Max: 15)."
58
+ },
59
+ "manual_review_status": {
60
+ "type": "integer",
61
+ "minimum": 0,
62
+ "maximum": 10,
63
+ "description": "Validation confirmed by human engineer (Max: 10)."
64
+ }
65
+ }
66
+ },
67
+ "rationale": {
68
+ "type": "string",
69
+ "description": "Justification explaining why this confidence score and band were assigned."
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,66 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://torusguard.dev/schemas/evidence.schema.json",
4
+ "title": "TorusGuardEvidencePackage",
5
+ "description": "Structured evidence package schema with raw technical proof, hashes, and provenance for TorusGuard v0.5.1.",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "location",
10
+ "raw_snippet",
11
+ "sha256_checksum",
12
+ "rationale",
13
+ "confidence_level",
14
+ "collected_at"
15
+ ],
16
+ "properties": {
17
+ "type": {
18
+ "type": "string",
19
+ "enum": ["source", "runtime", "test", "manual_review"],
20
+ "description": "Origin and modality of the technical evidence."
21
+ },
22
+ "location": {
23
+ "type": "string",
24
+ "description": "File path, line number range, configuration key, or route endpoint (e.g. app/views.py:45-52)."
25
+ },
26
+ "raw_snippet": {
27
+ "type": "string",
28
+ "description": "Exact, unedited excerpt of the offending source code, configuration, or log."
29
+ },
30
+ "sha256_checksum": {
31
+ "type": "string",
32
+ "pattern": "^[a-f0-9]{64}$",
33
+ "description": "Cryptographic SHA-256 hash of the raw evidence snippet for audit integrity."
34
+ },
35
+ "collected_at": {
36
+ "type": "string",
37
+ "format": "date-time",
38
+ "description": "Timestamp when this evidence was extracted."
39
+ },
40
+ "context": {
41
+ "type": "string",
42
+ "description": "Surrounding architectural context (e.g. within unauthenticated route handler)."
43
+ },
44
+ "rationale": {
45
+ "type": "string",
46
+ "description": "Technical justification explaining why this code snippet proves the vulnerability."
47
+ },
48
+ "confidence_level": {
49
+ "type": "string",
50
+ "enum": ["Confirmed", "High Confidence", "Medium Confidence", "Low Confidence", "Needs Review", "Informational"],
51
+ "description": "Confidence assessment derived solely from this evidence artifact."
52
+ },
53
+ "reproduction_notes": {
54
+ "type": "string",
55
+ "description": "Specific inputs or conditions required to trigger the issue."
56
+ },
57
+ "reviewer_notes": {
58
+ "type": "string",
59
+ "description": "Human or AI security reviewer annotations."
60
+ },
61
+ "is_sufficient_for_confirmed": {
62
+ "type": "boolean",
63
+ "description": "True only if direct unmitigated vulnerability is proven without external assumptions."
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,164 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://torusguard.dev/schemas/finding.schema.json",
4
+ "title": "TorusGuardCanonicalFinding",
5
+ "description": "Canonical normalized finding object schema for TorusGuard v0.5.1 with provenance and auditable confidence scoring.",
6
+ "type": "object",
7
+ "required": [
8
+ "finding_id",
9
+ "rule_id",
10
+ "title",
11
+ "category",
12
+ "severity",
13
+ "confidence",
14
+ "status",
15
+ "affected_component",
16
+ "evidence",
17
+ "provenance",
18
+ "reproduction_method",
19
+ "remediation",
20
+ "retest_result",
21
+ "timestamps"
22
+ ],
23
+ "properties": {
24
+ "finding_id": {
25
+ "type": "string",
26
+ "pattern": "^TG-FIND-[0-9]{4}-[a-f0-9]{4,12}$",
27
+ "description": "Unique canonical identifier for this finding instance."
28
+ },
29
+ "rule_id": {
30
+ "type": "string",
31
+ "pattern": "^TG-[A-Z0-9]+-[0-9]{3}$",
32
+ "description": "Canonical TorusGuard Rule ID (e.g. TG-AUTH-007, TG-SEC-001)."
33
+ },
34
+ "title": {
35
+ "type": "string",
36
+ "description": "Concise, human-readable finding title."
37
+ },
38
+ "category": {
39
+ "type": "string",
40
+ "enum": [
41
+ "authentication-authorization",
42
+ "input-validation-encoding",
43
+ "data-access-orm",
44
+ "file-upload-handling",
45
+ "secrets-configuration",
46
+ "dependency-supply-chain",
47
+ "network-ssrf-boundaries",
48
+ "business-logic-rate-limiting",
49
+ "client-cache-platform"
50
+ ],
51
+ "description": "Normalized lifecycle taxonomy category."
52
+ },
53
+ "severity": {
54
+ "type": "object",
55
+ "required": ["level", "rationale", "rubric_justification"],
56
+ "properties": {
57
+ "level": {
58
+ "type": "string",
59
+ "enum": ["Critical", "High", "Medium", "Low", "Informational"]
60
+ },
61
+ "rationale": {
62
+ "type": "string",
63
+ "description": "Justification for assigned severity level."
64
+ },
65
+ "rubric_justification": {
66
+ "type": "string",
67
+ "description": "Explicit reason why this finding is not a higher or lower severity."
68
+ }
69
+ }
70
+ },
71
+ "confidence": {
72
+ "$ref": "confidence.schema.json"
73
+ },
74
+ "status": {
75
+ "type": "string",
76
+ "enum": [
77
+ "Confirmed",
78
+ "High Confidence",
79
+ "Medium Confidence",
80
+ "Low Confidence",
81
+ "Unconfirmed",
82
+ "Needs Review",
83
+ "Remediated",
84
+ "Verified Fixed"
85
+ ],
86
+ "description": "Standardized operational verification status."
87
+ },
88
+ "affected_component": {
89
+ "type": "object",
90
+ "required": ["component_name", "target_path"],
91
+ "properties": {
92
+ "component_name": { "type": "string" },
93
+ "target_path": { "type": "string" },
94
+ "start_line": { "type": "integer" },
95
+ "end_line": { "type": "integer" },
96
+ "symbol": { "type": "string" }
97
+ }
98
+ },
99
+ "evidence": {
100
+ "type": "array",
101
+ "minItems": 1,
102
+ "items": { "$ref": "evidence.schema.json" }
103
+ },
104
+ "provenance": {
105
+ "$ref": "provenance.schema.json"
106
+ },
107
+ "reproduction_method": {
108
+ "type": "object",
109
+ "required": ["step_by_step", "deterministic"],
110
+ "properties": {
111
+ "step_by_step": {
112
+ "type": "array",
113
+ "items": { "type": "string" }
114
+ },
115
+ "test_command": { "type": "string" },
116
+ "deterministic": { "type": "boolean" },
117
+ "expected_failure_response": { "type": "string" }
118
+ }
119
+ },
120
+ "remediation": {
121
+ "$ref": "remediation.schema.json"
122
+ },
123
+ "retest_result": {
124
+ "$ref": "retest.schema.json"
125
+ },
126
+ "requirement_reference": {
127
+ "type": "object",
128
+ "properties": {
129
+ "asvs_v4": { "type": "string" },
130
+ "nist_ssdf": { "type": "string" },
131
+ "owasp_top10": { "type": "string" }
132
+ }
133
+ },
134
+ "cwe": {
135
+ "type": "string",
136
+ "pattern": "^CWE-[0-9]{1,5}$"
137
+ },
138
+ "timestamps": {
139
+ "type": "object",
140
+ "required": ["discovered_at", "updated_at"],
141
+ "properties": {
142
+ "discovered_at": { "type": "string", "format": "date-time" },
143
+ "verified_at": { "type": "string", "format": "date-time" },
144
+ "remediated_at": { "type": "string", "format": "date-time" },
145
+ "retested_at": { "type": "string", "format": "date-time" },
146
+ "updated_at": { "type": "string", "format": "date-time" }
147
+ }
148
+ },
149
+ "notes": {
150
+ "type": "object",
151
+ "required": ["raw_facts_summary", "ai_interpretation"],
152
+ "properties": {
153
+ "raw_facts_summary": {
154
+ "type": "string",
155
+ "description": "Objective, unembellished summary of verified code facts."
156
+ },
157
+ "ai_interpretation": {
158
+ "type": "string",
159
+ "description": "AI-generated risk analysis and contextual reasoning."
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://torusguard.dev/schemas/provenance.schema.json",
4
+ "title": "TorusGuardProvenanceChain",
5
+ "description": "Structured provenance chain tracking discovery and decision path for TorusGuard v0.5.1 findings.",
6
+ "type": "object",
7
+ "required": [
8
+ "discovery_module",
9
+ "triggering_input",
10
+ "evidence_collected",
11
+ "decision_path",
12
+ "verification_step"
13
+ ],
14
+ "properties": {
15
+ "discovery_module": {
16
+ "type": "string",
17
+ "description": "Module or rule that initiated the detection (e.g. rules/authorization/TG-AUTH-007)."
18
+ },
19
+ "triggering_input": {
20
+ "type": "string",
21
+ "description": "The specific input, AST node, manifest line, or configuration key that triggered detection."
22
+ },
23
+ "evidence_collected": {
24
+ "type": "array",
25
+ "items": { "type": "string" },
26
+ "description": "List of evidence identifiers or file locations gathered during discovery."
27
+ },
28
+ "decision_path": {
29
+ "type": "array",
30
+ "items": { "type": "string" },
31
+ "description": "Ordered sequence of logical evaluation steps leading to the finding classification."
32
+ },
33
+ "verification_step": {
34
+ "type": "string",
35
+ "description": "Verification method used to confirm or refute the finding."
36
+ },
37
+ "agent_environment": {
38
+ "type": "string",
39
+ "description": "Runtime context (e.g. TorusGuard Engine v0.5.1 on Python 3.11)."
40
+ },
41
+ "timestamp": {
42
+ "type": "string",
43
+ "format": "date-time"
44
+ }
45
+ }
46
+ }