torusguard 2.0.0-alpha → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.torusguard/.manifest.json +94 -30
- package/.torusguard/core/__init__.py +146 -0
- package/.torusguard/core/agent_roles.py +104 -0
- package/.torusguard/core/ast_walker.py +283 -0
- package/.torusguard/core/authorization.py +218 -0
- package/.torusguard/core/browser_verifier.py +128 -0
- package/.torusguard/core/bundle.py +141 -0
- package/.torusguard/core/call_graph.py +184 -0
- package/.torusguard/core/clustering.py +275 -0
- package/.torusguard/core/confidence.py +120 -0
- package/.torusguard/core/cross_file_taint.py +101 -0
- package/.torusguard/core/exploit_checker.py +317 -0
- package/.torusguard/core/formatter.py +351 -0
- package/.torusguard/core/governance.py +210 -0
- package/.torusguard/core/identity.py +104 -0
- package/.torusguard/core/import_resolver.py +91 -0
- package/.torusguard/core/incremental.py +102 -0
- package/.torusguard/core/lifecycle.py +137 -0
- package/.torusguard/core/models.py +425 -0
- package/.torusguard/core/parallel.py +56 -0
- package/.torusguard/core/parser.py +202 -0
- package/.torusguard/core/rechecker.py +107 -0
- package/.torusguard/core/replay_trace.py +178 -0
- package/.torusguard/core/rules_registry.py +131 -0
- package/.torusguard/core/run_folder.py +60 -0
- package/.torusguard/core/run_manager.py +163 -0
- package/.torusguard/core/runtime_evidence.py +175 -0
- package/.torusguard/core/runtime_validator.py +246 -0
- package/.torusguard/core/safety_gate.py +139 -0
- package/.torusguard/core/sarif.py +189 -0
- package/.torusguard/core/stack_profiler.py +184 -0
- package/.torusguard/core/symbol_table.py +91 -0
- package/.torusguard/core/taint.py +133 -0
- package/.torusguard/core/taint_graph.py +235 -0
- package/.torusguard/core/taint_rules.py +268 -0
- package/.torusguard/core/v070_reporter.py +102 -0
- package/.torusguard/core/v070_workflow.py +339 -0
- package/.torusguard/core/v6_reporter.py +180 -0
- package/.torusguard/core/v6_workflow.py +221 -0
- package/.torusguard/core/watcher.py +58 -0
- package/.torusguard/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
- package/.torusguard/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
- package/.torusguard/rules/container/TG-CONT-001-root-user-execution.md +50 -0
- package/.torusguard/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
- package/.torusguard/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
- package/.torusguard/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
- package/.torusguard/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
- package/.torusguard/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
- package/.torusguard/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
- package/.torusguard/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
- package/.torusguard/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
- package/.torusguard/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
- package/.torusguard/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
- package/.torusguard/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
- package/.torusguard/rules_catalog.json +96 -0
- package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/rules_sync.cpython-314.pyc +0 -0
- package/.torusguard/scripts/audit_runner.py +108 -10
- package/.torusguard/scripts/finding_scorer.py +43 -13
- package/.torusguard/scripts/manifest_builder.py +1 -1
- package/.torusguard/scripts/skill_profiler.py +26 -0
- package/.torusguard/skills/torusguard/SKILL.md +74 -25
- package/.torusguard/skills/torusguard/bootstrap.py +57 -24
- package/.torusguard/skills/torusguard-ai-guard/SKILL.md +95 -0
- package/.torusguard/skills/torusguard-apply/SKILL.md +60 -34
- package/.torusguard/skills/torusguard-audit/SKILL.md +131 -57
- package/.torusguard/skills/torusguard-authorize/SKILL.md +48 -6
- package/.torusguard/skills/torusguard-container/SKILL.md +94 -0
- package/.torusguard/skills/torusguard-exploit-check/SKILL.md +50 -6
- package/.torusguard/skills/torusguard-full/SKILL.md +62 -19
- package/.torusguard/skills/torusguard-git-mine/SKILL.md +92 -0
- package/.torusguard/skills/torusguard-harden/SKILL.md +81 -50
- package/.torusguard/skills/torusguard-init/SKILL.md +61 -14
- package/.torusguard/skills/torusguard-ocr-scan/SKILL.md +94 -0
- package/.torusguard/skills/torusguard-recheck/SKILL.md +71 -18
- package/.torusguard/skills/torusguard-redos/SKILL.md +91 -0
- package/.torusguard/skills/torusguard-report/SKILL.md +50 -9
- package/.torusguard/skills/torusguard-status/SKILL.md +63 -10
- package/.torusguard/skills/torusguard-verify/SKILL.md +52 -10
- package/.torusguard/skills/torusguard-web-validate/SKILL.md +53 -8
- package/.torusguard/workflows/ai-guard.md +31 -0
- package/.torusguard/workflows/apply.md +32 -55
- package/.torusguard/workflows/audit.md +35 -49
- package/.torusguard/workflows/authorize.md +27 -50
- package/.torusguard/workflows/container.md +29 -0
- package/.torusguard/workflows/exploit-check.md +28 -50
- package/.torusguard/workflows/git-mine.md +25 -0
- package/.torusguard/workflows/harden.md +29 -48
- package/.torusguard/workflows/init.md +27 -50
- package/.torusguard/workflows/memory.md +18 -23
- package/.torusguard/workflows/ocr-scan.md +25 -0
- package/.torusguard/workflows/recheck.md +28 -46
- package/.torusguard/workflows/redos.md +27 -0
- package/.torusguard/workflows/report.md +33 -52
- package/.torusguard/workflows/status.md +31 -52
- package/.torusguard/workflows/verify.md +29 -49
- package/.torusguard/workflows/web-validate.md +22 -45
- package/README.md +96 -60
- package/package.json +7 -2
- package/skills/torusguard/SKILL.md +75 -24
- package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/skills/torusguard/bootstrap.py +60 -71
- package/skills/torusguard/payload/.manifest.json +94 -31
- package/skills/torusguard/payload/core/__init__.py +146 -0
- package/skills/torusguard/payload/core/agent_roles.py +104 -0
- package/skills/torusguard/payload/core/ast_walker.py +283 -0
- package/skills/torusguard/payload/core/authorization.py +218 -0
- package/skills/torusguard/payload/core/browser_verifier.py +128 -0
- package/skills/torusguard/payload/core/bundle.py +141 -0
- package/skills/torusguard/payload/core/call_graph.py +184 -0
- package/skills/torusguard/payload/core/clustering.py +275 -0
- package/skills/torusguard/payload/core/confidence.py +120 -0
- package/skills/torusguard/payload/core/cross_file_taint.py +101 -0
- package/skills/torusguard/payload/core/exploit_checker.py +317 -0
- package/skills/torusguard/payload/core/formatter.py +351 -0
- package/skills/torusguard/payload/core/governance.py +210 -0
- package/skills/torusguard/payload/core/identity.py +104 -0
- package/skills/torusguard/payload/core/import_resolver.py +91 -0
- package/skills/torusguard/payload/core/incremental.py +102 -0
- package/skills/torusguard/payload/core/lifecycle.py +137 -0
- package/skills/torusguard/payload/core/models.py +425 -0
- package/skills/torusguard/payload/core/parallel.py +56 -0
- package/skills/torusguard/payload/core/parser.py +202 -0
- package/skills/torusguard/payload/core/rechecker.py +107 -0
- package/skills/torusguard/payload/core/replay_trace.py +178 -0
- package/skills/torusguard/payload/core/rules_registry.py +131 -0
- package/skills/torusguard/payload/core/run_folder.py +60 -0
- package/skills/torusguard/payload/core/run_manager.py +163 -0
- package/skills/torusguard/payload/core/runtime_evidence.py +175 -0
- package/skills/torusguard/payload/core/runtime_validator.py +246 -0
- package/skills/torusguard/payload/core/safety_gate.py +139 -0
- package/skills/torusguard/payload/core/sarif.py +189 -0
- package/skills/torusguard/payload/core/stack_profiler.py +184 -0
- package/skills/torusguard/payload/core/symbol_table.py +91 -0
- package/skills/torusguard/payload/core/taint.py +133 -0
- package/skills/torusguard/payload/core/taint_graph.py +235 -0
- package/skills/torusguard/payload/core/taint_rules.py +268 -0
- package/skills/torusguard/payload/core/v070_reporter.py +102 -0
- package/skills/torusguard/payload/core/v070_workflow.py +339 -0
- package/skills/torusguard/payload/core/v6_reporter.py +180 -0
- package/skills/torusguard/payload/core/v6_workflow.py +221 -0
- package/skills/torusguard/payload/core/watcher.py +58 -0
- package/skills/torusguard/payload/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
- package/skills/torusguard/payload/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-001-root-user-execution.md +50 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
- package/skills/torusguard/payload/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
- package/skills/torusguard/payload/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
- package/skills/torusguard/payload/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
- package/skills/torusguard/payload/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
- package/skills/torusguard/payload/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
- package/skills/torusguard/payload/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
- package/skills/torusguard/payload/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
- package/skills/torusguard/payload/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
- package/skills/torusguard/payload/rules_catalog.json +338 -518
- package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/audit_runner.py +108 -10
- package/skills/torusguard/payload/scripts/finding_scorer.py +43 -13
- package/skills/torusguard/payload/scripts/manifest_builder.py +1 -1
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +74 -25
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +57 -24
- package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -41
- package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -41
- package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -40
- package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -25
- package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -40
- package/skills/torusguard/payload/skills/torusguard-ai-guard/SKILL.md +95 -0
- package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +60 -34
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +131 -57
- package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +48 -6
- package/skills/torusguard/payload/skills/torusguard-container/SKILL.md +94 -0
- package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +50 -6
- package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +62 -19
- package/skills/torusguard/payload/skills/torusguard-git-mine/SKILL.md +92 -0
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +81 -50
- package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +61 -14
- package/skills/torusguard/payload/skills/torusguard-ocr-scan/SKILL.md +94 -0
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +71 -18
- package/skills/torusguard/payload/skills/torusguard-redos/SKILL.md +91 -0
- package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +50 -9
- package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +63 -10
- package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +52 -10
- package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +53 -8
- package/skills/torusguard/payload/workflows/ai-guard.md +31 -0
- package/skills/torusguard/payload/workflows/apply.md +31 -62
- package/skills/torusguard/payload/workflows/audit.md +35 -55
- package/skills/torusguard/payload/workflows/authorize.md +27 -50
- package/skills/torusguard/payload/workflows/container.md +29 -0
- package/skills/torusguard/payload/workflows/exploit-check.md +28 -50
- package/skills/torusguard/payload/workflows/git-mine.md +25 -0
- package/skills/torusguard/payload/workflows/harden.md +28 -52
- package/skills/torusguard/payload/workflows/init.md +27 -56
- package/skills/torusguard/payload/workflows/memory.md +18 -23
- package/skills/torusguard/payload/workflows/ocr-scan.md +25 -0
- package/skills/torusguard/payload/workflows/recheck.md +28 -46
- package/skills/torusguard/payload/workflows/redos.md +27 -0
- package/skills/torusguard/payload/workflows/report.md +39 -62
- package/skills/torusguard/payload/workflows/status.md +31 -55
- package/skills/torusguard/payload/workflows/torusguard-audit.md +35 -55
- package/skills/torusguard/payload/workflows/verify.md +29 -49
- package/skills/torusguard/payload/workflows/web-validate.md +22 -45
- package/skills/torusguard/references/csharp-security.md +41 -0
- package/skills/torusguard/references/go-security.md +41 -0
- package/skills/torusguard/references/java-security.md +40 -0
- package/skills/torusguard/references/polyglot-security-matrix.md +25 -0
- package/skills/torusguard/references/rust-security.md +40 -0
- package/skills/torusguard-ai-guard/SKILL.md +95 -0
- package/skills/torusguard-apply/SKILL.md +60 -34
- package/skills/torusguard-audit/SKILL.md +130 -57
- package/skills/torusguard-authorize/SKILL.md +48 -6
- package/skills/torusguard-container/SKILL.md +94 -0
- package/skills/torusguard-exploit-check/SKILL.md +50 -6
- package/skills/torusguard-full/SKILL.md +62 -19
- package/skills/torusguard-git-mine/SKILL.md +92 -0
- package/skills/torusguard-harden/SKILL.md +81 -50
- package/skills/torusguard-init/SKILL.md +61 -14
- package/skills/torusguard-ocr-scan/SKILL.md +94 -0
- package/skills/torusguard-recheck/SKILL.md +71 -18
- package/skills/torusguard-redos/SKILL.md +91 -0
- package/skills/torusguard-report/SKILL.md +50 -9
- package/skills/torusguard-status/SKILL.md +63 -10
- package/skills/torusguard-verify/SKILL.md +52 -10
- package/skills/torusguard-web-validate/SKILL.md +53 -8
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
|
|
14
|
-
<a href="https://github.com/githubmofo/TorusGuard/releases"><img src="https://img.shields.io/badge/version-
|
|
15
|
-
<a href="https://www.npmjs.com/package/torusguard"><img src="https://img.shields.io/badge/npm-v2.
|
|
14
|
+
<a href="https://github.com/githubmofo/TorusGuard/releases"><img src="https://img.shields.io/badge/version-v2.1.1-orange.svg" alt="Version"></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/torusguard"><img src="https://img.shields.io/badge/npm-v2.1.1-CB3837?logo=npm&logoColor=white" alt="npm: v2.1.1"></a>
|
|
16
16
|
<img src="https://img.shields.io/badge/Privacy-Local_First-success" alt="Privacy: Local First">
|
|
17
17
|
<img src="https://img.shields.io/badge/Dependencies-Zero-brightgreen" alt="Dependencies: Zero">
|
|
18
18
|
<img src="https://img.shields.io/badge/SARIF-v2.1.0-6C3483" alt="SARIF">
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
<p align="center">
|
|
23
23
|
<img src="https://img.shields.io/badge/Unit%20Tests-100%25%20Passing-brightgreen?logo=go&logoColor=white" alt="Unit Tests: 100% Passing">
|
|
24
24
|
<img src="https://img.shields.io/badge/Polyglot%20Tests-36%2F36%20Repos%20Passed-brightgreen?logo=checkmarx&logoColor=white" alt="Polyglot Tests: 36/36 Repos Passed">
|
|
25
|
+
<a href="docs/validation/unseen-repos-tri-mode-validation-report.md"><img src="https://img.shields.io/badge/Tri--Mode%20Validation-6%2F6%20Unseen%20Stacks%20Passed-brightgreen?logo=checkmarx&logoColor=white" alt="Tri-Mode Validation: 6/6 Unseen Stacks Passed"></a>
|
|
25
26
|
<img src="https://img.shields.io/badge/Tri--Mode%20E2E-16%2F16%20Verified-blue?logo=checkmarx&logoColor=white" alt="Tri-Mode E2E: 16/16 Verified">
|
|
26
27
|
<img src="https://img.shields.io/badge/Vision%20OCR-Tested%20%26%20Verified-blueviolet?logo=tesseract&logoColor=white" alt="Vision OCR: Tested & Verified">
|
|
27
|
-
<img src="https://img.shields.io/badge/Rules%20Verified-
|
|
28
|
+
<img src="https://img.shields.io/badge/Rules%20Verified-88%2F88%20Rules-success" alt="Rules: 88/88 Verified">
|
|
28
29
|
</p>
|
|
29
30
|
|
|
30
31
|
<p align="center">
|
|
@@ -42,13 +43,13 @@
|
|
|
42
43
|
|
|
43
44
|
- [What Is TorusGuard?](#what-is-torusguard)
|
|
44
45
|
- [Features](#-features)
|
|
45
|
-
- [Autonomous Architecture](#-autonomous-architecture)
|
|
46
|
+
- [Autonomous Architecture & Workflow](#-autonomous-architecture--workflow)
|
|
46
47
|
- [Prerequisites](#-prerequisites)
|
|
47
48
|
- [Installation](#-installation)
|
|
48
49
|
- [Usage](#-usage)
|
|
49
50
|
- [Commands](#-commands)
|
|
50
51
|
- [Project Structure](#-project-structure)
|
|
51
|
-
- [Security
|
|
52
|
+
- [Security Invariants & Rule Governance](#-security-invariants--rule-governance)
|
|
52
53
|
- [AI Agent Integration](#-ai-agent-integration)
|
|
53
54
|
- [Verified Test Suite & Benchmarks](#-verified-test-suite--mass-benchmarks)
|
|
54
55
|
- [Non-Negotiable Invariants](#-non-negotiable-invariants)
|
|
@@ -60,10 +61,11 @@
|
|
|
60
61
|
|
|
61
62
|
## What Is TorusGuard?
|
|
62
63
|
|
|
63
|
-
TorusGuard is a **zero-dependency, single-binary security engine** that scans, hardens, and validates AI-generated codebases. It enforces
|
|
64
|
+
TorusGuard is a **zero-dependency, single-binary security engine** that scans, hardens, and validates AI-generated codebases. It enforces 88 security rules across 22 architectural families and works across three unified operational modes (**Tri-Mode Parity**):
|
|
64
65
|
|
|
65
|
-
- **CLI
|
|
66
|
-
- **AI
|
|
66
|
+
- **Mode A: Terminal CLI (Go Binary)** — A deterministic scanner and enforcer that runs in your terminal or CI/CD pipeline (`torusguard <command>`).
|
|
67
|
+
- **Mode B: AI Chat Slash Commands** — Integrates natively with Antigravity, Cursor, Claude Code, Windsurf, VS Code, and other AI coding assistants via slash commands (`/torusguard <command>`).
|
|
68
|
+
- **Mode C: Native MCP Tools** — Stdio Model Context Protocol (JSON-RPC 2.0) interface exposing autonomous security tools and living resources directly to AI agents.
|
|
67
69
|
|
|
68
70
|
TorusGuard ensures that the code your AI assistant writes is secure *before* it reaches production.
|
|
69
71
|
|
|
@@ -71,8 +73,14 @@ TorusGuard ensures that the code your AI assistant writes is secure *before* it
|
|
|
71
73
|
|
|
72
74
|
## ✨ Features
|
|
73
75
|
|
|
74
|
-
- **
|
|
75
|
-
- **
|
|
76
|
+
- **88 Security Rules** across 22 families (Secrets, Auth, SQL Injection, Deserialization, Open Redirects, SSRF, CSRF, GraphQL, Supply Chain, Containers, Git History, ReDoS, AI & RAG, and more)
|
|
77
|
+
- **Taint Analysis & Interprocedural Dataflow Engine** — Cross-file, interprocedural taint flow tracking from untrusted sources to critical sinks across imports, modules, and call graphs
|
|
78
|
+
- **7-Signal Calibrated Confidence Scorer** — Evidence-chain calibration combining rule severity, taint confirmation, taint depth, sanitizer absence, framework context, multi-line evidence, and persistent memory
|
|
79
|
+
- **First-Principles Security Suite** — Built-in native scanners for Dockerfile/Compose privilege bounds, Git commit log secret mining, exponential regex backtracking, and cross-tenant vector isolation
|
|
80
|
+
- **Polyglot Parser & AST Walker** — Tree-sitter powered AST traversal with unified CST nodes and symbol resolution across Go, JavaScript, TypeScript, and Python
|
|
81
|
+
- **Incremental Hash Cache & Parallel Scanning** — SHA-256 mtime incremental scan caching, process-pool parallelization, and continuous file-watcher debounce
|
|
82
|
+
- **Line-Level Reflection Module** — Semantic patch synthesis (`find_snippet` / `replace_snippet`) that accurately replaces exact code blocks without brittle line-number offsets
|
|
83
|
+
- **1/9th Token Bounded Context Extraction** — AST context extraction (±3 lines) via `scanner.ExtractContext` to keep review prompts hyper-efficient and prevent context saturation
|
|
76
84
|
- **Ponytail Protocol** — Surgical patch bounds (≤35 additions, ≤25 deletions) to prevent full-file rewrites
|
|
77
85
|
- **Pre-Apply Snapshots** — Automatic `.bak` rollback snapshots before every code modification
|
|
78
86
|
- **SARIF v2.1.0 Export** — Standards-compliant output for GitHub Advanced Security, VS Code, and other SARIF consumers
|
|
@@ -104,37 +112,64 @@ TorusGuard’s static scanner and enforcement binary have been rigorously tested
|
|
|
104
112
|
|
|
105
113
|
---
|
|
106
114
|
|
|
107
|
-
## 🏗️ Autonomous Architecture
|
|
115
|
+
## 🏗️ Autonomous Architecture & Workflow
|
|
108
116
|
|
|
109
117
|
TorusGuard uses a **tri-track architecture** where intelligence, deterministic enforcement, and agent tool execution are cleanly separated across three unified operational modes:
|
|
110
118
|
|
|
111
119
|
```mermaid
|
|
112
120
|
flowchart TD
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
User --> ModeC[Mode C: Native MCP Protocol<br/><code>torusguard_audit / ocr_scan</code><br/>Stdio JSON-RPC 2.0 Agent Tools]
|
|
118
|
-
|
|
119
|
-
ModeA --> Router[Command Router & Dispatcher<br/>cmd/torusguard]
|
|
120
|
-
ModeB --> Router
|
|
121
|
-
ModeC --> Router
|
|
122
|
-
|
|
123
|
-
Router --> Engine
|
|
124
|
-
|
|
125
|
-
subgraph Engine[TorusGuard Core Engine]
|
|
126
|
-
Scanner[Polyglot AST & Heuristic Scanner<br/>74 Rules across 18 Families]
|
|
127
|
-
OCR[Multi-Modal Vision OCR Engine<br/>Tesseract Optical Analysis ≤10MB]
|
|
128
|
-
Harden[Harden Engine<br/>Ponytail Protocol ≤35 add, ≤25 del]
|
|
129
|
-
Apply[Snapshot & Apply Engine<br/>Byte-for-byte Rollback Backups]
|
|
130
|
-
Validate[Runtime Web Validator<br/>SSRF Defense & Audit Probing]
|
|
131
|
-
Recheck[Differential Recheck Engine<br/>Fix Closure Verification]
|
|
121
|
+
subgraph Ingress["Unified Tri-Mode Ingress"]
|
|
122
|
+
ModeA["<b>Mode A: Terminal CLI</b><br/><code>torusguard <cmd></code><br/>Deterministic Single Binary"]
|
|
123
|
+
ModeB["<b>Mode B: AI Chat Slash Commands</b><br/><code>/torusguard <cmd></code><br/>Cursor • Claude • Windsurf • Antigravity"]
|
|
124
|
+
ModeC["<b>Mode C: Native MCP Tools</b><br/><code>torusguard_*</code> (10 Tools • 2 Resources)<br/>Stdio JSON-RPC 2.0 Agent Server"]
|
|
132
125
|
end
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
|
|
127
|
+
Ingress --> Router["<b>Command Router & Dispatcher</b><br/>cmd/torusguard (21 Commands)"]
|
|
128
|
+
|
|
129
|
+
subgraph Core["TorusGuard Core Security Engine (Go Single Binary)"]
|
|
130
|
+
direction TB
|
|
131
|
+
subgraph Scanners["First-Principles & Multi-Modal Scanner Suite"]
|
|
132
|
+
AST["<b>Polyglot AST & Heuristic Scanner</b><br/>Go • TS/JS • Python • SQL • Auth • SSRF • CSRF"]
|
|
133
|
+
OCR["<b>Multi-Modal Vision OCR Engine</b><br/>Tesseract v5.4.0 • Leaked Keys in PNG/JPG ≤10MB"]
|
|
134
|
+
Container["<b>Container & Dockerfile Auditor</b><br/>Root Execution • Docker Sockets • Build Secrets"]
|
|
135
|
+
GitMine["<b>Git History Secret Miner</b><br/>Past Commits • Diff Logs • Remote Credentials"]
|
|
136
|
+
ReDoS["<b>ReDoS Complexity Analyzer</b><br/>Polynomial & Exponential Backtracking Loops"]
|
|
137
|
+
AIGuard["<b>AI Agent & RAG Vector Guard</b><br/>Prompt Injection • Tenant Vector Contamination"]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
subgraph Governance["Governance & Remediation Pipeline"]
|
|
141
|
+
Harden["<b>Harden & Line Reflection</b><br/>Ponytail Bounds: ≤35 Add • ≤25 Del"]
|
|
142
|
+
Snapshot["<b>Pre-Apply Snapshot Engine</b><br/>Byte-for-Byte Rollback Backups in .torusguard/snapshots/"]
|
|
143
|
+
HumanGate{"<b>Human Gate Authorization</b><br/>Explicit --yes Confirmation Required"}
|
|
144
|
+
Recheck["<b>Differential Recheck Engine</b><br/>Zero-Regression Fix Closure"]
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Router --> Scanners
|
|
149
|
+
Scanners --> Ledger[("<b>Living Security Ledger</b><br/><code>security_report.md</code><br/>Single Source of Truth")]
|
|
150
|
+
Ledger --> Harden
|
|
151
|
+
Harden --> Snapshot
|
|
152
|
+
Snapshot --> HumanGate
|
|
153
|
+
HumanGate -- Approved --> Recheck
|
|
154
|
+
Recheck --> Outputs["<b>Enterprise Outputs</b><br/>OASIS SARIF v2.1.0 • Dark-Mode HTML Report • Golden Fix Distillation"]
|
|
155
|
+
|
|
156
|
+
classDef ingressStyle fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc;
|
|
157
|
+
classDef scannerStyle fill:#0f172a,stroke:#818cf8,stroke-width:2px,color:#f8fafc;
|
|
158
|
+
classDef govStyle fill:#0f172a,stroke:#34d399,stroke-width:2px,color:#f8fafc;
|
|
159
|
+
classDef ledgerStyle fill:#312e81,stroke:#a78bfa,stroke-width:2px,color:#f8fafc;
|
|
160
|
+
classDef outStyle fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#f8fafc;
|
|
161
|
+
|
|
162
|
+
class ModeA,ModeB,ModeC ingressStyle;
|
|
163
|
+
class AST,OCR,Container,GitMine,ReDoS,AIGuard scannerStyle;
|
|
164
|
+
class Harden,Snapshot,HumanGate,Recheck govStyle;
|
|
165
|
+
class Ledger ledgerStyle;
|
|
166
|
+
class Outputs outStyle;
|
|
136
167
|
```
|
|
137
168
|
|
|
169
|
+
> 🌐 **Interactive Architecture Visualizations:**
|
|
170
|
+
> - [**System Architecture Diagram** (HTML)](docs/architecture/torusguard-architecture.html) — Dynamic zoomable/pannable pipeline with dark/light themes, live view switching (Tri-Mode Ingress, AST Engine, Multi-Modal Vision OCR, Ponytail Bounds, Fail-Closed Recovery), and SVG/PNG export.
|
|
171
|
+
> - [**Governed Remediation Workflow** (HTML)](docs/architecture/torusguard-governance.workflow.html) — Step-by-step visual trace of the 7-stage remediation loop, safety gates, and automatic rollback path.
|
|
172
|
+
|
|
138
173
|
**Key design decisions:**
|
|
139
174
|
- **Tri-Mode Parity:** The CLI (Mode A), Chat Slash Commands (Mode B), and Native MCP Tools (Mode C) share the exact same underlying governance and validation rules.
|
|
140
175
|
- **Multi-Modal Vision OCR:** Images, architecture diagrams, and screenshots are automatically scanned for leaked secrets using Tesseract OCR, bounded by strict 10MB memory safety limits.
|
|
@@ -169,7 +204,7 @@ npx torusguard init
|
|
|
169
204
|
```
|
|
170
205
|
|
|
171
206
|
<a href="https://www.npmjs.com/package/torusguard">
|
|
172
|
-
<img src="https://img.shields.io/badge/npm-v2.
|
|
207
|
+
<img src="https://img.shields.io/badge/npm-v2.1.1-CB3837?logo=npm&logoColor=white" alt="npm package">
|
|
173
208
|
</a>
|
|
174
209
|
|
|
175
210
|
### Option 2: Build from Source (Recommended for Contributors)
|
|
@@ -256,8 +291,14 @@ torusguard exploit-check
|
|
|
256
291
|
| `recipes` | Manage the Golden Fix recipe library |
|
|
257
292
|
| `authorize` | Generate cryptographic auth tokens for runtime probing |
|
|
258
293
|
| `web-validate` | Authorized HTTP probing with `X-TorusGuard-Audit` headers |
|
|
294
|
+
| `exploit-check` | Bounded single-step exploitability confirmation |
|
|
259
295
|
| `ocr-scan` | Run Tesseract OCR secret scan on images/diagrams (<10MB) |
|
|
296
|
+
| `container` | Audit Dockerfile, compose, and container configurations |
|
|
297
|
+
| `git-mine` | Mine git commit history for leaked secrets & creds |
|
|
298
|
+
| `redos` | Analyze regex patterns for catastrophic backtracking |
|
|
299
|
+
| `ai-guard` | Scan AI/LLM code for prompt injection & RAG flaws |
|
|
260
300
|
| `mcp` | Run native Model Context Protocol (MCP) server over stdio |
|
|
301
|
+
| `full` | Master 7-stage closed-loop security governance pipeline |
|
|
261
302
|
| `update` | Self-update the TorusGuard engine |
|
|
262
303
|
| `help` | Show interactive command guide |
|
|
263
304
|
|
|
@@ -272,7 +313,9 @@ TorusGuard/
|
|
|
272
313
|
│ └── mcp.go # Model Context Protocol (MCP) JSON-RPC 2.0 stdio server
|
|
273
314
|
├── internal/
|
|
274
315
|
│ ├── apply/ # Patch application + pre-apply snapshot engine
|
|
275
|
-
│ ├── harden/ # Ponytail Protocol bounds enforcement
|
|
316
|
+
│ ├── harden/ # Ponytail Protocol bounds enforcement & line-level reflection
|
|
317
|
+
│ │ ├── patch.go # Ponytail Protocol bounds verification
|
|
318
|
+
│ │ └── reflection.go # Line-level reflection & semantic replacement
|
|
276
319
|
│ ├── memory/ # Golden Fix recipe persistence
|
|
277
320
|
│ ├── recheck/ # Differential re-scan engine
|
|
278
321
|
│ ├── report/ # SARIF v2.1.0 + dark-mode HTML generators
|
|
@@ -296,28 +339,13 @@ TorusGuard/
|
|
|
296
339
|
|
|
297
340
|
---
|
|
298
341
|
|
|
299
|
-
## 🔒 Security
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
| `TG-INPUT` | Input Sanitization & Traversal | 6 | Strict path sanitization, safe DOM assignments |
|
|
307
|
-
| `TG-RATE` | Rate Limiting & Resources | 3 | Rate-limiting on auth endpoints, payload size bounds |
|
|
308
|
-
| `TG-AGENT` | AI Agent & LLM Injection | 4 | Structural prompt isolation, tool call schema validation |
|
|
309
|
-
| `TG-SSRF` | Server-Side Request Forgery | 4 | Hostname whitelisting, private IP range blocking |
|
|
310
|
-
| `TG-WEBHOOK` | Inbound Webhook Verification | 4 | HMAC-SHA256 signature verification, replay prevention |
|
|
311
|
-
| `TG-WS` | WebSocket & Real-Time | 4 | Origin verification, handshake auth, frame size limits |
|
|
312
|
-
| `TG-CSRF` | Cross-Site Request Forgery | 2 | SameSite cookies, anti-CSRF token verification |
|
|
313
|
-
| `TG-GQL` | GraphQL Safety | 4 | Query depth limiting, introspection suppression |
|
|
314
|
-
| `TG-SUPPLY` | Supply Chain & Dependencies | 6 | Lockfile integrity, known CVE audits |
|
|
315
|
-
| `TG-BIZ` | Business Logic & Workflows | 4 | Negative amount validation, transaction locks |
|
|
316
|
-
| `TG-CACHE` | Cache Poisoning & Timing | 3 | Cache-control headers, unkeyed header sanitization |
|
|
317
|
-
| `TG-CLIENT` | Client Bundle & Frontend | 2 | Zero private env vars in client bundles |
|
|
318
|
-
| `TG-PLATFORM` | Server Hardening & Headers | 4 | Helmet headers, debug suppression, cookie secure flags |
|
|
319
|
-
| `TG-DIFF` | Polyglot Bypass & Churn | 3 | Block `# nosec`, `InsecureSkipVerify`, churn bounds |
|
|
320
|
-
| `TG-EDGE` | Edge Computing & Serverless | 2 | Subrequest fan-out limits, execution timeouts |
|
|
342
|
+
## 🔒 Security Invariants & Rule Governance
|
|
343
|
+
|
|
344
|
+
TorusGuard enforces **88 security invariants across 22 architectural families** covering Secrets, Authentication, Multi-Tenant Database Isolation, Input Sanitization, Rate Limiting, AI Agent Prompt Injection, SSRF, Webhooks, WebSockets, CSRF, GraphQL, Supply Chain, Business Logic, Cache Poisoning, Client Bundles, Platform Headers, Polyglot Bypasses, Edge Timeouts, Container & Docker Safety, Git History Secret Mining, Regular Expression Backtracking (ReDoS), and Vector Database RAG Isolation.
|
|
345
|
+
|
|
346
|
+
> 📘 **Full Rules Catalog & Invariants:**
|
|
347
|
+
> The complete rulebook with formal invariant definitions, severity scores, and testing signatures is maintained in [`AGENTS.md`](AGENTS.md) and the [`rules/`](rules/) directory.
|
|
348
|
+
> You can also explore verified Golden Fix patterns anytime via `torusguard recipes` or stream the live catalog over MCP via `torusguard://rules_catalog`.
|
|
321
349
|
|
|
322
350
|
---
|
|
323
351
|
|
|
@@ -356,10 +384,16 @@ When configured with `.agents/mcp_config.json` or `mcp_config.json`, AI coding a
|
|
|
356
384
|
|
|
357
385
|
- `torusguard_audit`: Deep static AST scan + Vision OCR; writes `security_report.md`
|
|
358
386
|
- `torusguard_ocr_scan`: Dedicated image credential analysis via Tesseract (5-10MB bounds)
|
|
387
|
+
- `torusguard_container`: Audits container files for root execution, docker socket exposure, and privileged mode
|
|
388
|
+
- `torusguard_git_mine`: Mines git commit history and config for leaked credentials and tokens
|
|
389
|
+
- `torusguard_redos`: Analyzes regex patterns for catastrophic exponential backtracking
|
|
390
|
+
- `torusguard_ai_guard`: Audits AI agent prompt templates, tool registries, and vector database queries
|
|
391
|
+
- `torusguard_verify`: Asserts evidence sufficiency & line-shift invariant fingerprint matches
|
|
359
392
|
- `torusguard_harden`: Validates remediation diff against Ponytail Protocol bounds
|
|
360
393
|
- `torusguard_recheck`: Differential re-scan confirming fix closure
|
|
361
394
|
- `torusguard_status`: Workspace posture and tech stack inspection
|
|
362
395
|
- `torusguard://security_report`: MCP Resource reading the living security report
|
|
396
|
+
- `torusguard://rules_catalog`: MCP Resource exploring verified rules catalog & Golden Fix patterns
|
|
363
397
|
|
|
364
398
|
---
|
|
365
399
|
|
|
@@ -369,11 +403,12 @@ TorusGuard undergoes rigorous automated multi-tier testing across polyglot stack
|
|
|
369
403
|
|
|
370
404
|
| Testing Tier | Scope & Target Stacks | Pass Rate | Verified Capabilities |
|
|
371
405
|
| :--- | :--- | :---: | :--- |
|
|
372
|
-
| **Go Engine & Unit Tests** | `cmd/torusguard`, `internal/scanner`, `internal/*` | **100% Passing** | Deterministic AST matching,
|
|
406
|
+
| **Go Engine & Unit Tests** | `cmd/torusguard`, `internal/scanner`, `internal/*` | **100% Passing** | Deterministic AST matching, 88 canonical rule patterns, JSON-RPC 2.0 MCP protocol (133/133 harness tests passing). |
|
|
373
407
|
| **Mass Polyglot Benchmarks** | **20 Enterprise Tech Stacks** (Go, Python, Java, Node, Rust, PHP, C#, Ruby, Svelte, Vue, Angular) | **20/20 Passed** | Framework auto-profiling, heuristic AST analysis, finding deduplication. |
|
|
408
|
+
| **Unseen Tri-Mode Validation** | **6 Unseen Framework Ecosystems** (SvelteKit 2 + Bun, FastAPI AI RAG, DevOps Git Mine, OCR Asset Suite, Kotlin Ktor, Laravel 11) | **6/6 Passed (100%)** | Mode A (CLI) + Mode B (Slash Commands) + Mode C (Native MCP Tools) across 18/18 canonical skills with automated sandbox cleanup. |
|
|
374
409
|
| **Tri-Mode & Vision E2E** | **16 Diverse Framework Repos** (React, Next.js, Express, Django, FastAPI, Spring Boot, etc.) | **16/16 Passed** | Mode A (CLI) + Mode B (Slash Commands) + Mode C (Native MCP Tools) + Multi-Modal Vision OCR. |
|
|
375
|
-
| **Multi-Modal Vision OCR** | Diagram & Image assets (`.png`, `.jpg`,
|
|
376
|
-
| **Ponytail Churn Limits** | Surgical patch validation across all
|
|
410
|
+
| **Multi-Modal Vision OCR** | Diagram & Image assets (`.png`, `.jpg`, `.webp`) via Tesseract v5.4.0 | **100% Recall** | Secrets detection (`TG-SEC-001` - `TG-SEC-007`), 10MB DoS bounding, OCR character substitution tolerance. |
|
|
411
|
+
| **Ponytail Churn Limits** | Surgical patch validation across all 88 rules | **Bounded** | Line bounds (≤35 additions, ≤25 deletions), zero-bypass verification (`TG-DIFF-001`). |
|
|
377
412
|
|
|
378
413
|
All test environments are completely sandboxed, verified with byte-for-byte assertions, and cleaned up automatically.
|
|
379
414
|
|
|
@@ -422,5 +457,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines and [CODE_OF_COND
|
|
|
422
457
|
| [Testing Playbook](docs/usage/testing-playbook.md) | Testing guide and CI integration |
|
|
423
458
|
| [Demo Guide](docs/demo.md) | Quick start and full lifecycle demo |
|
|
424
459
|
| [Roadmap](docs/roadmap.md) | Feature roadmap and release planning |
|
|
460
|
+
| [Unseen Stacks Validation Report](docs/validation/unseen-repos-tri-mode-validation-report.md) | Tri-mode validation across 6 unseen ecosystems & vision OCR |
|
|
425
461
|
| [SECURITY.md](SECURITY.md) | Vulnerability disclosure policy |
|
|
426
462
|
| [CHANGELOG.md](CHANGELOG.md) | Version history and release notes |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torusguard",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Security guardrails, governed remediation, and authorized runtime validation for AI-built web applications.",
|
|
5
5
|
"main": "bin/torusguard.js",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
"harden": "node bin/torusguard.js harden",
|
|
23
23
|
"apply": "node bin/torusguard.js apply",
|
|
24
24
|
"recipes": "node bin/torusguard.js recipes",
|
|
25
|
-
"update": "node bin/torusguard.js update"
|
|
25
|
+
"update": "node bin/torusguard.js update",
|
|
26
|
+
"build": "echo \"No build step required\""
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^26.6.3",
|
|
30
|
+
"typescript": "^5.0.0"
|
|
26
31
|
},
|
|
27
32
|
"keywords": [
|
|
28
33
|
"security",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard
|
|
3
|
-
description: Universal autonomous security engine:
|
|
4
|
-
version: 1.
|
|
3
|
+
description: Universal autonomous security engine: 88 canonical rules across 22 families, polyglot stack detection across 16+ languages, Ponytail remediation bounds (<=35 add, <=25 del), standardized 75-column terminal UI, SARIF v2.1.0 exports, and persistent security memory context.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# TorusGuard Master Security Engine & Command Router
|
|
@@ -10,39 +10,54 @@ version: 1.3.6
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Tri-Mode Execution & Command Catalog
|
|
14
14
|
|
|
15
|
-
TorusGuard operates with 100% feature parity across
|
|
15
|
+
TorusGuard operates with 100% feature parity across the compiled terminal CLI, AI chat slash commands, and Model Context Protocol (MCP) tools:
|
|
16
16
|
|
|
17
|
-
| Capability | Terminal CLI Command | AI Chat Slash Command | Specialist Skill | Purpose |
|
|
17
|
+
| Capability | Terminal CLI Command | AI Chat Slash Command | Specialist Skill | Governed Purpose |
|
|
18
18
|
| :--- | :--- | :--- | :--- | :--- |
|
|
19
|
-
| **Init** | `
|
|
20
|
-
| **Status** | `
|
|
21
|
-
| **Audit** | `
|
|
22
|
-
| **
|
|
23
|
-
| **
|
|
24
|
-
| **
|
|
25
|
-
| **
|
|
26
|
-
| **
|
|
27
|
-
| **
|
|
28
|
-
| **
|
|
29
|
-
| **
|
|
30
|
-
| **
|
|
31
|
-
| **
|
|
32
|
-
| **
|
|
33
|
-
| **
|
|
19
|
+
| **Init** | `torusguard init` | `/torusguard init` | `.torusguard/skills/torusguard-init` | Stack discovery, rule activation, workspace scaffolding |
|
|
20
|
+
| **Status** | `torusguard status` | `/torusguard status` | `.torusguard/skills/torusguard-status` | Posture score, active rules, run history, scope check |
|
|
21
|
+
| **Audit** | `torusguard audit` | `/torusguard audit` | `.torusguard/skills/torusguard-audit` | Static AST scan, invariant fingerprinting, confidence scoring |
|
|
22
|
+
| **OCR Vision**| `torusguard ocr-scan <path>` | `/torusguard ocr-scan` | `.torusguard/skills/torusguard-ocr-scan` | Tesseract OCR secret scan on images/diagrams |
|
|
23
|
+
| **Verify** | `torusguard verify` | `/torusguard verify` | `.torusguard/skills/torusguard-verify` | Evidence sufficiency audit & line match calibration |
|
|
24
|
+
| **Harden** | `torusguard harden <patch>` | `/torusguard harden` | `.torusguard/skills/torusguard-harden` | Ponytail patch formulation ($\le 35$ add, $\le 25$ del) & reflection validation |
|
|
25
|
+
| **Apply** | `torusguard apply [--yes]` | `/torusguard apply` | `.torusguard/skills/torusguard-apply` | Human Gate review, `.bak` snapshots, patch application |
|
|
26
|
+
| **Rollback** | `torusguard rollback` | `/torusguard rollback` | `.torusguard/skills/torusguard-apply` | Instant 1-step rollback from pre-apply snapshots |
|
|
27
|
+
| **Recheck** | `torusguard recheck` | `/torusguard recheck` | `.torusguard/skills/torusguard-recheck` | Targeted differential AST scan, fix closure verification |
|
|
28
|
+
| **Recipes** | `torusguard recipes` | `/torusguard recipes` | `.torusguard/skills/torusguard-harden` | Explore verified Golden Fix Recipes from persistent memory |
|
|
29
|
+
| **Report** | `torusguard report --html` | `/torusguard report` | `.torusguard/skills/torusguard-report` | Executive posture reporting, SARIF v2.1.0 & visual HTML |
|
|
30
|
+
| **Authorize** | `torusguard authorize` | `/torusguard authorize` | `.torusguard/skills/torusguard-authorize`| Legal scope definition & safety boundaries |
|
|
31
|
+
| **Validate** | `torusguard web-validate` | `/torusguard web-validate` | `.torusguard/skills/torusguard-web-validate`| Authorized non-destructive HTTP probing |
|
|
32
|
+
| **Exploit** | `torusguard exploit-check` | `/torusguard exploit-check`| `.torusguard/skills/torusguard-exploit-check`| Bounded single-step exploitability confirmation |
|
|
33
|
+
| **Container** | `torusguard container` | `/torusguard container` | `.torusguard/skills/torusguard-container` | Audits Dockerfile & Compose for root users, sockets, privileged mode |
|
|
34
|
+
| **Git Mine** | `torusguard git-mine` | `/torusguard git-mine` | `.torusguard/skills/torusguard-git-mine` | Mines git commit history & config for leaked credentials & tokens |
|
|
35
|
+
| **ReDoS** | `torusguard redos` | `/torusguard redos` | `.torusguard/skills/torusguard-redos` | Analyzes regex patterns for catastrophic exponential backtracking |
|
|
36
|
+
| **AI Guard** | `torusguard ai-guard` | `/torusguard ai-guard` | `.torusguard/skills/torusguard-ai-guard` | Audits AI agents & RAG pipelines for prompt injection & tenant leaks |
|
|
37
|
+
| **Full** | `torusguard full` | `/torusguard full` | `.torusguard/skills/torusguard-full` | End-to-end 7-stage closed-loop execution |
|
|
38
|
+
| **MCP Server**| `torusguard mcp` | — | Native Stdio JSON-RPC 2.0 | Serves native Model Context Protocol tools to AI coding agents |
|
|
39
|
+
| **Update** | `torusguard update` | `/torusguard update` | `.torusguard/skills/torusguard-init` | Self-update TorusGuard engine binary |
|
|
40
|
+
| **Help** | `torusguard help` | `/torusguard help` | — | Interactive command guide |
|
|
34
41
|
|
|
35
42
|
---
|
|
36
43
|
|
|
37
44
|
## Non-Negotiable Invariants
|
|
38
45
|
|
|
39
|
-
1. **Browser-Code Truth:** If the client receives it, it is public. Zero hardcoded secrets (`SUPABASE_SERVICE_ROLE_KEY`, private tokens, live API keys) in frontend code.
|
|
40
|
-
2. **Multi-Tenant Isolation:** All database lookups must be scoped by organization or user ownership (`tenant_id`, `organization_id`, `where: { tenantId }`).
|
|
46
|
+
1. **Browser-Code Truth:** If the client receives it, it is public. Zero hardcoded secrets (`SUPABASE_SERVICE_ROLE_KEY`, private tokens, live API keys) in frontend code (`TG-CLIENT-001`).
|
|
47
|
+
2. **Multi-Tenant Isolation:** All database lookups must be scoped by organization or user ownership (`tenant_id`, `organization_id`, `where: { tenantId }`) (`TG-DB-001`).
|
|
41
48
|
3. **Ponytail Churn Bounds:** Patches must be minimal and surgical ($\le 35$ additions, $\le 25$ deletions). Never perform full-file rewrites.
|
|
42
49
|
4. **Standardized 75-Column Terminal:** All CLI terminal output is strictly normalized to 75 visual columns with Unicode emoji width calculation, ANSI escape handling, and visual truncation with ellipsis (`...`).
|
|
43
|
-
5. **Zero Security Bypasses:** Never insert `# nosec`, `verify=False`, `InsecureSkipVerify: true`, `[AllowAnonymous]`, or `csrf().disable()
|
|
50
|
+
5. **Zero Security Bypasses:** Never insert `# nosec`, `verify=False`, `InsecureSkipVerify: true`, `[AllowAnonymous]`, or `csrf().disable()` (`TG-DIFF-001`).
|
|
44
51
|
6. **Snapshots Before Edits:** Every code modification must capture a byte-for-byte pre-apply backup in `.torusguard/snapshots/<run_id>/` before touching disk code.
|
|
45
|
-
7. **Living
|
|
52
|
+
7. **Living Report Ground Truth:** All findings synchronize directly with `security_report.md` at workspace root.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🏛️ Alibaba OpenCodeReview Hybrid Architecture Integration
|
|
57
|
+
TorusGuard employs the dual-track hybrid architecture battle-tested at Alibaba Group scale:
|
|
58
|
+
1. **Deterministic Engineering Pipeline (Go CLI Engine):** Mechanical tasks (file traversal, whitespace tolerance, exact AST matching, Ponytail churn bounds calculation, pre-apply snapshot capture, and OCR extraction) are strictly executed by the compiled Go binary.
|
|
59
|
+
2. **Context Minimization (1/9th Token Strategy):** Agents never dump full files into prompt context. Bounded AST windows ($\pm 3$ lines) are extracted via `ExtractContext` to keep review tokens hyper-dense.
|
|
60
|
+
3. **Line-Level Reflection:** In remediation, the agent provides semantic intent (`find_snippet` + `replace_snippet`). The Go CLI reflection module pins and verifies line bounds deterministically, preventing line-number drift.
|
|
46
61
|
|
|
47
62
|
---
|
|
48
63
|
|
|
@@ -68,6 +83,42 @@ TorusGuard operates with 100% feature parity across both the terminal CLI and AI
|
|
|
68
83
|
│ ├── report.html # Single-file visual dark-mode HTML report
|
|
69
84
|
│ ├── results.sarif # OASIS SARIF v2.1.0 log
|
|
70
85
|
│ └── bundles/ # Formulated Ponytail remediation bundles
|
|
86
|
+
├── skills/ # Canonical distribution skills for end-user AI agents
|
|
87
|
+
├── workflows/ # Operational step-by-step workflow guides
|
|
71
88
|
└── snapshots/
|
|
72
89
|
└── run-YYYYMMDD-HHMMSS-audit/ # Pre-apply .bak files for instant rollback
|
|
73
90
|
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 🚨 LLM Trap Table
|
|
95
|
+
|
|
96
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
97
|
+
| :--- | :--- | :--- |
|
|
98
|
+
| **Line-Number Diff Hallucination** | Guesses line numbers in unified diff headers (`@@ -42,5 +42,7 @@`) causing patch rejection. | Use the Line-Level Reflection Module (`SemanticPatch` with `find_snippet` and `replace_snippet`) to let Go resolve exact lines. |
|
|
99
|
+
| **Context Window Bloating** | Dumps entire 1,000-line source files into conversation when diagnosing a single finding. | Use bounded AST context extraction ($\pm 3$ lines) matching OpenCodeReview's 1/9th token efficiency. |
|
|
100
|
+
| **Full-File Rewrites** | Rewrites the entire file or surrounding business logic when fixing a vulnerability. | Strictly conform to Ponytail bounds ($\le 35$ additions, $\le 25$ deletions per bundle). |
|
|
101
|
+
| **Security Bypass Insertion** | Introduces `# nosec`, `verify=False`, or `[AllowAnonymous]` to make tests pass. | Strictly forbidden (`TG-DIFF-001`). Rejections are enforced fail-closed by the Go engine. |
|
|
102
|
+
| **Missing Multi-Tenant Scope** | Modifies queries to filter only by record `id`. | Always scope database lookups by tenant or user ownership (`tenantId: user.tenantId`). |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## ✅ Pre-Flight Self-Audit
|
|
107
|
+
|
|
108
|
+
Before producing any security remediation or analysis, verify:
|
|
109
|
+
- [ ] Did I read `security_report.md` at workspace root before proposing changes?
|
|
110
|
+
- [ ] Did I inspect only the bounded AST context window ($\pm 3$ lines) rather than the entire file?
|
|
111
|
+
- [ ] Does my proposed remediation stay strictly within Ponytail bounds ($\le 35$ additions, $\le 25$ deletions)?
|
|
112
|
+
- [ ] Is the fix free of any `# nosec`, `verify=False`, or bypass flags?
|
|
113
|
+
- [ ] Did I verify multi-tenant isolation on all database and model queries?
|
|
114
|
+
- [ ] Can this patch be applied via deterministic reflection (`find_snippet` -> `replace_snippet`)?
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
VERIFY: Inspect living security_report.md and bounded AST context snippet.
|
|
122
|
+
BUILD: Formulate surgical SemanticPatch (find_snippet + replace_snippet within <=35 add / <=25 del).
|
|
123
|
+
CONFIRM: Validate via torusguard harden, apply snapshot, and execute differential torusguard recheck.
|
|
124
|
+
```
|
|
Binary file
|