torusguard 1.3.3 → 1.3.5

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 (322) hide show
  1. package/.torusguard/.manifest.json +66 -63
  2. package/.torusguard/rules/business-logic/TG-BIZ-001-client-controlled-sensitive-business-value.md +30 -14
  3. package/.torusguard/rules/business-logic/TG-BIZ-002-replayable-one-time-operation.md +33 -16
  4. package/.torusguard/rules/business-logic/TG-BIZ-003-missing-workflow-state-validation.md +31 -15
  5. package/.torusguard/rules/business-logic/TG-BIZ-004-unrestricted-sensitive-business-flow.md +26 -16
  6. package/.torusguard/rules/cache/TG-CACHE-001-sensitive-response-publicly-cacheable.md +24 -16
  7. package/.torusguard/rules/cache/TG-CACHE-002-missing-user-cache-isolation.md +32 -18
  8. package/.torusguard/rules/cache/TG-CACHE-003-sensitive-data-in-url.md +24 -17
  9. package/.torusguard/rules/csrf/TG-CSRF-001-missing-csrf-protection.md +31 -18
  10. package/.torusguard/rules/csrf/TG-CSRF-002-unsafe-credentialed-cross-origin-request.md +28 -17
  11. package/.torusguard/rules/graphql/TG-GQL-002-resolver-missing-authorization.md +33 -17
  12. package/.torusguard/rules/graphql/TG-GQL-003-unbounded-graphql-pagination-or-batching.md +31 -16
  13. package/.torusguard/rules/graphql/TG-GQL-004-unnecessary-production-introspection.md +25 -16
  14. package/.torusguard/rules/secrets/TG-SEC-005-secret-in-git-history.md +24 -19
  15. package/.torusguard/rules/secrets/TG-SEC-006-secret-in-build-artifact.md +36 -19
  16. package/.torusguard/rules/secrets/TG-SEC-007-secret-in-test-or-example-fixture.md +21 -16
  17. package/.torusguard/rules/ssrf/TG-SSRF-002-missing-internal-network-protection.md +45 -18
  18. package/.torusguard/rules/ssrf/TG-SSRF-003-unsafe-redirect-following.md +20 -16
  19. package/.torusguard/rules/ssrf/TG-SSRF-004-unbounded-outbound-request.md +28 -19
  20. package/.torusguard/rules/supply-chain/TG-SUPPLY-001-missing-or-ignored-dependency-lockfile.md +25 -18
  21. package/.torusguard/rules/supply-chain/TG-SUPPLY-003-unsafe-ci-cd-secret-exposure.md +29 -19
  22. package/.torusguard/rules/supply-chain/TG-SUPPLY-004-unpinned-ci-action.md +23 -18
  23. package/.torusguard/rules/supply-chain/TG-SUPPLY-005-unsafe-dependency-install-script.md +23 -18
  24. package/.torusguard/rules/webhook/TG-WEBHOOK-001-missing-webhook-signature-verification.md +36 -16
  25. package/.torusguard/rules/webhook/TG-WEBHOOK-002-replayable-webhook.md +26 -17
  26. package/.torusguard/rules/webhook/TG-WEBHOOK-003-missing-webhook-idempotency.md +30 -16
  27. package/.torusguard/rules/webhook/TG-WEBHOOK-004-unvalidated-webhook-event-type.md +25 -16
  28. package/.torusguard/rules/websocket/TG-WS-002-missing-channel-level-authorization.md +28 -17
  29. package/.torusguard/rules/websocket/TG-WS-003-unvalidated-websocket-message.md +31 -17
  30. package/.torusguard/rules/websocket/TG-WS-004-unbounded-websocket-connections.md +31 -17
  31. package/.torusguard/rules_catalog.json +520 -0
  32. package/.torusguard/runs/report-latest.html +93 -7
  33. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-115-9a059e/metadata.json +15 -0
  34. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-115-9a059e/minimal_patch_plan.md +21 -0
  35. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-115-9a059e/patch.diff +9 -0
  36. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-119-61557c/metadata.json +15 -0
  37. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-119-61557c/minimal_patch_plan.md +21 -0
  38. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-119-61557c/patch.diff +9 -0
  39. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-265-996ca3/metadata.json +15 -0
  40. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-265-996ca3/minimal_patch_plan.md +21 -0
  41. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-265-996ca3/patch.diff +9 -0
  42. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-503-d11cf8/metadata.json +15 -0
  43. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-503-d11cf8/minimal_patch_plan.md +21 -0
  44. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-503-d11cf8/patch.diff +9 -0
  45. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-79-91f41f/metadata.json +15 -0
  46. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-79-91f41f/minimal_patch_plan.md +21 -0
  47. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-db-004-79-91f41f/patch.diff +9 -0
  48. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-107-516a40/metadata.json +15 -0
  49. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-107-516a40/minimal_patch_plan.md +21 -0
  50. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-107-516a40/patch.diff +9 -0
  51. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-128-7809a1/metadata.json +15 -0
  52. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-128-7809a1/minimal_patch_plan.md +21 -0
  53. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-128-7809a1/patch.diff +9 -0
  54. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-256-c8a22e/metadata.json +15 -0
  55. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-256-c8a22e/minimal_patch_plan.md +21 -0
  56. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-002-256-c8a22e/patch.diff +9 -0
  57. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-003-53-d167b4/metadata.json +15 -0
  58. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-003-53-d167b4/minimal_patch_plan.md +21 -0
  59. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-input-003-53-d167b4/patch.diff +9 -0
  60. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-platform-001-183-47fd5e/metadata.json +15 -0
  61. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-platform-001-183-47fd5e/minimal_patch_plan.md +21 -0
  62. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-platform-001-183-47fd5e/patch.diff +9 -0
  63. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-209-4f6424/metadata.json +15 -0
  64. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-209-4f6424/minimal_patch_plan.md +21 -0
  65. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-209-4f6424/patch.diff +9 -0
  66. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-257-89bf34/metadata.json +15 -0
  67. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-257-89bf34/minimal_patch_plan.md +21 -0
  68. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-257-89bf34/patch.diff +9 -0
  69. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-341-ce228c/metadata.json +15 -0
  70. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-341-ce228c/minimal_patch_plan.md +21 -0
  71. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-341-ce228c/patch.diff +9 -0
  72. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-355-7b190b/metadata.json +15 -0
  73. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-355-7b190b/minimal_patch_plan.md +21 -0
  74. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-355-7b190b/patch.diff +9 -0
  75. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-64-5af31a/metadata.json +15 -0
  76. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-64-5af31a/minimal_patch_plan.md +21 -0
  77. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-64-5af31a/patch.diff +9 -0
  78. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-9-f51467/metadata.json +15 -0
  79. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-9-f51467/minimal_patch_plan.md +21 -0
  80. package/.torusguard/runs/run-20260910-120238-audit/bundles/bnd-tg-sec-001-9-f51467/patch.diff +9 -0
  81. package/.torusguard/runs/run-20260910-120238-audit/findings.json +1520 -0
  82. package/.torusguard/runs/run-20260910-120238-audit/findings.md +560 -0
  83. package/.torusguard/runs/run-20260910-120238-audit/manifest.json +13 -0
  84. package/.torusguard/runs/run-20260910-120238-audit/recheck.md +86 -0
  85. package/.torusguard/runs/run-20260910-120238-audit/remediation.md +262 -0
  86. package/.torusguard/runs/run-20260910-120238-audit/summary.md +5 -0
  87. package/.torusguard/runs/run-20260910-121238-audit/findings.json +794 -0
  88. package/.torusguard/runs/run-20260910-121238-audit/findings.md +344 -0
  89. package/.torusguard/runs/run-20260910-121238-audit/manifest.json +12 -0
  90. package/.torusguard/runs/run-20260910-121238-audit/summary.md +5 -0
  91. package/.torusguard/runs/run-20260910-130454-audit/findings.json +893 -0
  92. package/.torusguard/runs/run-20260910-130454-audit/findings.md +386 -0
  93. package/.torusguard/runs/run-20260910-130454-audit/manifest.json +12 -0
  94. package/.torusguard/runs/run-20260910-130454-audit/summary.md +5 -0
  95. package/.torusguard/runs/run-20260910-130519-audit/findings.json +563 -0
  96. package/.torusguard/runs/run-20260910-130519-audit/findings.md +246 -0
  97. package/.torusguard/runs/run-20260910-130519-audit/manifest.json +12 -0
  98. package/.torusguard/runs/run-20260910-130519-audit/summary.md +5 -0
  99. package/.torusguard/runs/run-20260912-214110-audit/findings.json +1256 -0
  100. package/.torusguard/runs/run-20260912-214110-audit/findings.md +534 -0
  101. package/.torusguard/runs/run-20260912-214110-audit/manifest.json +12 -0
  102. package/.torusguard/runs/run-20260912-214110-audit/summary.md +5 -0
  103. package/.torusguard/runs/run-20260912-214813-audit/findings.json +992 -0
  104. package/.torusguard/runs/run-20260912-214813-audit/findings.md +422 -0
  105. package/.torusguard/runs/run-20260912-214813-audit/manifest.json +12 -0
  106. package/.torusguard/runs/run-20260912-214813-audit/summary.md +5 -0
  107. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-auth-003-49-7c96f3/metadata.json +17 -0
  108. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-auth-003-49-7c96f3/minimal_patch_plan.md +21 -0
  109. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-auth-003-49-7c96f3/patch.diff +9 -0
  110. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-input-003-53-d167b4/metadata.json +17 -0
  111. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-input-003-53-d167b4/minimal_patch_plan.md +21 -0
  112. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-input-003-53-d167b4/patch.diff +9 -0
  113. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-platform-001-12-cf8156/metadata.json +17 -0
  114. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-platform-001-12-cf8156/minimal_patch_plan.md +21 -0
  115. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-platform-001-12-cf8156/patch.diff +9 -0
  116. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-rate-001-26-affcfa/metadata.json +17 -0
  117. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-rate-001-26-affcfa/minimal_patch_plan.md +21 -0
  118. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-rate-001-26-affcfa/patch.diff +9 -0
  119. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-sec-001-9-e22e50/metadata.json +17 -0
  120. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-sec-001-9-e22e50/minimal_patch_plan.md +21 -0
  121. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-sec-001-9-e22e50/patch.diff +9 -0
  122. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-ssrf-004-9-9803ad/metadata.json +17 -0
  123. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-ssrf-004-9-9803ad/minimal_patch_plan.md +21 -0
  124. package/.torusguard/runs/run-20260912-215555-audit/bundles/bnd-tg-ssrf-004-9-9803ad/patch.diff +9 -0
  125. package/.torusguard/runs/run-20260912-215555-audit/findings.json +530 -0
  126. package/.torusguard/runs/run-20260912-215555-audit/findings.md +232 -0
  127. package/.torusguard/runs/run-20260912-215555-audit/manifest.json +13 -0
  128. package/.torusguard/runs/run-20260912-215555-audit/remediation.md +102 -0
  129. package/.torusguard/runs/run-20260912-215555-audit/summary.md +5 -0
  130. package/.torusguard/runs/run-20260912-215731-audit/apply_plan.md +6 -0
  131. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-client-001-7-587129/metadata.json +17 -0
  132. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-client-001-7-587129/minimal_patch_plan.md +21 -0
  133. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-client-001-7-587129/patch.diff +9 -0
  134. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-db-002-9-5f7850/metadata.json +17 -0
  135. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-db-002-9-5f7850/minimal_patch_plan.md +21 -0
  136. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-db-002-9-5f7850/patch.diff +9 -0
  137. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-input-001-27-2486f1/metadata.json +17 -0
  138. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-input-001-27-2486f1/minimal_patch_plan.md +22 -0
  139. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-input-001-27-2486f1/patch.diff +10 -0
  140. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-input-003-53-d167b4/metadata.json +17 -0
  141. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-input-003-53-d167b4/minimal_patch_plan.md +21 -0
  142. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-input-003-53-d167b4/patch.diff +9 -0
  143. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-001-12-cf8156/metadata.json +17 -0
  144. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-001-12-cf8156/minimal_patch_plan.md +21 -0
  145. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-001-12-cf8156/patch.diff +9 -0
  146. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-002-17-876973/metadata.json +17 -0
  147. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-002-17-876973/minimal_patch_plan.md +23 -0
  148. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-002-17-876973/patch.diff +11 -0
  149. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-002-5-40c794/metadata.json +17 -0
  150. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-002-5-40c794/minimal_patch_plan.md +23 -0
  151. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-platform-002-5-40c794/patch.diff +11 -0
  152. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-rate-001-26-affcfa/metadata.json +17 -0
  153. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-rate-001-26-affcfa/minimal_patch_plan.md +21 -0
  154. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-rate-001-26-affcfa/patch.diff +9 -0
  155. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-rate-002-54-0b38d2/metadata.json +17 -0
  156. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-rate-002-54-0b38d2/minimal_patch_plan.md +21 -0
  157. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-rate-002-54-0b38d2/patch.diff +9 -0
  158. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-001-18-a3c1e8/metadata.json +17 -0
  159. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-001-18-a3c1e8/minimal_patch_plan.md +21 -0
  160. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-001-18-a3c1e8/patch.diff +9 -0
  161. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-001-9-e22e50/metadata.json +17 -0
  162. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-001-9-e22e50/minimal_patch_plan.md +21 -0
  163. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-001-9-e22e50/patch.diff +9 -0
  164. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-004-28-a1a0a1/metadata.json +17 -0
  165. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-004-28-a1a0a1/minimal_patch_plan.md +21 -0
  166. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-004-28-a1a0a1/patch.diff +9 -0
  167. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-004-30-00569e/metadata.json +17 -0
  168. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-004-30-00569e/minimal_patch_plan.md +21 -0
  169. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-sec-004-30-00569e/patch.diff +9 -0
  170. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-ssrf-004-9-9803ad/metadata.json +17 -0
  171. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-ssrf-004-9-9803ad/minimal_patch_plan.md +21 -0
  172. package/.torusguard/runs/run-20260912-215731-audit/bundles/bnd-tg-ssrf-004-9-9803ad/patch.diff +9 -0
  173. package/.torusguard/runs/run-20260912-215731-audit/diff_summary.md +186 -0
  174. package/.torusguard/runs/run-20260912-215731-audit/findings.json +497 -0
  175. package/.torusguard/runs/run-20260912-215731-audit/findings.md +218 -0
  176. package/.torusguard/runs/run-20260912-215731-audit/manifest.json +14 -0
  177. package/.torusguard/runs/run-20260912-215731-audit/recheck.md +76 -0
  178. package/.torusguard/runs/run-20260912-215731-audit/remediation.md +234 -0
  179. package/.torusguard/runs/run-20260912-215731-audit/summary.md +5 -0
  180. package/.torusguard/runs/run-20260912-220134-audit/findings.json +68 -0
  181. package/.torusguard/runs/run-20260912-220134-audit/findings.md +36 -0
  182. package/.torusguard/runs/run-20260912-220134-audit/manifest.json +12 -0
  183. package/.torusguard/runs/run-20260912-220134-audit/summary.md +5 -0
  184. package/.torusguard/runs/run-20260912-220200-audit/findings.json +1 -0
  185. package/.torusguard/runs/run-20260912-220200-audit/findings.md +8 -0
  186. package/.torusguard/runs/run-20260912-220200-audit/manifest.json +12 -0
  187. package/.torusguard/runs/run-20260912-220200-audit/recheck.md +6 -0
  188. package/.torusguard/runs/run-20260912-220200-audit/summary.md +5 -0
  189. package/.torusguard/runs/run-20260912-220227-audit/findings.json +1 -0
  190. package/.torusguard/runs/run-20260912-220227-audit/findings.md +8 -0
  191. package/.torusguard/runs/run-20260912-220227-audit/manifest.json +12 -0
  192. package/.torusguard/runs/run-20260912-220227-audit/recheck.md +6 -0
  193. package/.torusguard/runs/run-20260912-220227-audit/summary.md +5 -0
  194. package/.torusguard/scripts/__pycache__/audit_runner.cpython-311.pyc +0 -0
  195. package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
  196. package/.torusguard/scripts/__pycache__/finding_scorer.cpython-311.pyc +0 -0
  197. package/.torusguard/scripts/__pycache__/html_reporter.cpython-311.pyc +0 -0
  198. package/.torusguard/scripts/__pycache__/report_sync.cpython-311.pyc +0 -0
  199. package/.torusguard/scripts/__pycache__/rules_sync.cpython-311.pyc +0 -0
  200. package/.torusguard/scripts/__pycache__/stack_detect.cpython-311.pyc +0 -0
  201. package/.torusguard/scripts/__pycache__/term_ui.cpython-311.pyc +0 -0
  202. package/.torusguard/scripts/apply_runner.py +383 -339
  203. package/.torusguard/scripts/audit_runner.py +1306 -550
  204. package/.torusguard/scripts/finding_scorer.py +14 -2
  205. package/.torusguard/scripts/harden_runner.py +628 -375
  206. package/.torusguard/scripts/recheck_runner.py +248 -221
  207. package/.torusguard/scripts/recipes_runner.py +137 -130
  208. package/.torusguard/scripts/report_sync.py +423 -0
  209. package/.torusguard/scripts/sarif_exporter.py +116 -116
  210. package/.torusguard/scripts/term_ui.py +162 -0
  211. package/.torusguard/skills/torusguard/SKILL.md +61 -31
  212. package/.torusguard/skills/torusguard-apply/SKILL.md +80 -46
  213. package/.torusguard/skills/torusguard-audit/SKILL.md +83 -70
  214. package/.torusguard/skills/torusguard-authorize/SKILL.md +5 -4
  215. package/.torusguard/skills/torusguard-exploit-check/SKILL.md +6 -5
  216. package/.torusguard/skills/torusguard-full/SKILL.md +1 -1
  217. package/.torusguard/skills/torusguard-harden/SKILL.md +94 -63
  218. package/.torusguard/skills/torusguard-init/SKILL.md +64 -52
  219. package/.torusguard/skills/torusguard-recheck/SKILL.md +77 -53
  220. package/.torusguard/skills/torusguard-report/SKILL.md +72 -54
  221. package/.torusguard/skills/torusguard-status/SKILL.md +58 -42
  222. package/.torusguard/skills/torusguard-verify/SKILL.md +8 -7
  223. package/.torusguard/skills/torusguard-web-validate/SKILL.md +8 -7
  224. package/.torusguard/snapshots/run-20260912-215731-audit/demo/playground/vulnerable_nextjs/actions.ts.bak +24 -0
  225. package/.torusguard/snapshots/run-20260912-215731-audit/examples/hardened-react-express/server/index.js.bak +121 -0
  226. package/.torusguard/snapshots/run-20260912-215731-audit/examples/python/fastapi-vuln/main.py.bak +20 -0
  227. package/.torusguard/snapshots/run-20260912-215731-audit/examples/vulnerable-react-express/client/src/App.jsx.bak +63 -0
  228. package/.torusguard/snapshots/run-20260912-215731-audit/examples/vulnerable-react-express/client/vite.config.js.bak +12 -0
  229. package/.torusguard/snapshots/run-20260912-215731-audit/examples/vulnerable-react-express/server/index.js.bak +82 -0
  230. package/.torusguard/workflows/apply.md +11 -4
  231. package/.torusguard/workflows/audit.md +7 -1
  232. package/.torusguard/workflows/authorize.md +2 -1
  233. package/.torusguard/workflows/exploit-check.md +2 -1
  234. package/.torusguard/workflows/harden.md +7 -1
  235. package/.torusguard/workflows/init.md +6 -1
  236. package/.torusguard/workflows/memory.md +2 -1
  237. package/.torusguard/workflows/recheck.md +7 -1
  238. package/.torusguard/workflows/report.md +7 -1
  239. package/.torusguard/workflows/status.md +6 -1
  240. package/.torusguard/workflows/verify.md +6 -1
  241. package/.torusguard/workflows/web-validate.md +2 -1
  242. package/README.md +470 -344
  243. package/bin/torusguard.js +209 -97
  244. package/package.json +1 -1
  245. package/skills/torusguard/SKILL.md +73 -42
  246. package/skills/torusguard/payload/.manifest.json +66 -63
  247. package/skills/torusguard/payload/rules/business-logic/TG-BIZ-001-client-controlled-sensitive-business-value.md +30 -14
  248. package/skills/torusguard/payload/rules/business-logic/TG-BIZ-002-replayable-one-time-operation.md +33 -16
  249. package/skills/torusguard/payload/rules/business-logic/TG-BIZ-003-missing-workflow-state-validation.md +31 -15
  250. package/skills/torusguard/payload/rules/business-logic/TG-BIZ-004-unrestricted-sensitive-business-flow.md +26 -16
  251. package/skills/torusguard/payload/rules/cache/TG-CACHE-001-sensitive-response-publicly-cacheable.md +24 -16
  252. package/skills/torusguard/payload/rules/cache/TG-CACHE-002-missing-user-cache-isolation.md +32 -18
  253. package/skills/torusguard/payload/rules/cache/TG-CACHE-003-sensitive-data-in-url.md +24 -17
  254. package/skills/torusguard/payload/rules/csrf/TG-CSRF-001-missing-csrf-protection.md +31 -18
  255. package/skills/torusguard/payload/rules/csrf/TG-CSRF-002-unsafe-credentialed-cross-origin-request.md +28 -17
  256. package/skills/torusguard/payload/rules/graphql/TG-GQL-002-resolver-missing-authorization.md +33 -17
  257. package/skills/torusguard/payload/rules/graphql/TG-GQL-003-unbounded-graphql-pagination-or-batching.md +31 -16
  258. package/skills/torusguard/payload/rules/graphql/TG-GQL-004-unnecessary-production-introspection.md +25 -16
  259. package/skills/torusguard/payload/rules/secrets/TG-SEC-005-secret-in-git-history.md +24 -19
  260. package/skills/torusguard/payload/rules/secrets/TG-SEC-006-secret-in-build-artifact.md +36 -19
  261. package/skills/torusguard/payload/rules/secrets/TG-SEC-007-secret-in-test-or-example-fixture.md +21 -16
  262. package/skills/torusguard/payload/rules/ssrf/TG-SSRF-002-missing-internal-network-protection.md +45 -18
  263. package/skills/torusguard/payload/rules/ssrf/TG-SSRF-003-unsafe-redirect-following.md +20 -16
  264. package/skills/torusguard/payload/rules/ssrf/TG-SSRF-004-unbounded-outbound-request.md +28 -19
  265. package/skills/torusguard/payload/rules/supply-chain/TG-SUPPLY-001-missing-or-ignored-dependency-lockfile.md +25 -18
  266. package/skills/torusguard/payload/rules/supply-chain/TG-SUPPLY-003-unsafe-ci-cd-secret-exposure.md +29 -19
  267. package/skills/torusguard/payload/rules/supply-chain/TG-SUPPLY-004-unpinned-ci-action.md +23 -18
  268. package/skills/torusguard/payload/rules/supply-chain/TG-SUPPLY-005-unsafe-dependency-install-script.md +23 -18
  269. package/skills/torusguard/payload/rules/webhook/TG-WEBHOOK-001-missing-webhook-signature-verification.md +36 -16
  270. package/skills/torusguard/payload/rules/webhook/TG-WEBHOOK-002-replayable-webhook.md +26 -17
  271. package/skills/torusguard/payload/rules/webhook/TG-WEBHOOK-003-missing-webhook-idempotency.md +30 -16
  272. package/skills/torusguard/payload/rules/webhook/TG-WEBHOOK-004-unvalidated-webhook-event-type.md +25 -16
  273. package/skills/torusguard/payload/rules/websocket/TG-WS-002-missing-channel-level-authorization.md +28 -17
  274. package/skills/torusguard/payload/rules/websocket/TG-WS-003-unvalidated-websocket-message.md +31 -17
  275. package/skills/torusguard/payload/rules/websocket/TG-WS-004-unbounded-websocket-connections.md +31 -17
  276. package/skills/torusguard/payload/rules_catalog.json +520 -0
  277. package/skills/torusguard/payload/scripts/apply_runner.py +383 -339
  278. package/skills/torusguard/payload/scripts/audit_runner.py +1306 -550
  279. package/skills/torusguard/payload/scripts/finding_scorer.py +14 -2
  280. package/skills/torusguard/payload/scripts/harden_runner.py +628 -375
  281. package/skills/torusguard/payload/scripts/recheck_runner.py +248 -221
  282. package/skills/torusguard/payload/scripts/recipes_runner.py +137 -130
  283. package/skills/torusguard/payload/scripts/report_sync.py +423 -0
  284. package/skills/torusguard/payload/scripts/sarif_exporter.py +116 -116
  285. package/skills/torusguard/payload/scripts/term_ui.py +162 -0
  286. package/skills/torusguard/payload/skills/torusguard/SKILL.md +75 -42
  287. package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +63 -25
  288. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +62 -45
  289. package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +11 -5
  290. package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +12 -6
  291. package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +7 -2
  292. package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +71 -36
  293. package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +45 -29
  294. package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +59 -31
  295. package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +52 -30
  296. package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +40 -20
  297. package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +14 -8
  298. package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +14 -8
  299. package/skills/torusguard/payload/workflows/apply.md +11 -4
  300. package/skills/torusguard/payload/workflows/audit.md +7 -1
  301. package/skills/torusguard/payload/workflows/authorize.md +2 -1
  302. package/skills/torusguard/payload/workflows/exploit-check.md +2 -1
  303. package/skills/torusguard/payload/workflows/harden.md +7 -1
  304. package/skills/torusguard/payload/workflows/init.md +6 -1
  305. package/skills/torusguard/payload/workflows/memory.md +2 -1
  306. package/skills/torusguard/payload/workflows/recheck.md +7 -1
  307. package/skills/torusguard/payload/workflows/report.md +7 -1
  308. package/skills/torusguard/payload/workflows/status.md +6 -1
  309. package/skills/torusguard/payload/workflows/verify.md +6 -1
  310. package/skills/torusguard/payload/workflows/web-validate.md +2 -1
  311. package/skills/torusguard-apply/SKILL.md +63 -27
  312. package/skills/torusguard-audit/SKILL.md +62 -50
  313. package/skills/torusguard-authorize/SKILL.md +7 -2
  314. package/skills/torusguard-exploit-check/SKILL.md +7 -2
  315. package/skills/torusguard-full/SKILL.md +7 -2
  316. package/skills/torusguard-harden/SKILL.md +71 -40
  317. package/skills/torusguard-init/SKILL.md +45 -30
  318. package/skills/torusguard-recheck/SKILL.md +59 -32
  319. package/skills/torusguard-report/SKILL.md +52 -31
  320. package/skills/torusguard-status/SKILL.md +40 -21
  321. package/skills/torusguard-verify/SKILL.md +7 -2
  322. package/skills/torusguard-web-validate/SKILL.md +7 -2
package/README.md CHANGED
@@ -1,344 +1,470 @@
1
- <div align="center">
2
- <img src="https://raw.githubusercontent.com/githubmofo/TorusGuard/main/TorusGuard.png" alt="TorusGuard Security Banner" width="480" style="max-width: 100%; height: auto; border-radius: 8px;">
3
-
4
- # TorusGuard
5
-
6
- **Autonomous Security Guardrails, Governed Remediation, and Authorized Runtime Validation for AI-Built Web Applications.**
7
-
8
- [![npm version](https://img.shields.io/badge/npm-v1.3.2-cb3837.svg?style=flat-square&logo=npm)](https://www.npmjs.com/package/torusguard)
9
- [![GitHub Packages](https://img.shields.io/badge/GitHub%20Packages-v1.3.2-181717.svg?style=flat-square&logo=github)](https://github.com/githubmofo/TorusGuard/pkgs/npm/torusguard)
10
- [![Release](https://img.shields.io/badge/Release-v1.3.2-blue.svg?style=flat-square)](https://github.com/githubmofo/TorusGuard/releases/latest)
11
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
12
- [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-blue.svg?style=flat-square&logo=python&logoColor=white)](https://python.org)
13
- [![Node.js 18+](https://img.shields.io/badge/Node.js-18%2B-339933.svg?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org)
14
- [![SARIF: v2.1.0](https://img.shields.io/badge/SARIF-v2.1.0%20OASIS-purple.svg?style=flat-square)](.torusguard/schemas/)
15
- [![Integrity: SHA--256](https://img.shields.io/badge/Integrity-SHA--256%20(216%20Files)-teal.svg?style=flat-square)](.torusguard/.manifest.json)
16
- [![OWASP: Top 10](https://img.shields.io/badge/OWASP-Top%2010%20Aligned-orange.svg?style=flat-square)](docs/architecture/SECURITY_ARCHITECTURE.md)
17
- </div>
18
-
19
- ---
20
-
21
- ## 💡 Executive Summary
22
-
23
- AI coding assistants generate application code at superhuman speeds. However, they routinely hallucinate critical security boundaries: leaking database credentials into client bundles, omitting multi-tenant filters in ORM queries, stripping CSRF protections, or granting unconstrained tool permissions to autonomous agents.
24
-
25
- **TorusGuard** is an autonomous application security co-pilot and governed remediation engine built specifically for AI-written code. Operating natively within developer IDEs (Cursor, Claude Code, Antigravity, Windsurf, VS Code Copilot) and CI workflows, it deterministically audits, runtime-verifies, and surgically patches vulnerabilities without destructive full-file rewrites.
26
-
27
- ### 🌐 The Core Invariant: The Browser-Code Truth
28
- > **"If the browser receives it, users can inspect it."**
29
- > Frontend environment variables, JavaScript network bundles, and React Server Action payloads cannot conceal secrets. TorusGuard strictly enforces that database credentials, service role keys, private API secrets, and tenant boundaries remain exclusively on trusted server runtimes.
30
-
31
- ---
32
-
33
- ## ⚔️ Why TorusGuard? (Traditional SAST vs. AI Coding Agents)
34
-
35
- | Capability | Traditional SAST (SonarQube, Snyk) | Raw AI Coding Agents | TorusGuard Engine |
36
- |---|:---:|:---:|:---:|
37
- | **Target Code Base** | Human-written legacy code | Fast, high-churn AI generations | **AI-built full-stack applications** |
38
- | **Remediation Model** | Issue tickets & PDF reports | Destructive full-file rewrites | **Ponytail Protocol** ($\le 35$ additions, $\le 25$ deletions) |
39
- | **Learning Feedback** | Static rules, zero memory | Forgets fixes across prompts | **Adaptive Security Memory** & Golden Recipes |
40
- | **IDE Integration** | Heavy background language servers | Bloated prompt context | **AI IDE Rules Auto-Sync** ($\le 300$ tokens) |
41
- | **Commit Interception** | Slow server-side webhooks | None (pushes broken code) | **Git Pre-Commit Diff Guard** ($< 200\text{ ms}$) |
42
- | **Privacy & Telemetry** | Cloud code upload / SaaS | Third-party cloud LLMs | **100% Local, Zero-Egress Guarantee** |
43
-
44
- ---
45
-
46
- ## 🏛️ System Architecture & Visual Flowcharts
47
-
48
- ### 1. End-to-End Governance Pipeline
49
- The complete operational pipeline from developer prompt down to telemetry and IDE rule synchronization:
50
-
51
- ```mermaid
52
- flowchart TD
53
- subgraph Execution ["1. Execution Layer"]
54
- Agent["🤖 AI Agent (Cursor, Claude, Antigravity)"]
55
- CLI["💻 Developer CLI / Local Git Hook"]
56
- end
57
-
58
- subgraph Profiling ["2. Profiling & Discovery"]
59
- Profiler["🔍 Universal Stack Profiler (16+ Languages)"]
60
- Monorepo["🏢 Monorepo Fleet Detector (pnpm, Cargo, Go)"]
61
- end
62
-
63
- subgraph Detection ["3. AST Audit & Scoring"]
64
- Rules["⚙️ 71 Security Rules across 11 Families"]
65
- TestFilter["🎯 Test-Path Noise Suppressor"]
66
- Scorer["🧮 5-Factor Confidence Scorer (0–100)"]
67
- end
68
-
69
- subgraph Intelligence ["4. Memory & Runtime Verification"]
70
- Memory["🧠 Adaptive Memory Engine (.torusguard/memory/)"]
71
- RuntimeGate["🧪 Authorized Runtime Prober (Masked HTTP)"]
72
- end
73
-
74
- subgraph Governance ["5. Governed Remediation & Interception"]
75
- Ponytail["✂️ Ponytail Remediation (&lt;= 35 Add, &lt;= 25 Del)"]
76
- DiffGuard["🛑 Git Diff Guard (Pre-Commit Interception)"]
77
- end
78
-
79
- subgraph Output ["6. Telemetry & AI Sync"]
80
- IDEs["🔄 AI IDE Rules Sync (&lt;= 300 Tokens)"]
81
- HTML["📊 Standalone Dark-Mode HTML Report"]
82
- SARIF["📋 OASIS SARIF v2.1.0 Export"]
83
- end
84
-
85
- Agent --> Profiler
86
- CLI --> Profiler
87
- CLI --> DiffGuard
88
-
89
- Profiler --> Monorepo --> Rules --> TestFilter --> Scorer
90
- Memory -.->|"Historical Boost"| Scorer
91
- Scorer --> RuntimeGate --> Ponytail
92
- Scorer --> Ponytail
93
- Ponytail --> DiffGuard
94
-
95
- Ponytail --> Memory
96
- Memory --> IDEs
97
- Scorer --> HTML
98
- Scorer --> SARIF
99
- ```
100
-
101
- ---
102
-
103
- ### 2. The 7-Stage Finding Lifecycle (Dual-Strategy Governance)
104
- Every finding follows a strict closed-loop state machine supported equally via **Terminal CLI** (`npx torusguard ...`) and **AI Chat Workflows** (`/torusguard-...`) with an unskippable **Human Gate** and automatic `.bak` snapshots before disk modification:
105
-
106
- ```mermaid
107
- flowchart LR
108
- Detect["1. DETECT<br/>Static AST Signal<br/><code>audit · /audit</code>"] --> Classify["2. CLASSIFY<br/>0–100 Confidence"]
109
- Classify --> Verify["3. VERIFY<br/>Authorized Probe<br/><code>verify · /verify</code>"]
110
- Verify --> Remediate["4. REMEDIATE<br/>Ponytail Patch Plan<br/><code>harden · /harden</code>"]
111
- Remediate --> Gate{"👤 Human Gate<br/>Approved? [y/N]"}
112
- Gate -- Yes --> Apply["5. APPLY<br/>Backup &amp; Surgical Patch<br/><code>apply · /apply</code>"]
113
- Gate -- No --> Reject["❌ Discarded"]
114
- Apply --> Recheck["6. RE-CHECK<br/>Differential AST Audit<br/><code>recheck · /recheck</code>"]
115
- Recheck -- Fixed --> Archive["7. ARCHIVE<br/>Golden Recipe Distilled<br/><code>recipes</code>"]
116
- Recheck -- Regressed --> Rollback["⏪ Instant Rollback<br/><code>rollback (.bak)</code>"]
117
- ```
118
-
119
- ---
120
-
121
- ### 3. Adaptive Memory & AI Rules Sync Loop
122
- Verified patches are converted into Golden Fix Recipes and injected back into your AI editor's prompt instructions:
123
-
124
- ```mermaid
125
- flowchart TD
126
- Fix["✅ Verified Fix Applied (/torusguard apply)"] --> Extract["🏆 Golden Recipe Distilled (Diff &lt;= 35/25)"]
127
- Extract --> Ledger["📜 Event Appended (memory/events/)"]
128
- Ledger --> Patterns["🧠 Pattern Store &amp; Profile Updated"]
129
- Patterns --> Sync["🔄 Rules Compiler (rules_sync.py)"]
130
- Sync --> Cursor["Cursor (.cursorrules)"]
131
- Sync --> Claude["Claude Code (CLAUDE.md)"]
132
- Sync --> Antigravity["Antigravity (.agent/rules/)"]
133
- Sync --> Windsurf["Windsurf (.windsurfrules)"]
134
- Cursor & Claude & Antigravity & Windsurf --> AgentPrompt["🤖 AI Editor Enforces Guardrails (&lt;= 300 Tokens)"]
135
- ```
136
-
137
- ---
138
-
139
- ### 4. Git Pre-Commit Interception (Diff Guard)
140
- Blocks security bypasses, exposed credentials, and tenant boundary removals in $< 200\text{ ms}$ before code enters git history:
141
-
142
- ```mermaid
143
- flowchart TD
144
- Commit["💻 Developer or AI Agent runs: git commit"] --> Hook["⚡ Git Pre-Commit Hook (.git/hooks/pre-commit)"]
145
- Hook --> Scanner["🔍 Content-Aware Diff Guard (diff_guard.py &lt; 200 ms)"]
146
- Scanner --> Check1{"TG-DIFF-001<br/>Security Bypass?"}
147
- Check1 -- Yes --> Block["🚨 COMMIT BLOCKED<br/>Detailed violation + remediation emitted"]
148
- Check1 -- No --> Check2{"TG-DIFF-002<br/>Hardcoded Credential?"}
149
- Check2 -- Yes --> Block
150
- Check2 -- No --> Check3{"TG-DIFF-003<br/>Tenant Boundary Stripped?"}
151
- Check3 -- Yes --> Block
152
- Check3 -- No --> Pass["✅ COMMIT ALLOWED<br/>Clean diff merged into git history"]
153
- ```
154
-
155
- ---
156
-
157
- ## ⚡ Core Subsystems (At a Glance)
158
-
159
- ```text
160
- ┌────────────────────────────────────────────────────────────────────────────────────────┐
161
- │ TORUSGUARD SUBSYSTEMS │
162
- ├──────────────────────────┬──────────────────────────┬──────────────────────────────────┤
163
- │ 🔍 Detection & Profiling │ 🧠 Adaptive Intelligence │ 🛡️ Governance & Developer Flow │
164
- ├──────────────────────────┼──────────────────────────┼──────────────────────────────────┤
165
- │ • 16+ Languages Profiled │ • 0–100 Confidence Model │ • Ponytail Protocol (<= 35/25) │
166
- │ • Monorepo Fleet Map │ • Persistent Event Store │ • Pre-Apply Byte Snapshots (.bak)│
167
- │ • 71 AST Security Rules │ • Golden Recipe Learning │ • Pre-Commit Diff Hook (<200 ms) │
168
- │ • Test-Path Suppression │ • 90-Day Auto TTL Decay │ • AI Rules Auto-Sync (<= 300 tok)│
169
- └──────────────────────────┴──────────────────────────┴──────────────────────────────────┘
170
- ```
171
-
172
- - **Universal Profiler & Monorepo Detector:** Discovers manifests across 16+ languages (Go, Rust, Java, C#, PHP, Python, TS) and isolates nested packages (pnpm, Cargo, Gradle, Go work).
173
- - **Context-Aware Static Auditing:** Evaluates 71 rules across 11 families (`TG-AUTH`, `TG-DB`, `TG-INPUT`, `TG-SEC`, `TG-AGENT`, etc.). Suppresses test mocks automatically via `is_test_path()`.
174
- - **Adaptive Memory Engine:** Distills verified Before/After fixes into Golden Recipes. Proximity scoring injects targeted advice into a compact card ($\le 2,000$ tokens).
175
- - **Ponytail Governed Remediation:** Restricts code fixes to $\le 35$ additions and $\le 25$ deletions. Automatically saves byte-for-byte `.bak` backups for instant rollbacks.
176
- - **Pre-Commit Diff Guard:** 1-command installer (`diff-guard --install-hook`) blocks bypasses (`InsecureSkipVerify`, `[AllowAnonymous]`, `csrf().disable()`, `unsafe`) before git commit.
177
- - **AI IDE Rules Auto-Sync:** Compiles project security invariants into Cursor, Claude Code, Antigravity, and Windsurf within a strict $\le 300$ token overhead ceiling.
178
- - **Visual HTML Posture Dashboard:** Generates a 100% self-contained, offline-ready dark-mode report with animated SVG score gauges and interactive diff viewers.
179
-
180
- ---
181
-
182
- ## 🌐 Polyglot Ecosystem & Framework Matrix
183
-
184
- | Language / Stack | Manifests & Ecosystem | Supported Frameworks | Data Layers / ORMs | Intercepted Bypasses (`TG-DIFF`) |
185
- |---|---|---|---|---|
186
- | **Python** | `pyproject.toml`, `requirements.txt` | FastAPI, Django, Flask, DRF | SQLAlchemy, Django ORM, Tortoise | Raw SQL formatting, unescaped templates |
187
- | **TypeScript / JS** | `package.json` | Next.js, Express, NestJS, Nuxt | Prisma, Drizzle, TypeORM, Mongoose | Client-side secrets, tenant deletion |
188
- | **Go** | `go.mod` | Gin, Fiber, Echo, Chi | GORM, Ent, SQLx | `InsecureSkipVerify: true`, GORM tenant drop |
189
- | **Rust** | `Cargo.toml` | Actix-web, Axum, Rocket | Diesel, SeaORM, SQLx | Unvetted `unsafe {`, unverified TLS |
190
- | **Java** | `pom.xml`, `build.gradle` | Spring Boot, Quarkus, Micronaut | Hibernate, JPA, MyBatis, jOOQ | `csrf().disable()`, `permitAll()` |
191
- | **C# (.NET)** | `*.csproj`, `*.sln` | ASP.NET Core, Blazor | Entity Framework Core, Dapper | `[AllowAnonymous]`, LINQ tenant deletion |
192
- | **PHP** | `composer.json` | Laravel, Symfony, Slim | Eloquent, Doctrine | `CURLOPT_SSL_VERIFYPEER => false` |
193
- | **Ruby** | `Gemfile` | Ruby on Rails, Sinatra | ActiveRecord, Sequel | Raw unescaped SQL fragments |
194
- | **Kotlin** | `build.gradle.kts` | Spring Boot, Ktor | Exposed, Hibernate | Unauthenticated route decorators |
195
- | **Elixir** | `mix.exs` | Phoenix | Ecto | Unfiltered changeset mutations |
196
- | **Dart** | `pubspec.yaml` | Flutter, Shelf | Drift | Permissive HTTP certificate overrides |
197
- | **C / C++** | `CMakeLists.txt`, `Makefile` | Crow, Drogon, Oat++ | Raw SQLite, libpq | Unbounded buffers, raw pointer leaks |
198
-
199
- ---
200
-
201
- ## 🚀 60-Second Quickstart (Dual-Strategy: CLI & Chat)
202
-
203
- TorusGuard works natively in both standard terminal environments (Cursor, VS Code, CI/CD runners) and AI chat workflows:
204
-
205
- ### Method A: Via Node.js / NPX (Full 7-Stage Governance Lifecycle)
206
- ```bash
207
- # 1. Initialize TorusGuard in your workspace (or /torusguard init)
208
- npx torusguard init
209
-
210
- # 2. Run static security audit (or /torusguard audit)
211
- npx torusguard audit
212
-
213
- # 3. Formulate minimal Ponytail candidate patches (or /torusguard harden)
214
- npx torusguard harden
215
-
216
- # 4. Review interactive Human Gate & apply with pre-apply rollback snapshots (.bak) (or /torusguard apply)
217
- npx torusguard apply
218
-
219
- # 5. Targeted differential re-scan verifying fix closure (or /torusguard recheck)
220
- npx torusguard recheck
221
-
222
- # 6. Explore distilled Golden Fix Recipes
223
- npx torusguard recipes
224
-
225
- # 7. Generate visual dark-mode HTML posture report (or /torusguard report)
226
- npx torusguard report --html
227
-
228
- # 8. (Optional) Revert to pre-apply snapshot at any time
229
- npx torusguard rollback
230
-
231
- # 9. Install Git Pre-Commit Diff Guard Hook (blocks dangerous commits)
232
- npx torusguard diff-guard --install-hook
233
-
234
- # 10. Synchronize prompt guardrails across AI editors (<= 300 tokens)
235
- npx torusguard rules sync
236
- ```
237
-
238
- ### Method B: Via Pure Python 3.10+ (Zero-Dependency Standard Library)
239
- ```bash
240
- # 1. Initialize workspace
241
- python .torusguard/scripts/bootstrap.py --workspace .
242
-
243
- # 2. Run static audit
244
- python .torusguard/scripts/finding_scorer.py --dir .
245
-
246
- # 3. Formulate candidate patch plans (Ponytail Protocol <= 35 add, <= 25 del)
247
- python .torusguard/scripts/harden_runner.py
248
-
249
- # 4. Interactive Human Gate patch applier with pre-apply byte snapshots
250
- python .torusguard/scripts/apply_runner.py
251
-
252
- # 5. Targeted differential recheck
253
- python .torusguard/scripts/recheck_runner.py
254
-
255
- # 6. Explore distilled Golden Fix Recipes
256
- python .torusguard/scripts/recipes_runner.py
257
-
258
- # 7. Generate single-file visual HTML posture report
259
- python .torusguard/scripts/html_reporter.py
260
-
261
- # 8. Rollback pre-apply snapshots
262
- python .torusguard/scripts/apply_runner.py --rollback
263
-
264
- # 9. Install Pre-Commit Diff Guard
265
- python .torusguard/scripts/diff_guard.py --install-hook
266
-
267
- # 10. Sync AI IDE rules
268
- python .torusguard/scripts/rules_sync.py --workspace . --format all
269
- ```
270
-
271
- ---
272
-
273
- ## 💻 CLI Command Reference
274
-
275
- | Command | Subcommands & Flags | Description |
276
- |---|---|---|
277
- | `torusguard init` | `[--stack <name>] [--profile <type>]` | Scaffolds `.torusguard/` with active security rules, schemas, and workflows. |
278
- | `torusguard audit` | `[--scope <path>] [--format md\|json]` | Audits source code against active rules, scores confidence, and emits run folder. |
279
- | `torusguard verify` | `[--id <finding_id>]` | Probes authorized endpoints with automated credential masking. |
280
- | `torusguard harden` | `[--scope <path>] [--format md\|json]` | Formulates surgical candidate patch bundles adhering to Ponytail bounds ($\le 35$ additions, $\le 25$ deletions). |
281
- | `torusguard apply` | `[--bundle <id>] [--yes \| -y]` | Interactive terminal Human Gate (`[y/N/all/quit]`) with syntax diffs, creates `.bak` snapshots, applies patches, and distills Golden Recipes. |
282
- | `torusguard rollback` | `[--run <run_id>]` | Restores all files from `.torusguard/snapshots/<run_id>/` back to disk instantly. |
283
- | `torusguard recheck`| `[--scope <path>]` | Differentially re-evaluates AST sinks over modified scopes (`Confirmed Fixed` vs `Regressed`). |
284
- | `torusguard recipes`| `[--rule <id>] [--json]` | Interactive explorer for distilled, verified Golden Fix Recipes stored in persistent memory. |
285
- | `torusguard report` | `[--sarif] [--html] [--out <path>]` | Exports OASIS SARIF v2.1.0 or single-file visual HTML posture dashboard. |
286
- | `torusguard status` | `[--json]` | Displays stack detection, active rule count, memory metrics, and run history. |
287
- | `torusguard diff-guard`| `[--install-hook] [--uninstall-hook] [--diff <file>]` | Scans git diff for bypasses (`TG-DIFF-001..004`) or installs pre-commit hook. |
288
- | `torusguard rules sync`| `[--format all\|cursor\|claude\|agent\|windsurf]` | Compiles project rules into AI IDE configs within $\le 300$ prompt tokens. |
289
- | `torusguard memory` | `status \| context \| export \| learn` | Inspects adaptive memory, generates proximity cards, or exports team packs. |
290
-
291
- ---
292
-
293
- ## 🤖 AI IDE & Agent Setup
294
-
295
- TorusGuard injects non-destructive comment fences so your personal instructions remain untouched:
296
-
297
- ```markdown
298
- <!-- TORUSGUARD-SECURITY-GUARDRAILS:START -->
299
- ## TorusGuard Security Invariants
300
- - Browser-Code Truth: Never expose database credentials or private keys in client code.
301
- - Multi-Tenant Isolation: Always include tenantId/orgId filters on queries.
302
- - CSRF Protection: Enforce CSRF validation on all state-changing routes.
303
- <!-- TORUSGUARD-SECURITY-GUARDRAILS:END -->
304
- ```
305
-
306
- - **Cursor (`.cursorrules`):** Run `npx torusguard rules sync --format cursor`.
307
- - **Claude Code (`CLAUDE.md`):** Run `npx torusguard rules sync --format claude`.
308
- - **Antigravity (`.agent/rules/torusguard.md`):** Run `npx torusguard rules sync --format agent`.
309
- - **Windsurf (`.windsurfrules`):** Run `npx torusguard rules sync --format windsurf`.
310
- - **VS Code Copilot & Cline:** Add `SKILL.md` to your skill directory for zero-footprint cognitive guidance.
311
-
312
- ---
313
-
314
- ## 🛡️ The Ponytail Protocol & Rollback Guarantees
315
-
316
- AI coding models often destroy working applications by attempting full-file rewrites to fix minor issues. TorusGuard enforces the **Ponytail Protocol**:
317
-
318
- - **Strict Churn Limits:** Every fix is capped at $\le 35$ additions and $\le 25$ deletions.
319
- - **Full-File Rewrite Ban:** Large destructive edits are rejected by the patch engine.
320
- - **Rollback Snapshot Guarantee:** Before any file is modified, a byte-for-byte snapshot is saved to `.torusguard/snapshots/<run_id>/<path>.bak`.
321
- - **Instant Rollback:** Restoring original files takes 1 command (`npx torusguard rollback`).
322
-
323
- ---
324
-
325
- ## 🔒 Zero-Telemetry Local Privacy Guarantee
326
-
327
- TorusGuard operates under an uncompromising **Local Execution Guarantee**:
328
- - **Zero Network Egress:** No source code, AST trees, credentials, or audit findings leave your machine.
329
- - **Pure Local Execution:** 100% Python standard library and local Node.js. No background daemons or cloud SaaS accounts.
330
- - **Automatic Secret Redaction:** Live API keys, JWTs, AWS credentials, and passwords are automatically masked before writing reports.
331
- - **Sanitized Team Export:** `npx torusguard memory export --sanitized` strips developer usernames and local paths before sharing.
332
-
333
- For security policies and responsible disclosure, please refer to [SECURITY.md](SECURITY.md).
334
-
335
- ---
336
-
337
- ## 📄 License & Community
338
-
339
- TorusGuard is open-source software licensed under the [MIT License](LICENSE).
340
-
341
- - **Documentation:** Architecture guides and specifications in [docs/](docs/).
342
- - **Changelog:** Release milestones and updates in [CHANGELOG.md](CHANGELOG.md).
343
- - **Security Policy:** Vulnerability reporting in [SECURITY.md](SECURITY.md).
344
- - **Contributions:** Pull requests and discussions are welcomed via [CONTRIBUTING.md](CONTRIBUTING.md).
1
+ <div align="center">
2
+ <img src="TorusGuard.png" alt="TorusGuard Autonomous Security Engine Banner" width="560" style="max-width: 100%; height: auto; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);">
3
+
4
+ # TorusGuard
5
+
6
+ ### Autonomous Security Guardrails, Governed Remediation & Living Verification for AI-Built Applications
7
+
8
+ <p align="center">
9
+ <strong>Zero Telemetry · Zero External Python Dependencies · Pure Standard-Library Architecture · 100% Local-First</strong>
10
+ </p>
11
+
12
+ [![npm version](https://img.shields.io/badge/npm-v1.3.5-cb3837.svg?style=flat-square&logo=npm)](https://www.npmjs.com/package/torusguard)
13
+ [![GitHub Packages](https://img.shields.io/badge/GitHub%20Packages-v1.3.5-181717.svg?style=flat-square&logo=github)](https://github.com/githubmofo/TorusGuard/pkgs/npm/torusguard)
14
+ [![Release](https://img.shields.io/badge/Release-v1.3.5-blue.svg?style=flat-square)](https://github.com/githubmofo/TorusGuard/releases/latest)
15
+ [![Tests](https://img.shields.io/badge/Tests-81%2F81%20Passing-brightgreen.svg?style=flat-square)](harness/runner.py)
16
+ [![Security Health](https://img.shields.io/badge/Health%20Score-100%2F100%20Hardened-brightgreen.svg?style=flat-square)](security_report.md)
17
+ [![Rules Catalog](https://img.shields.io/badge/Rules%20Catalog-74%20Rules%20%7C%2018%20Families-indigo.svg?style=flat-square)](rules/)
18
+ [![Terminal Standard](https://img.shields.io/badge/Terminal-75--col%20Standard-informational.svg?style=flat-square)](.torusguard/scripts/term_ui.py)
19
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
20
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B%20(Zero%20Deps)-blue.svg?style=flat-square&logo=python&logoColor=white)](https://python.org)
21
+ [![Node.js 18+](https://img.shields.io/badge/Node.js-18%2B-339933.svg?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org)
22
+ [![SARIF: v2.1.0](https://img.shields.io/badge/SARIF-v2.1.0%20OASIS-purple.svg?style=flat-square)](.torusguard/schemas/)
23
+ [![OWASP: Top 10](https://img.shields.io/badge/OWASP-Top%2010%20Aligned-orange.svg?style=flat-square)](docs/architecture/SECURITY_ARCHITECTURE.md)
24
+ [![Privacy](https://img.shields.io/badge/Privacy-100%25%20Local%20Zero--Egress-success.svg?style=flat-square)](docs/overview/security-philosophy.md)
25
+ </div>
26
+
27
+ ---
28
+
29
+ ## 🛡️ The Architecture Behind the Emblem
30
+
31
+ In the emblem above, the **central golden keyhole shield** represents unbreakable secret protection, authentication integrity, and tenant isolation. It is enveloped by a continuous, interlocking **torus ring**—symbolizing TorusGuard's closed-loop autonomous security lifecycle:
32
+
33
+ ```mermaid
34
+ flowchart LR
35
+ subgraph Torus ["🔄 360° Closed-Loop Torus Lifecycle"]
36
+ direction LR
37
+ Detect["1. Detect (74 AST Rules)"] --> Verify["2. Verify (Evidence & Fingerprints)"]
38
+ Verify --> Harden["3. Harden (Ponytail Protocol)"]
39
+ Harden --> Apply["4. Apply (Human Gate & Snapshots)"]
40
+ Apply --> Recheck["5. Recheck (Differential Closure)"]
41
+ Recheck --> Memory["6. Memory (Golden Fix Recipes)"]
42
+ Memory -.->|Continuous Guardrail| Detect
43
+ end
44
+
45
+ subgraph Shield ["🛡️ Central Golden Keyhole Shield"]
46
+ direction TB
47
+ Inv1["Browser-Code Truth: Zero Client Secrets"]
48
+ Inv2["Tenant Partitioning: Scoped Lookups"]
49
+ Inv3["Zero Bypasses: No verify=False"]
50
+ Inv4["Living Source of Truth: security_report.md"]
51
+ end
52
+
53
+ Torus === Shield
54
+ ```
55
+
56
+ > **The Developer Reality:** AI coding assistants (Cursor, Claude Code, Copilot, Windsurf) build software at superhuman speed, but routinely leak private keys into client bundles, drop tenant partition filters, or inject raw user input into LLM system prompts.
57
+ > **TorusGuard forms an unbroken local guardrail around your codebase.** It audits static ASTs, runtime-verifies exploitability with inert canaries, synthesizes minimal surgical diffs adhering to the **Ponytail Protocol** ($\le 35$ additions, $\le 25$ deletions), and eliminates hallucinations by maintaining a verifiable single source of truth in `security_report.md`.
58
+
59
+ ---
60
+
61
+ ## 📑 Table of Contents
62
+
63
+ 1. [Developer Overview & Value Proposition](#-developer-overview--value-proposition)
64
+ 2. [End-to-End Autonomous Architecture](#-end-to-end-autonomous-architecture)
65
+ 3. [Why TorusGuard? (Traditional SAST vs. AI Coding vs. TorusGuard)](#-why-torusguard)
66
+ 4. [Installation & Setup Guide (npm & CLI)](#-installation--setup-guide-npm--cli)
67
+ 5. [Quickstart: The 5-Step Core Lifecycle](#-quickstart-the-5-step-core-lifecycle)
68
+ 6. [Dual-Strategy Command Matrix (CLI & AI Chat Parity)](#-dual-strategy-command-matrix-cli--ai-chat-parity)
69
+ 7. [74 Canonical Security Rules Catalog (18 Families Across 6 Pillars)](#-74-canonical-security-rules-catalog-18-families-across-6-pillars)
70
+ 8. [Ponytail Remediation Protocol & Rollback Safety](#-ponytail-remediation-protocol--rollback-safety)
71
+ 9. [Living Security Report Ground Truth (`security_report.md`)](#-living-security-report-ground-truth-security_reportmd)
72
+ 10. [Visual HTML Dashboard & SARIF v2.1.0 Export](#-visual-html-dashboard--sarif-v210-export)
73
+ 11. [AI Editor Guardrails Auto-Sync](#-ai-editor-guardrails-auto-sync)
74
+ 12. [Monorepo Fleet Support & Git Pre-Commit Diff Guard](#-monorepo-fleet-support--git-pre-commit-diff-guard)
75
+ 13. [Verification & Test Harness (81/81 Passing Harness Explained)](#-verification--test-harness)
76
+ 14. [Security Policy & Responsible Disclosure](#-security-policy--responsible-disclosure)
77
+ 15. [License](#-license)
78
+
79
+ ---
80
+
81
+ ## 💡 Developer Overview & Value Proposition
82
+
83
+ When developers use AI coding agents to write features, models optimize for *getting the code to run* rather than *defensive architecture*. Common failure modes include:
84
+ - **Exposing Private Credentials:** Leaking `process.env.SUPABASE_SERVICE_ROLE_KEY` or master database connection strings into Next.js `'use client'` bundles.
85
+ - **Dropping Tenant Boundaries:** Querying Prisma or Mongoose by record ID without scoping by tenant (`where: { id }` instead of `where: { id, tenantId }`).
86
+ - **Prompt Injection Vulnerabilities:** Interpolating untrusted user chat messages directly into system prompts.
87
+ - **Destructive AI Rewrites:** When asked to fix a minor bug, AI models rewrite entire 500-line files, introducing fresh regressions and breaking surrounding business logic.
88
+
89
+ **TorusGuard solves this deterministically:**
90
+ - **Zero-Egress Local Execution:** 100% of scanning and patching happens on your machine. Zero code or tokens are transmitted to external servers.
91
+ - **Zero Pip Dependencies:** Pure Python standard library (`pathlib`, `re`, `json`, `difflib`, `shutil`). No virtualenv conflicts or broken build wheels.
92
+ - **Ponytail Churn Bounds:** Patches are constrained strictly to $\le 35$ additions and $\le 25$ deletions. Surrounding business logic is never rewritten.
93
+ - **Human Gate & Instant Undo:** Every change requires interactive approval with syntax-highlighted diffs, backed up byte-for-byte in `.torusguard/snapshots/` with instant 1-command rollback.
94
+
95
+ ### 🌐 The Browser-Code Truth Invariant
96
+ > **"If the browser receives it, users can inspect it via DevTools."**
97
+ > Frontend environment variables, client JavaScript bundles, and React Server Action payloads cannot conceal secrets. TorusGuard strictly enforces that database credentials, service role keys, private API secrets, and tenant boundaries remain exclusively on trusted server runtimes.
98
+
99
+ ---
100
+
101
+ ## 📐 End-to-End Autonomous Architecture
102
+
103
+ The following flowchart illustrates how TorusGuard safeguards your repository from initial developer input to verified, regression-free output:
104
+
105
+ ```mermaid
106
+ flowchart TD
107
+ subgraph In ["1. Workspace & AI Context"]
108
+ A1["Polyglot Source Tree (16+ Languages)"]
109
+ A2["AI Coding Assistant (Cursor / Claude / Antigravity)"]
110
+ A3["Git Staged Diffs / Pre-Commit Hook"]
111
+ end
112
+
113
+ subgraph Core ["2. TorusGuard Engine (100% Local-First & Zero-Egress)"]
114
+ direction TB
115
+ B1["Static AST Engine: 74 Canonical Rules Across 18 Families"]
116
+ B2["Living Ledger Sync: security_report.md (0-100 Score)"]
117
+ B3["Ponytail Synthesizer: Minimal Surgical Diffs (&le;35 Add / &le;25 Del)"]
118
+ B4["Pre-Apply Snapshot Engine: Byte-for-Byte .bak Backups"]
119
+ B5["Human Gate: Interactive Syntax-Highlighted Approval"]
120
+ B6["Targeted Differential Re-Scan: Confirmed Fixed State"]
121
+
122
+ B1 --> B2 --> B3 --> B4 --> B5 --> B6
123
+ end
124
+
125
+ subgraph Out ["3. Verified Deliverables & Artifacts"]
126
+ C1["Hardened Production Code (Zero Regressions)"]
127
+ C2["Self-Contained Dark-Mode HTML Dashboard"]
128
+ C3["OASIS SARIF v2.1.0 for CI/CD Pipeline"]
129
+ C4["Auto-Synced AI Rules (.cursorrules, CLAUDE.md, etc.)"]
130
+ end
131
+
132
+ In --> Core --> Out
133
+ ```
134
+
135
+ ---
136
+
137
+ ## ⚔️ Why TorusGuard?
138
+
139
+ | Security Dimension | Traditional SAST (SonarQube, Snyk) | Raw AI Coding Agents | TorusGuard v1.3.5 Engine |
140
+ |:---|:---:|:---:|:---:|
141
+ | **Target Architecture** | Human-written legacy codebases | High-churn AI code generation | **AI-built full-stack applications** |
142
+ | **Remediation Model** | PDF reports & Jira tickets | Destructive full-file rewrites | **Ponytail Protocol** ($\le 35$ add, $\le 25$ del) |
143
+ | **Fix Preservation** | None (scans from scratch) | Forgets context across chats | **Adaptive Security Memory** & Golden Recipes |
144
+ | **Editor Sync** | Heavy background language daemons | Bloated prompt context ($> 2,000$ tokens) | **Stack-Adaptive Rules** ($\le 300$ prompt tokens) |
145
+ | **Ground-Truth State** | External proprietary web dashboard | Ephemeral chat context (hallucinates) | **Living Security Ledger** (`security_report.md`) |
146
+ | **Pre-Commit Defense** | Slow server-side webhooks | None (commits insecure code) | **Git Pre-Commit Diff Guard** ($< 200\text{ ms}$) |
147
+ | **Privacy & Telemetry** | Cloud code upload / SaaS | Third-party cloud LLMs | **100% Local, Zero-Egress Guarantee** |
148
+
149
+ ---
150
+
151
+ ## 📦 Installation & Setup Guide (npm & CLI)
152
+
153
+ TorusGuard is designed to be effortless to adopt in any project. There are no configuration servers, databases, or complex background daemons.
154
+
155
+ ### 📋 Prerequisites
156
+ - **Node.js:** 18.0.0 or higher
157
+ - **Python:** 3.10 or higher (**Pure standard library** — **zero `pip` dependencies required**)
158
+
159
+ > [!IMPORTANT]
160
+ > **Zero Pip Dependencies Guarantee:** TorusGuard's core Python engine relies strictly on the Python standard library (`pathlib`, `re`, `json`, `difflib`, `shutil`, `sys`, `os`, `argparse`, `hashlib`). You **never** need to create a Python virtualenv (`venv`), run `pip install`, or configure external wheels. It works out of the box with your system Python.
161
+
162
+ ---
163
+
164
+ ### 1. Zero-Install Runner (Recommended)
165
+ Run TorusGuard instantly in any repository without installing anything globally:
166
+
167
+ ```bash
168
+ # Run any command directly via npx
169
+ npx torusguard init
170
+ npx torusguard audit
171
+ npx torusguard status
172
+ ```
173
+
174
+ ### 2. Project Dev Dependency
175
+ Lock TorusGuard into your project's `package.json` for all team members and CI/CD pipelines:
176
+
177
+ ```bash
178
+ npm install -D torusguard
179
+ ```
180
+
181
+ Add convenience scripts to your `package.json`:
182
+ ```json
183
+ {
184
+ "scripts": {
185
+ "security:audit": "torusguard audit",
186
+ "security:harden": "torusguard harden",
187
+ "security:recheck": "torusguard recheck",
188
+ "security:status": "torusguard status"
189
+ }
190
+ }
191
+ ```
192
+
193
+ ### 3. Global Installation
194
+ If you prefer having the `torusguard` binary available system-wide across all terminal sessions:
195
+
196
+ ```bash
197
+ npm install -g torusguard
198
+ ```
199
+
200
+ ### 4. AI Agent Skill Installation
201
+ Install TorusGuard as a native AI assistant skill for Cursor, Claude Code, Cline, or Antigravity:
202
+
203
+ ```bash
204
+ npx skills add torusguard
205
+ ```
206
+
207
+ ---
208
+
209
+ ### 🔍 What Happens on First Run (`init`)
210
+ When you execute `npx torusguard init` in your repository:
211
+ 1. **Polyglot Profiling:** Automatically detects 16+ languages (Go, Rust, Java, C#, PHP, Python, TypeScript) and 30+ frameworks without manual configuration.
212
+ 2. **Scaffolding:** Creates a local `.torusguard/` directory containing active security rules, schemas, and runners.
213
+ 3. **Editor Rules Synchronization:** Automatically compiles compact, language-specific guardrails into `.cursorrules`, `CLAUDE.md`, `.agent/rules/torusguard.md`, and `.windsurfrules` ($\le 300$ prompt tokens).
214
+ 4. **Living Ledger Initialization:** Creates `security_report.md` at workspace root to track finding states without hallucination.
215
+ 5. **Baseline Policy:** Emits a production-ready `SECURITY.md` for responsible disclosure.
216
+
217
+ ---
218
+
219
+ ## ⚡ Quickstart: The 5-Step Core Lifecycle
220
+
221
+ Run the complete autonomous governance cycle in 60 seconds from your terminal:
222
+
223
+ ```bash
224
+ # Step 1: Initialize workspace and profile stack
225
+ npx torusguard init
226
+
227
+ # Step 2: Run AST static security audit across 74 rules
228
+ npx torusguard audit
229
+
230
+ # Step 3: Synthesize minimal surgical candidate patches
231
+ npx torusguard harden
232
+
233
+ # Step 4: Review syntax-highlighted diffs and apply with rollback backup
234
+ npx torusguard apply
235
+
236
+ # Step 5: Differentially recheck modified files to verify fix closure
237
+ npx torusguard recheck
238
+ ```
239
+
240
+ > 💡 **Prefer AI Chat?** Every step above can be triggered directly in your AI assistant chat using `/torusguard init`, `/torusguard audit`, `/torusguard harden`, `/torusguard apply`, and `/torusguard recheck`!
241
+
242
+ ---
243
+
244
+ ## ⌨️ Dual-Strategy Command Matrix (CLI & AI Chat Parity)
245
+
246
+ TorusGuard guarantees **100% operational parity** between terminal CLI execution and AI chat slash commands. Terminal outputs strictly adhere to a **75-column visual width** with Unicode emojis and ANSI stripping.
247
+
248
+ ### 🔄 Core Remediation Lifecycle
249
+
250
+ | Lifecycle Stage | Mode A: Terminal CLI | Mode B: AI Chat Command | Governed Action & Primary Artifact |
251
+ |:---|:---|:---|:---|
252
+ | **1. Init** | `npx torusguard init` | `/torusguard init` | Profiles workspace, activates rules, initializes `.torusguard/` |
253
+ | **2. Audit** | `npx torusguard audit` | `/torusguard audit` | 74-rule AST scan, line-shift fingerprints, updates `security_report.md` |
254
+ | **3. Harden** | `npx torusguard harden` | `/torusguard harden` | Synthesizes Ponytail diffs ($\le 35$ add, $\le 25$ del) into candidate bundles |
255
+ | **4. Apply** | `npx torusguard apply [--yes]` | `/torusguard apply` | Human Gate, pre-apply `.bak` snapshots, Golden Fix distillation |
256
+ | **5. Rollback**| `npx torusguard rollback` | `/torusguard rollback` | Instant restoration from pre-apply snapshots in `.torusguard/snapshots/` |
257
+ | **6. Recheck** | `npx torusguard recheck` | `/torusguard recheck` | Differential AST re-scan; marks findings `RESOLVED 🟢` in living report |
258
+
259
+ ### 📊 Intelligence, Memory & Reporting
260
+
261
+ | Capability | Mode A: Terminal CLI | Mode B: AI Chat Command | Governed Action & Primary Artifact |
262
+ |:---|:---|:---|:---|
263
+ | **Status** | `npx torusguard status` | `/torusguard status` | 75-column diagnostic overview of health score, stack, memory & rules |
264
+ | **Recipes** | `npx torusguard recipes` | `/torusguard recipes` | Explores verified Golden Fix patterns stored in `.torusguard/memory/` |
265
+ | **Report** | `npx torusguard report --html` | `/torusguard report` | Emits single-file dark-mode HTML posture report & OASIS SARIF v2.1.0 |
266
+ | **Rules Sync**| `npx torusguard rules sync` | `/torusguard rules sync`| Synchronizes prompt guardrails across Cursor, Claude, Antigravity, Windsurf |
267
+ | **Diff Guard**| `npx torusguard diff-guard` | `/torusguard diff-guard`| Audits git diffs for security bypasses; `--install-hook` binds pre-commit |
268
+
269
+ ### 🧪 Runtime Verification & Bounded Probing
270
+
271
+ | Capability | Mode A: Terminal CLI | Mode B: AI Chat Command | Governed Action & Primary Artifact |
272
+ |:---|:---|:---|:---|
273
+ | **Authorize** | `npx torusguard authorize` | `/torusguard authorize` | Target domain allowlisting, cryptographic ownership proof, TTL limits |
274
+ | **Verify** | `npx torusguard verify` | `/torusguard verify` | Asserts evidence sufficiency & live disk line-shift fingerprint matches |
275
+ | **Validate** | `npx torusguard web-validate` | `/torusguard web-validate`| Authorized non-destructive HTTP probing with transparent audit headers |
276
+ | **Exploit** | `npx torusguard exploit-check`| `/torusguard exploit-check`| Bounded single-step exploitability confirmation using inert sentinels |
277
+
278
+ ---
279
+
280
+ ## 📋 74 Canonical Security Rules Catalog (18 Families Across 6 Pillars)
281
+
282
+ TorusGuard's AST scanner inspects polyglot source trees across 74 canonical security rules organized into **6 core security pillars** across 18 families:
283
+
284
+ ```text
285
+ ┌─────────────────────────────────────────────────────────────────────────────┐
286
+ │ 74 CANONICAL RULES ACROSS 6 PILLARS │
287
+ └─────────────────────────────────────────────────────────────────────────────┘
288
+ 1. Secrets & Identity ──► TG-SEC (7) · TG-AUTH (8) · TG-CLIENT (2)
289
+ 2. Data & Injection Defense ──► TG-DB (4) · TG-INPUT (6) · TG-CSRF (2)
290
+ 3. AI Agent & LLM Security ──► TG-AGENT (4)
291
+ 4. Network & Real-Time ──► TG-SSRF (4) · TG-WEBHOOK (4) · TG-WS (4)
292
+ 5. Platform & API Limits ──► TG-RATE (3) · TG-GQL (4) · TG-PLATFORM (4)
293
+ TG-CACHE (3) · TG-EDGE (2)
294
+ 6. Supply Chain & Governance──► TG-SUPPLY (6) · TG-BIZ (4) · TG-DIFF (3)
295
+ ```
296
+
297
+ | Pillar | Family Prefix | Rules | Critical Invariant Enforced |
298
+ |:---|:---|:---:|:---|
299
+ | **🔑 Secrets & Client Bundles** | `TG-SEC`, `TG-CLIENT` | **9** | Zero hardcoded API keys, JWT secrets, private certificates, or server keys in client bundles. |
300
+ | **🛡️ Authentication & Sessions** | `TG-AUTH`, `TG-CSRF` | **10** | Timing-safe string compares, strong password hashing, algorithm verification, SameSite cookies. |
301
+ | **🗄️ Database & Input Safety** | `TG-DB`, `TG-INPUT` | **10** | Parameterized SQL queries, multi-tenant isolation (`where: { tenantId }`), path sanitization. |
302
+ | **🤖 AI Agent & LLM Guardrails** | `TG-AGENT` | **4** | Structural user prompt isolation, delimiter wrapping, shell tool sandboxing, MCP least-privilege. |
303
+ | **🌐 Network, Webhooks & WS** | `TG-SSRF`, `TG-WEBHOOK`, `TG-WS` | **12** | Private IP range blocking (`169.254.169.254`), HMAC-SHA256 signature checks, WS origin validation. |
304
+ | **⚡ Platform, Edge & Governance** | `TG-RATE`, `TG-GQL`, `TG-PLATFORM`, `TG-CACHE`, `TG-EDGE`, `TG-SUPPLY`, `TG-BIZ`, `TG-DIFF` | **29** | Auth rate limiting, GraphQL depth bounds, Helmet headers, lockfile integrity, zero `# nosec` bypasses. |
305
+
306
+ <details>
307
+ <summary><strong>🔍 Click to expand full 18-family catalog breakdown</strong></summary>
308
+
309
+ <br>
310
+
311
+ - **`TG-SEC` (Secrets & API Tokens — 7 rules):** Detects hardcoded JWT secrets, private certificates, cloud API keys, environment variable leakage, and secrets in URL queries or logs.
312
+ - **`TG-AUTH` (Authentication & Access Control — 8 rules):** Enforces constant-time string comparisons, strong password hashing (`bcrypt`/`argon2`), JWT algorithm pinning, mass assignment prevention, and server-side role verification.
313
+ - **`TG-DB` (Database Partitioning & Injection — 4 rules):** Mandates tenant-scoped queries across Prisma, Mongoose, SQLAlchemy, and GORM; eliminates raw SQL string concatenation.
314
+ - **`TG-INPUT` (Input Validation & Traversal — 6 rules):** Enforces safe path sanitization (`path.basename`), command argument escaping, safe DOM text assignments, and server-side file upload bounds.
315
+ - **`TG-RATE` (Rate Limiting & Resource Protection — 3 rules):** Enforces rate-limiting middleware on authentication routes, pagination bounds, and request payload size limits.
316
+ - **`TG-AGENT` (AI Agent & LLM Defense — 4 rules):** Enforces structural separation of user prompts from system instructions, inert XML delimiters, and containerized tool execution.
317
+ - **`TG-SSRF` (Server-Side Request Forgery — 4 rules):** Restricts dynamic outbound HTTP calls, blocks AWS/cloud metadata access (`169.254.169.254`), and enforces request timeouts.
318
+ - **`TG-WEBHOOK` (Webhook Verification — 4 rules):** Mandates cryptographic HMAC-SHA256 signature validation before body parsing, replay prevention, and timestamp expiration.
319
+ - **`TG-WS` (WebSocket Security — 4 rules):** Enforces handshake authentication, origin validation, channel-level authorization, and frame size caps.
320
+ - **`TG-CSRF` (Cross-Site Request Forgery — 2 rules):** Enforces anti-CSRF tokens on state-changing operations and `SameSite` cookie attributes.
321
+ - **`TG-GQL` (GraphQL Protection — 4 rules):** Enforces query depth limiting, production introspection suppression, and field-level resolver authorization.
322
+ - **`TG-SUPPLY` (Supply Chain Integrity — 6 rules):** Audits dependency lockfile presence, checks against known CVEs, prevents `--no-audit` build flags, and inspects build scripts.
323
+ - **`TG-BIZ` (Business Logic Bounds — 4 rules):** Validates negative quantity inputs, coupon/discount boundaries, and race-condition transaction locks.
324
+ - **`TG-CACHE` (Cache Isolation — 3 rules):** Enforces `Cache-Control: no-store, private` on authenticated responses and sanitizes unkeyed request headers.
325
+ - **`TG-CLIENT` (Client Bundle Hygiene — 2 rules):** Forbids importing private server environment variables into browser bundles and suppresses production source maps.
326
+ - **`TG-PLATFORM` (Server Hardening — 4 rules):** Enforces Helmet HTTP security headers, CORS origin whitelisting, cookie `secure` flags, and debug mode suppression.
327
+ - **`TG-DIFF` (Polyglot Diff Integrity — 3 rules):** Intercepts security bypass comments (`# nosec`, `InsecureSkipVerify: true`) and asserts Ponytail patch budgets.
328
+ - **`TG-EDGE` (Edge & Serverless Limits — 2 rules):** Prevents cross-request memory leaks in Cloudflare Workers and enforces subrequest fan-out limits.
329
+
330
+ </details>
331
+
332
+ ---
333
+
334
+ ## ✂️ Ponytail Remediation Protocol & Rollback Safety
335
+
336
+ Traditional AI coding assistants routinely destroy functional features by attempting full-file rewrites. TorusGuard strictly enforces the **Ponytail Protocol**:
337
+
338
+ $$\Delta \text{Lines} \le 35\text{ Additions}, \quad \Delta \text{Lines} \le 25\text{ Deletions}$$
339
+
340
+ ### 🛡️ Pre-Apply Rollback Snapshots
341
+ Before modifying a single file on disk, `apply_runner.py` creates a byte-for-byte backup:
342
+ ```text
343
+ .torusguard/snapshots/<run_id>/<target_file>.bak
344
+ ```
345
+
346
+ If a patch causes unforeseen behavior or test failures, execute an instant 1-command rollback:
347
+ ```bash
348
+ npx torusguard rollback
349
+ ```
350
+ All affected files are immediately restored to their exact pre-patch byte state.
351
+
352
+ ---
353
+
354
+ ## 📜 Living Security Report Ground Truth (`security_report.md`)
355
+
356
+ To eliminate AI hallucination, TorusGuard maintains `security_report.md` at the workspace root as the single source of truth across all CLI commands and AI chat sessions.
357
+
358
+ ### 🔄 Lifecycle State Machine
359
+ ```text
360
+ ┌─────────────────────────────────────────────────────────────────────────────┐
361
+ │ SECURITY REPORT LIFECYCLE STATE MACHINE │
362
+ └─────────────────────────────────────────────────────────────────────────────┘
363
+ [ OPEN 🔴 ] ──(verify)──► [ VERIFIED 🟠 ] ──(harden)──► [ CANDIDATE 🟡 ]
364
+ │
365
+ (apply)
366
+ │
367
+ ▼
368
+ [ RESOLVED 🟢 ] ◄──(recheck: confirmed)── [ APPLIED 🔵 ]
369
+ │
370
+ └──(recheck: failed)──► [ REGRESSED ❌ ]
371
+ ```
372
+
373
+ ### 🧮 Posture Health Score (0–100)
374
+ The Health Score dynamically reflects the open risk ledger:
375
+ $$\text{Penalty} = (25 \times \text{Critical}) + (15 \times \text{High}) + (5 \times \text{Medium}) + (2 \times \text{Low})$$
376
+ $$\text{Score} = \max(0, \min(100, 100 - \text{Penalty}))$$
377
+
378
+ *When all findings are verified closed via differential recheck, the repository achieves **Health Score: 100/100 🟢 Hardened & Secure**.*
379
+
380
+ ---
381
+
382
+ ## 📊 Visual HTML Dashboard & SARIF v2.1.0 Export
383
+
384
+ Generate a standalone, zero-external-CDN, dark-mode visual posture dashboard:
385
+ ```bash
386
+ npx torusguard report --html
387
+ ```
388
+ - **SVG Circular Posture Gauge:** Animated visual health score ($0-100$).
389
+ - **7-Stage Closed-Loop Pipeline:** Visual state timeline across all lifecycle phases.
390
+ - **Golden Fix Recipes Grid:** Syntax-highlighted unified diffs with Ponytail metrics.
391
+ - **Zero-CDN Architecture:** Completely offline-ready; embeds all styles and assets inline.
392
+
393
+ To integrate with **GitHub Code Scanning**, export standard SARIF:
394
+ ```bash
395
+ npx torusguard report > results.sarif
396
+ ```
397
+
398
+ ---
399
+
400
+ ## 🤖 AI Editor Guardrails Auto-Sync
401
+
402
+ TorusGuard compiles project security invariants, golden recipes, and active guardrails into prompt-optimized rule files:
403
+ ```bash
404
+ npx torusguard rules sync
405
+ ```
406
+
407
+ ### Supported AI Editors:
408
+ - **Cursor:** Injects non-destructive rules into `.cursorrules`
409
+ - **Claude Code:** Injects non-destructive rules into `CLAUDE.md`
410
+ - **Antigravity IDE:** Injects non-destructive rules into `.agent/rules/torusguard.md`
411
+ - **Windsurf:** Injects non-destructive rules into `.windsurfrules`
412
+
413
+ *All rules are compiled under a strict overhead ceiling of $\le 300$ prompt tokens to preserve AI reasoning context.*
414
+
415
+ ---
416
+
417
+ ## 🏢 Monorepo Fleet Support & Git Pre-Commit Diff Guard
418
+
419
+ TorusGuard automatically discovers and profiles multi-package workspaces:
420
+ - **Monorepo Ecosystems:** pnpm workspaces, npm/yarn workspaces, Cargo workspaces, Go multi-module workspaces, Gradle multi-project builds.
421
+ - **Universal Polyglot Profiler:** Automatically identifies 16+ languages and maps ORM boundaries independently per sub-package.
422
+ - **Pre-Commit Diff Guard:** Run `npx torusguard diff-guard --install-hook` to bind `.git/hooks/pre-commit` and block security bypasses before code is committed.
423
+
424
+ ---
425
+
426
+ ## 🧪 Verification & Test Harness
427
+
428
+ ### What Happens When You Run `npm test`?
429
+ TorusGuard enforces a strict **100% pass requirement across 81 test suites** before every release.
430
+
431
+ When a developer runs:
432
+ ```bash
433
+ npm test
434
+ ```
435
+ The test harness invokes `python harness/runner.py` directly using the Python standard library. It systematically verifies:
436
+ 1. **JSON Schema Validity:** 10 formal schemas (`finding`, `evidence`, `remediation`, `rule`, `lifecycle`, `provenance`, etc.).
437
+ 2. **74-Rule Catalog Integrity:** AST detection accuracy across all 18 security families.
438
+ 3. **Line-Shift Fingerprinting:** Stable anchor matching across file edits without line number drift.
439
+ 4. **Secret Redaction:** Stripe secret keys and JWT tokens safely masked.
440
+ 5. **Deterministic Replay:** 3-pass differential validation across Django, DRF, FastAPI, Flask, and SQLAlchemy fixtures.
441
+ 6. **Ponytail Patch Churn Bounds:** Verifying line budgets ($\le 35$ additions, $\le 25$ deletions).
442
+ 7. **Living Security Report State Transitions:** Discovery (`OPEN 🔴`), Candidate (`CANDIDATE 🟡`), Applied (`APPLIED 🔵`), and Verified Closure (`RESOLVED 🟢`).
443
+
444
+ ```bash
445
+ # Run formal TorusGuard test harness
446
+ npm test
447
+
448
+ # Expected Output:
449
+ # ================================================================================
450
+ # SUMMARY: 81 Passed | 0 Failed
451
+ # ================================================================================
452
+ ```
453
+
454
+ To validate diff guard and monorepo profiling independently:
455
+ ```bash
456
+ python harness/validate_v0_9_2_diff_and_monorepo.py
457
+ ```
458
+
459
+ ---
460
+
461
+ ## 🔒 Security Policy & Responsible Disclosure
462
+
463
+ If you believe you have discovered a security vulnerability in TorusGuard itself, please report it responsibly and privately through [GitHub Private Vulnerability Reporting](https://github.com/githubmofo/TorusGuard/security/advisories/new) or contact the project maintainers. Do not file public issues for undisclosed security flaws. For complete details, consult [SECURITY.md](SECURITY.md).
464
+
465
+ ---
466
+
467
+ ## 📄 License
468
+
469
+ TorusGuard is released under the [MIT License](LICENSE).
470
+ Copyright (c) 2026 Jenish Lad ([@githubmofo](https://github.com/githubmofo)).