torusguard 2.0.0-alpha → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.torusguard/.manifest.json +50 -28
- 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__/manifest_builder.cpython-314.pyc +0 -0
- package/.torusguard/scripts/manifest_builder.py +1 -1
- package/.torusguard/skills/torusguard/SKILL.md +69 -24
- 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 +73 -24
- 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 +28 -46
- 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 +84 -56
- package/package.json +1 -1
- package/skills/torusguard/SKILL.md +71 -24
- package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/skills/torusguard/bootstrap.py +60 -71
- package/skills/torusguard/payload/.manifest.json +50 -28
- 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/manifest_builder.py +1 -1
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +69 -24
- 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 +73 -24
- 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 +27 -51
- 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/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 +73 -24
- 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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-exploit-check
|
|
3
3
|
description: Safe, non-destructive confirmation of exploitability using inert canary tokens and sentinels.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/exploit-check.md
|
|
6
6
|
tools: Read, Grep, Glob, Bash, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
8
9
|
- .torusguard/scripts/report_sync.py
|
|
9
10
|
- .torusguard/scripts/safety_gate.py
|
|
10
11
|
- .torusguard/scripts/finding_scorer.py
|
|
@@ -17,11 +18,21 @@ Confirm whether candidate findings are practically exploitable using safe, singl
|
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
21
|
+
## Tri-Mode Parity
|
|
22
|
+
|
|
23
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
24
|
+
| :--- | :--- | :--- |
|
|
25
|
+
| **Mode A: CLI Terminal** | `torusguard exploit-check` | Dispatches single-step sentinel canaries, confirms exploitability safely. |
|
|
26
|
+
| **Mode B: AI Chat Slash** | `/torusguard exploit-check` | Evaluates reproduction traces and classifies findings into 5 statuses. |
|
|
27
|
+
| **Mode C: Native MCP Tool**| — | Bounded execution guarded by safety gate and inert payloads. |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
20
31
|
## Authorization Gate Check
|
|
21
32
|
Before dispatching any exploitability probe:
|
|
22
33
|
1. Verify target route is explicitly authorized in `.torusguard/config/scope.json`.
|
|
23
34
|
2. Verify authorization TTL has not expired.
|
|
24
|
-
3. Assert probe passes
|
|
35
|
+
3. Assert probe passes safety boundaries.
|
|
25
36
|
|
|
26
37
|
---
|
|
27
38
|
|
|
@@ -37,15 +48,17 @@ Before dispatching any exploitability probe:
|
|
|
37
48
|
|
|
38
49
|
1. **Verify Scope:** Read `scope.json`; assert authorized endpoint.
|
|
39
50
|
2. **Select Canary:** Choose matching non-destructive probe strategy.
|
|
40
|
-
3. **
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
3. **Dispatch Probe:** Send request with header `X-TorusGuard-AuthID`:
|
|
52
|
+
```bash
|
|
53
|
+
torusguard exploit-check --finding TG-SEC-001
|
|
54
|
+
```
|
|
55
|
+
4. **Classify Status:** Transition finding into one of 5 canonical outcomes:
|
|
43
56
|
- `Confirmed`: Canary reflected or secondary tenant data leaked.
|
|
44
57
|
- `Not Reproducible`: Endpoint responded with 401/403 or sanitized input.
|
|
45
58
|
- `Needs Review`: Ambiguous status code or incomplete response.
|
|
46
59
|
- `Blocked by Controls`: WAF or rate limiter stopped probe.
|
|
47
60
|
- `Out of Scope`: Target endpoint is not authorized.
|
|
48
|
-
|
|
61
|
+
5. **Record Evidence:** Save trace in `.torusguard/runs/<run_id>/exploit-evidence.md`.
|
|
49
62
|
|
|
50
63
|
---
|
|
51
64
|
|
|
@@ -68,3 +81,34 @@ Before dispatching any exploitability probe:
|
|
|
68
81
|
- Evidence: <Response snippet or status code>
|
|
69
82
|
Next: Run `/torusguard harden` to formulate surgical remediation bundle.
|
|
70
83
|
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🚨 LLM Trap Table
|
|
88
|
+
|
|
89
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
90
|
+
| :--- | :--- | :--- |
|
|
91
|
+
| **Destructive Payloads** | Generates real data-altering payloads (`'; DROP TABLE users;--`, `<script>evil()</script>`). | Use strictly inert canaries (`' OR 1=1--`, `<tg-canary-tag>`) that cannot destroy state or exfiltrate data. |
|
|
92
|
+
| **Fuzzing Floods** | Runs recursive wordlist fuzzing or multi-hundred request automated attacks. | Enforce single-step bounded confirmation (1-2 deterministic probe requests max). |
|
|
93
|
+
| **False Confirmation** | Declares finding "Confirmed" based on a generic HTTP 500 error without validating the canary reflection. | Require differential response evidence (e.g. reflection of exact sentinel tag or tenant leak). |
|
|
94
|
+
| **Missing Scope Check** | Probes external auth providers (OAuth Google/GitHub) during auth validation. | Confine probes strictly to internal endpoints authorized in `scope.json`. |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ✅ Pre-Flight Self-Audit
|
|
99
|
+
|
|
100
|
+
Before dispatching an exploitability check:
|
|
101
|
+
- [ ] Is the probe payload completely inert and non-destructive?
|
|
102
|
+
- [ ] Is the route explicitly in scope and within TTL?
|
|
103
|
+
- [ ] Is the `X-TorusGuard-AuthID` header attached?
|
|
104
|
+
- [ ] Is the outcome classification mapped to one of the 5 canonical statuses?
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
VERIFY: Check route authorization in scope.json and confirm finding AST context.
|
|
112
|
+
BUILD: Select inert canary token (e.g. <tg-canary-tag>) and construct probe.
|
|
113
|
+
CONFIRM: Evaluate response for differential proof, classify status, and record trace.
|
|
114
|
+
```
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-full
|
|
3
3
|
description: Master 7-stage security pipeline orchestrator — coordinates discovery, authorization, static audit, runtime validation, governed remediation, recheck, and reporting.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/audit.md
|
|
6
6
|
tools: Read, Grep, Glob, Bash, Edit, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
9
|
+
- internal/harden/patch.go
|
|
10
|
+
- internal/apply/apply.go
|
|
8
11
|
- .torusguard/scripts/report_sync.py
|
|
9
|
-
- .torusguard/scripts/stack_detect.py
|
|
10
|
-
- .torusguard/scripts/safety_gate.py
|
|
11
|
-
- .torusguard/scripts/finding_scorer.py
|
|
12
|
-
- .torusguard/scripts/run_manager.py
|
|
13
|
-
- .torusguard/scripts/sarif_exporter.py
|
|
14
12
|
---
|
|
15
13
|
|
|
16
14
|
# TorusGuard Full — Master 7-Stage Pipeline Orchestrator
|
|
@@ -20,15 +18,33 @@ Execute the full, closed-loop TorusGuard security lifecycle from stack discovery
|
|
|
20
18
|
|
|
21
19
|
---
|
|
22
20
|
|
|
21
|
+
## Tri-Mode Pipeline Parity
|
|
22
|
+
|
|
23
|
+
| Stage | Mode A: Terminal CLI | Mode B: AI Chat Slash | Mode C: Native MCP Tool |
|
|
24
|
+
| :--- | :--- | :--- | :--- |
|
|
25
|
+
| **0. Init** | `torusguard init` | `/torusguard init` | Init + `torusguard_status` |
|
|
26
|
+
| **1. Authorize** | `torusguard authorize` | `/torusguard authorize` | Safety Gate Boundary |
|
|
27
|
+
| **2. Audit & Vision** | `torusguard audit` / `ocr-scan` | `/torusguard audit` / `ocr-scan` | `torusguard_audit` / `torusguard_ocr_scan` |
|
|
28
|
+
| **3. Verify** | `torusguard verify` | `/torusguard verify` | `torusguard_verify` |
|
|
29
|
+
| **4. Harden** | `torusguard harden` | `/torusguard harden` | `torusguard_harden` |
|
|
30
|
+
| **5. Apply** | `torusguard apply [--yes]` | `/torusguard apply` | Human Gate Approval |
|
|
31
|
+
| **6. Recheck** | `torusguard recheck` | `/torusguard recheck` | `torusguard_recheck` |
|
|
32
|
+
| **7. Report** | `torusguard report --html` | `/torusguard report` | `torusguard://security_report` |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
23
36
|
## 7-Stage Security Pipeline
|
|
24
|
-
|
|
37
|
+
```
|
|
38
|
+
0. Init ──► 1. Authorize ──► 2. Audit ──► 3. Validate ──► 4. Harden ──► 5. Apply ──► 6. Recheck ──► 7. Report
|
|
39
|
+
(Baseline) (Scope Gate) (AST Scan) (Evidence) (Ponytail) (Human Gate) (Regression) (SARIF/HTML)
|
|
40
|
+
```
|
|
25
41
|
|
|
26
42
|
---
|
|
27
43
|
|
|
28
44
|
## Specialist Skill Routing
|
|
29
45
|
- **Phase 0:** `torusguard-init` (`profiler`)
|
|
30
46
|
- **Phase 1:** `torusguard-authorize` (`reviewer`)
|
|
31
|
-
- **Phase 2:** `torusguard-audit` (`auditor`)
|
|
47
|
+
- **Phase 2:** `torusguard-audit` (`auditor`) / `torusguard-ocr-scan` (`vision`)
|
|
32
48
|
- **Phase 3:** `torusguard-verify` / `torusguard-exploit-check` (`validator`)
|
|
33
49
|
- **Phase 4:** `torusguard-harden` (`remediator`)
|
|
34
50
|
- **Phase 5:** `torusguard-apply` (`remediator`)
|
|
@@ -38,19 +54,14 @@ Execute the full, closed-loop TorusGuard security lifecycle from stack discovery
|
|
|
38
54
|
---
|
|
39
55
|
|
|
40
56
|
## Pipeline Execution Instructions
|
|
41
|
-
1. **Init:** Detect stack via `
|
|
57
|
+
1. **Init:** Detect stack via `torusguard init` and activate tailored rules in `.torusguard/rules/active/`.
|
|
42
58
|
2. **Authorize:** Verify target ownership and TTL in `.torusguard/config/scope.json`.
|
|
43
|
-
3. **Audit:** Scan ASTs; assign fingerprints;
|
|
59
|
+
3. **Audit:** Scan ASTs via `torusguard audit` (or `torusguard ocr-scan` for visual assets); assign fingerprints; compute confidence scores.
|
|
44
60
|
4. **Validate:** Audit evidence sufficiency; optionally send bounded probe canary.
|
|
45
|
-
5. **Harden:** Formulate surgical diffs bound by Ponytail limits ($\le 35$
|
|
46
|
-
6. **Apply:**
|
|
47
|
-
7. **Recheck:** Re-scan modified files
|
|
48
|
-
8. **Report:** Export OASIS SARIF v2.1.0 and emit
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Confidence Scoring Rubric
|
|
53
|
-
Evaluates Evidence (35 pts), Reproduction (25 pts), Corroboration (15 pts), Environment (15 pts), and Review Status (10 pts) into 4 bands: Confirmed (90–100), High (70–89), Medium (50–69), Needs Review (<50).
|
|
61
|
+
5. **Harden:** Formulate surgical diffs bound by Ponytail limits ($\le 35$ additions, $\le 25$ deletions).
|
|
62
|
+
6. **Apply:** Capture `.bak` snapshot in `.torusguard/snapshots/`; obtain Human Gate; apply patch via `torusguard apply`.
|
|
63
|
+
7. **Recheck:** Re-scan modified files via `torusguard recheck`; assert findings are `Fixed` with zero regressions.
|
|
64
|
+
8. **Report:** Export OASIS SARIF v2.1.0 and emit visual HTML dashboard via `torusguard report --html`.
|
|
54
65
|
|
|
55
66
|
---
|
|
56
67
|
|
|
@@ -62,6 +73,7 @@ Evaluates Evidence (35 pts), Reproduction (25 pts), Corroboration (15 pts), Envi
|
|
|
62
73
|
- Human Gate mandatory before code modifications in Phase 5.
|
|
63
74
|
- Enforce Ponytail line bounds ($\le 35$ additions, $\le 25$ deletions).
|
|
64
75
|
- Never dispatch network probes outside authorized scope in `scope.json`.
|
|
76
|
+
- Zero security bypasses permitted (`TG-DIFF-001`).
|
|
65
77
|
|
|
66
78
|
---
|
|
67
79
|
|
|
@@ -73,3 +85,34 @@ Evaluates Evidence (35 pts), Reproduction (25 pts), Corroboration (15 pts), Envi
|
|
|
73
85
|
- SARIF Log: `.torusguard/runs/<run_id>/results.sarif`
|
|
74
86
|
- Report: `.torusguard/runs/<run_id>/report.md`
|
|
75
87
|
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 🚨 LLM Trap Table
|
|
92
|
+
|
|
93
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| **Pipeline Step Skipping** | Jumps directly from Audit to Apply without verifying evidence or validating Ponytail patch bounds. | Follow the 7 stages in sequential order; each stage gate must be satisfied. |
|
|
96
|
+
| **Human Gate Bypass** | Writes modifications directly to disk without presenting candidate diffs or awaiting user confirmation. | Always require explicit Human Gate confirmation before Phase 5 (`torusguard apply`). |
|
|
97
|
+
| **Full File Rewrites** | Rewrites complete source files during remediation, causing massive line churn and regression risk. | Formulate surgical patches respecting Ponytail bounds ($\le 35$ add, $\le 25$ del) using Line-Level Reflection. |
|
|
98
|
+
| **Unsynchronized State** | Generates reports that don't match the statuses in `security_report.md`. | Keep `security_report.md` synchronized at every phase transition as the single living source of truth. |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## ✅ Pre-Flight Self-Audit
|
|
103
|
+
|
|
104
|
+
Before orchestrating the full pipeline:
|
|
105
|
+
- [ ] Are all prerequisite tools (`torusguard` binary) available?
|
|
106
|
+
- [ ] Is `security_report.md` inspected prior to initiating any scans or fixes?
|
|
107
|
+
- [ ] Are all patches bounded by Ponytail limits and verified without security bypasses?
|
|
108
|
+
- [ ] Is a `.bak` snapshot captured before any disk modification?
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
VERIFY: Review current workspace security posture and verify phase prerequisites.
|
|
116
|
+
BUILD: Execute the pipeline stage by stage using designated specialist skills.
|
|
117
|
+
CONFIRM: Validate final SARIF, HTML report, and synchronized security_report.md.
|
|
118
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-git-mine
|
|
3
|
+
description: Mines git commit history, commit diffs, and local repository metadata for leaked credentials, private keys, and historical API tokens via CLI, Chat, or MCP.
|
|
4
|
+
version: 2.0.0
|
|
5
|
+
workflow: .torusguard/workflows/git-mine.md
|
|
6
|
+
tools: Read, Grep, Glob, Write, run_command
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- internal/scanner/git_mine.go
|
|
9
|
+
- cmd/torusguard/main.go
|
|
10
|
+
- cmd/torusguard/mcp.go
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# TorusGuard Git History Secret Mining
|
|
14
|
+
|
|
15
|
+
## Objective
|
|
16
|
+
Inspect local `.git` metadata, remote configurations, and commit logs across the repository's commit history to identify leaked API tokens, private keys, database URIs, and credentials that were committed in past revisions or embedded in remote URLs.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Tri-Mode Execution
|
|
21
|
+
|
|
22
|
+
### Mode A: Automated CLI Execution
|
|
23
|
+
Run Git history mining against current repository or specified target workspace:
|
|
24
|
+
```bash
|
|
25
|
+
# Mine Git commit history and .git/config in current workspace
|
|
26
|
+
torusguard git-mine
|
|
27
|
+
|
|
28
|
+
# Mine specific repository target
|
|
29
|
+
torusguard git-mine --target /path/to/repo
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Mode B: In-Session AI Chat Slash Command
|
|
33
|
+
Run `/torusguard git-mine` in chat.
|
|
34
|
+
The agent executes the compiled Go Git mining engine or MCP tool to inspect commit history logs, detect historical secret leaks, and provide provider revocation guidance.
|
|
35
|
+
|
|
36
|
+
### Mode C: Native MCP Tool Call
|
|
37
|
+
MCP-enabled coding agents (Antigravity, Cursor, Windsurf, Claude Code) call:
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"tool": "torusguard_git_mine",
|
|
41
|
+
"arguments": {
|
|
42
|
+
"target": "."
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Supported Patterns & Invariants
|
|
50
|
+
- **TG-GIT-001 (Historical Secret Commit):** Detects API keys (OpenAI `sk-...`, AWS `AKIA...`, GitHub `ghp_...`), private certificates, or database credentials introduced in prior git commits even if removed from the current working tree.
|
|
51
|
+
- **TG-GIT-002 (Plaintext Remote Credentials):** Flags remote URLs in `.git/config` containing basic authentication credentials (`https://user:token@github.com/...`).
|
|
52
|
+
- **TG-GIT-003 (Sensitive File History Tracking):** Detects tracked `.env`, `id_rsa`, `.pem`, or `.key` files in git log metadata that bypass `.gitignore`.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🏛️ OpenCodeReview Hybrid Architecture Integration
|
|
57
|
+
- **Deterministic History Inspection:** Analyzes commit logs via local Git commands or fallback file reading with strict 5-second timeouts and bounded commit depths.
|
|
58
|
+
- **Token Minimization:** Emits commit SHA, author timestamp, and redacted secret preview rather than dumping full commit logs into LLM context.
|
|
59
|
+
- **Revocation-First Governance:** Prioritizes immediate credential revocation at the provider (OpenAI, AWS, GitHub) before history rewrites (`git filter-repo` / BFG).
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🚨 LLM Trap Table
|
|
64
|
+
|
|
65
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
66
|
+
| :--- | :--- | :--- |
|
|
67
|
+
| **Working Tree Only Bias** | Only scans files currently on disk, assuming deleted secrets are safely removed. | Always mine Git commit history (`git log -p`) because Git never forgets past commits. |
|
|
68
|
+
| **Token in Remote Origin URL** | Recommends `git remote set-url origin https://ghp_xxx@github.com/...` which writes token to disk in plaintext. | Use SSH keys, GitHub CLI (`gh auth login`), or credential helpers (`git credential-manager`). |
|
|
69
|
+
| **History Rewriting Over Revocation** | Recommends scrubbing Git history before revoking the leaked secret at the cloud provider. | Always rotate and revoke the credential immediately at the provider first; assume it was scraped. |
|
|
70
|
+
| **Single Commit Amends** | Recommends `git commit --amend` when the secret was committed 5 commits ago. | Use `git rebase -i` or `git-filter-repo` for deeper historical scrubbing. |
|
|
71
|
+
| **Tracking .env in Git** | Adds `.env` to `.gitignore` without running `git rm --cached .env`, leaving file tracked. | Run `git rm --cached <file>` so Git stops tracking the sensitive file in subsequent commits. |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## ✅ Pre-Flight Self-Audit
|
|
76
|
+
|
|
77
|
+
Before concluding a Git repository security audit, verify:
|
|
78
|
+
- [ ] Is `.git` directory present and valid?
|
|
79
|
+
- [ ] Were remote URLs in `.git/config` checked for embedded plaintext passwords or tokens?
|
|
80
|
+
- [ ] Were the most recent 50 commits audited for added secrets in commit diffs?
|
|
81
|
+
- [ ] Did I verify whether `.env` or private keys were ever tracked in git history?
|
|
82
|
+
- [ ] Was the user instructed to rotate/revoke leaked keys at the provider immediately?
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
VERIFY: Confirm workspace is a valid Git repository with accessible commit history.
|
|
90
|
+
BUILD: Execute torusguard git-mine or torusguard_git_mine to detect historical leaks and credential configs.
|
|
91
|
+
CONFIRM: Provide immediate rotation steps, clean .git/config, and scrub historical commits via git-filter-repo.
|
|
92
|
+
```
|
|
@@ -1,78 +1,80 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-harden
|
|
3
3
|
description: Package surgical remediation bundles conforming to the Ponytail Protocol (<= 35 additions, <= 25 deletions) via CLI or AI Agent.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/harden.md
|
|
6
6
|
tools: Read, Grep, Glob, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
8
|
+
- internal/harden/harden.go
|
|
9
|
+
- internal/harden/patch.go
|
|
10
|
+
- internal/harden/reflection.go
|
|
11
|
+
- cmd/torusguard/main.go
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# TorusGuard Harden — Governed Remediation & Bundle Packaging
|
|
15
15
|
|
|
16
16
|
## Objective
|
|
17
|
-
Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$ additions, $\le 25$ deletions), packaging unified diffs into auditable remediation bundles ready for review.
|
|
17
|
+
Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$ additions, $\le 25$ deletions), packaging unified diffs or semantic reflection patches into auditable remediation bundles ready for review.
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Tri-Mode Execution
|
|
22
22
|
|
|
23
23
|
### Mode A: Automated CLI Execution (Recommended First Step)
|
|
24
24
|
Run the autonomous remediation engine via the terminal:
|
|
25
25
|
```bash
|
|
26
|
-
#
|
|
27
|
-
|
|
26
|
+
# Validate candidate patch or semantic patch against Ponytail bounds
|
|
27
|
+
torusguard harden candidate.patch
|
|
28
28
|
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# Harden specific run ID
|
|
33
|
-
npx torusguard harden --run run-20260910-121618-audit
|
|
34
|
-
|
|
35
|
-
# Machine-readable JSON output
|
|
36
|
-
npx torusguard harden --json
|
|
29
|
+
# Validate semantic JSON patch
|
|
30
|
+
torusguard harden patch.json
|
|
37
31
|
```
|
|
38
|
-
**Under the Hood:** Executes `
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
- Packages candidate bundles into `.torusguard/runs/<run_id>/bundles/<bundle_id>/` containing `patch.diff`, `minimal_patch_plan.md`, and `metadata.json`.
|
|
43
|
-
- Emits run-level summary `remediation.md`.
|
|
32
|
+
**Under the Hood:** Executes compiled Go hardening engine (`internal/harden`).
|
|
33
|
+
- Evaluates patch churn strictly against Ponytail bounds ($\le 35$ additions, $\le 25$ deletions).
|
|
34
|
+
- Scans replacement code for security bypasses (`# nosec`, `verify=False`, `InsecureSkipVerify: true`).
|
|
35
|
+
- Supports both unified diff files (`.diff`, `.patch`) and Semantic Reflection JSON files.
|
|
44
36
|
- Renders pixel-perfect 75-column terminal cards.
|
|
45
37
|
|
|
46
38
|
### Mode B: In-Session AI Chat Agent Remediation
|
|
47
|
-
When findings require complex architectural changes, or when
|
|
48
|
-
1. **Locate Target Finding:** Inspect
|
|
49
|
-
2. **Inspect AST Context:**
|
|
50
|
-
3. **Formulate Minimal
|
|
39
|
+
When findings require complex architectural changes, or when formulating fixes:
|
|
40
|
+
1. **Locate Target Finding:** Inspect `security_report.md` at workspace root.
|
|
41
|
+
2. **Inspect AST Context (1/9th Token Strategy):** Inspect only surrounding lines ($\pm 3$ lines) via `ExtractContext` rather than ingesting entire files.
|
|
42
|
+
3. **Formulate Minimal Semantic Patch:** Formulate a surgical code modification using the Line-Level Reflection Module:
|
|
43
|
+
- Provide `target_file`, `find_snippet`, and `replace_snippet`.
|
|
51
44
|
- Parameterize SQL queries (replace concatenation with `?` or `$1` or `%s`).
|
|
52
|
-
- Add tenant isolation (`where: { tenantId }
|
|
53
|
-
- Replace unsafe HTML injection
|
|
54
|
-
- Sanitize path traversal using `
|
|
55
|
-
-
|
|
56
|
-
- Restore TLS verification flags (`verify=True`, `rejectUnauthorized: true`).
|
|
45
|
+
- Add tenant isolation (`where: { tenantId: user.tenantId }`).
|
|
46
|
+
- Replace unsafe HTML injection with safe text rendering (`textContent`).
|
|
47
|
+
- Sanitize path traversal using `filepath.Base()` or `path.basename()`.
|
|
48
|
+
- Restore TLS verification flags.
|
|
57
49
|
4. **Validate Ponytail Bounds:** Count additions ($\le 35$) and deletions ($\le 25$). Never perform full-file rewrites.
|
|
58
|
-
5. **
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
5. **Report to Operator:** Present proposed diff card and recommend running `/torusguard apply` or `torusguard apply`.
|
|
51
|
+
|
|
52
|
+
### Mode C: Native MCP Tool Execution
|
|
53
|
+
For autonomous AI coding agents (Antigravity, Cursor, Windsurf, Claude Code):
|
|
54
|
+
- **Tool Invocation:** Call `torusguard_harden` with semantic reflection arguments:
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"target_file": "src/controllers/userController.js",
|
|
58
|
+
"find_snippet": "const query = `SELECT * FROM users WHERE id = ${req.params.id}`;",
|
|
59
|
+
"replace_snippet": "const query = 'SELECT * FROM users WHERE id = ? AND tenant_id = ?';\nconst params = [req.params.id, req.user.tenantId];"
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
- **Programmatic Return:** Receives exact line ranges matched by Go AST, calculated additions/deletions, and verification that no `# nosec` or security bypasses exist.
|
|
63
63
|
|
|
64
64
|
---
|
|
65
65
|
|
|
66
|
-
##
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
## 🏛️ Line-Level Reflection Module (OpenCodeReview Hybrid Engine)
|
|
67
|
+
Instead of forcing the LLM to guess error-prone unified diff line offsets (`@@ -14,6 +14,8 @@`), TorusGuard allows formulating **Semantic Patches**:
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"target_file": "server/index.js",
|
|
71
|
+
"rule_id": "TG-SEC-001",
|
|
72
|
+
"find_snippet": "const jwtSecret = 'hardcoded-dev-secret-key-12345';",
|
|
73
|
+
"replace_snippet": "const jwtSecret = process.env.JWT_SECRET;",
|
|
74
|
+
"rationale": "Extracted hardcoded JWT secret to environment variable"
|
|
75
|
+
}
|
|
75
76
|
```
|
|
77
|
+
The Go engine deterministically matches `find_snippet` against the target file, counts additions/deletions, verifies Ponytail bounds, and guarantees zero line-number drift.
|
|
76
78
|
|
|
77
79
|
---
|
|
78
80
|
|
|
@@ -90,9 +92,38 @@ When findings require complex architectural changes, or when the automated CLI c
|
|
|
90
92
|
- **Target Finding:** `[TG-SEC-001]` at `server/index.js:9`
|
|
91
93
|
- **Ponytail Churn:** +1 / -1 (Compliant <= 35 add, <= 25 del)
|
|
92
94
|
- **Strategy:** Migrated hardcoded JWT secret to environment variable process.env.JWT_SECRET
|
|
93
|
-
- **
|
|
94
|
-
- **Next Step:** Run `
|
|
95
|
+
- **Mode:** Line-Level Reflection Match (Semantic Patch)
|
|
96
|
+
- **Next Step:** Run `torusguard apply` or `/torusguard apply` to review and apply
|
|
95
97
|
```
|
|
96
98
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🚨 LLM Trap Table
|
|
102
|
+
|
|
103
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
104
|
+
| :--- | :--- | :--- |
|
|
105
|
+
| **Line-Number Drift** | Formulates diff headers with estimated line numbers that fail `git apply`. | Use semantic patches (`find_snippet` -> `replace_snippet`) so Go reflection pins line bounds. |
|
|
106
|
+
| **Exceeding Ponytail Budget** | Produces patches with +50 additions or +40 deletions rewriting surrounding logic. | Split complex remediations or keep changes surgical ($\le 35$ additions, $\le 25$ deletions). |
|
|
107
|
+
| **Introducing Bypass Flags** | Inserts `# nosec`, `verify=False`, or `@csrf_exempt` to quickly silence warnings. | Fix the root cause without disabling security invariants. Bypasses trigger immediate error. |
|
|
108
|
+
| **Formatting Unrelated Lines** | Re-indents or cleans up imports in unrelated sections of the target file. | Zero unrelated churn. Touch only the lines required for vulnerability remediation. |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## ✅ Pre-Flight Self-Audit
|
|
113
|
+
|
|
114
|
+
Before formulating a remediation bundle, verify:
|
|
115
|
+
- [ ] Did I read only the bounded AST context window ($\pm 3$ lines) to keep tokens minimal?
|
|
116
|
+
- [ ] Is `find_snippet` an exact, verbatim substring of the target file?
|
|
117
|
+
- [ ] Are total additions $\le 35$ and deletions $\le 25$?
|
|
118
|
+
- [ ] Does `replace_snippet` strictly avoid any bypass flags (`# nosec`, `verify=False`)?
|
|
119
|
+
- [ ] Does the fix preserve existing application behavior and business contracts?
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
VERIFY: Inspect target finding context and verify verbatim match of find_snippet in source code.
|
|
127
|
+
BUILD: Formulate minimal SemanticPatch or unified diff conforming to Ponytail budget (<=35 add, <=25 del).
|
|
128
|
+
CONFIRM: Validate via torusguard harden or torusguard_harden MCP tool; verify zero bypass rejections.
|
|
129
|
+
```
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-init
|
|
3
3
|
description: Initialize TorusGuard workspace — detect project stack, activate tailored TG-* security rules, and generate SECURITY.md baseline via CLI or AI Agent.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/init.md
|
|
6
6
|
tools: Read, Grep, Glob, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
8
9
|
- .torusguard/scripts/report_sync.py
|
|
9
10
|
- .torusguard/scripts/stack_detect.py
|
|
10
|
-
- .torusguard/scripts/term_ui.py
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
# TorusGuard Init — Project Stack Discovery & Rule Activation
|
|
@@ -17,26 +17,37 @@ Auto-detect repository technology stack across 16+ languages and frameworks, pro
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Tri-Mode Parity
|
|
21
|
+
|
|
22
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Mode A: CLI Terminal** | `torusguard init` | Profiles workspace, provisions directories, activates tailored rules. |
|
|
25
|
+
| **Mode B: AI Chat Slash** | `/torusguard init` | Inspects workspace dependencies and guides baseline rule activation. |
|
|
26
|
+
| **Mode C: Native MCP Tool**| — | Workspace initialization is an administrative setup command. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Tri-Mode Execution
|
|
21
31
|
|
|
22
32
|
### Mode A: Automated CLI Execution
|
|
23
33
|
Run the workspace initializer from your terminal:
|
|
24
34
|
```bash
|
|
25
35
|
# Initialize current repository
|
|
26
|
-
|
|
36
|
+
torusguard init
|
|
27
37
|
|
|
28
38
|
# Initialize specific directory
|
|
29
|
-
|
|
39
|
+
torusguard init ./my-app
|
|
30
40
|
|
|
31
41
|
# Force re-initialization (overwriting existing configuration)
|
|
32
|
-
|
|
42
|
+
torusguard init --force
|
|
33
43
|
|
|
34
|
-
# Explicitly specify stack (e.g. react, nextjs, django, fastapi, express)
|
|
35
|
-
|
|
44
|
+
# Explicitly specify stack (e.g. react, nextjs, django, fastapi, express, go)
|
|
45
|
+
torusguard init --stack express
|
|
36
46
|
```
|
|
47
|
+
|
|
37
48
|
**Under the Hood:**
|
|
38
|
-
-
|
|
39
|
-
- Detects backend frameworks, frontend libraries, ORMs (Prisma, Mongoose, SQLAlchemy, Django ORM), and authentication systems.
|
|
49
|
+
- Inspects package files (`package.json`, `pyproject.toml`, `requirements.txt`, `go.mod`, `Cargo.toml`, `Gemfile`, `composer.json`, `*.csproj`).
|
|
50
|
+
- Detects backend frameworks, frontend libraries, ORMs (Prisma, Mongoose, SQLAlchemy, Django ORM, GORM), and authentication systems.
|
|
40
51
|
- Scaffolds `.torusguard/` directory tree: `config/`, `rules/active/`, `runs/`, `scripts/`, `workflows/`, `templates/`, `schemas/`, `memory/`, `snapshots/`.
|
|
41
52
|
- Copies tailored rule definitions into `.torusguard/rules/active/`.
|
|
42
53
|
- Provisions `SECURITY.md` with standard responsible disclosure contacts.
|
|
@@ -45,12 +56,17 @@ npx torusguard init --stack express
|
|
|
45
56
|
|
|
46
57
|
### Mode B: In-Session AI Chat Agent Initialization
|
|
47
58
|
When initializing a workspace directly in AI chat:
|
|
48
|
-
1. **Detect Stack:** Inspect root files (`package.json`, `requirements.txt`, etc.) to determine languages and frameworks.
|
|
49
|
-
2. **Bootstrap Structure:** Ensure `.torusguard/` structure exists.
|
|
59
|
+
1. **Detect Stack:** Inspect root files (`package.json`, `go.mod`, `requirements.txt`, etc.) to determine languages and frameworks.
|
|
60
|
+
2. **Bootstrap Structure:** Ensure `.torusguard/` structure exists.
|
|
50
61
|
3. **Activate Rules:** Populate `.torusguard/rules/active/` with applicable rule files from `rules/`.
|
|
51
62
|
4. **Provision Policy:** Create `SECURITY.md` if not already present.
|
|
52
63
|
5. **Write Configuration:** Persist settings into `.torusguard/config/torusguard.json`.
|
|
53
|
-
6. **Prompt Audit:** Advise the user to run `
|
|
64
|
+
6. **Prompt Audit:** Advise the user to run `torusguard audit` or `/torusguard audit`.
|
|
65
|
+
|
|
66
|
+
### Mode C: Native MCP Tool Integration
|
|
67
|
+
For autonomous AI coding agents (Antigravity, Cursor, Windsurf, Claude Code):
|
|
68
|
+
- **Administrative Provisioning:** Agents prompt or invoke `torusguard init` to scaffold workspace boundaries.
|
|
69
|
+
- **Posture Verification:** Once initialized, agents query `torusguard_status` via MCP to inspect active rules and verify initialization state.
|
|
54
70
|
|
|
55
71
|
---
|
|
56
72
|
|
|
@@ -61,8 +77,39 @@ When initializing a workspace directly in AI chat:
|
|
|
61
77
|
- **Active Rules:** 74 canonical security rules enabled in `.torusguard/rules/active/`
|
|
62
78
|
- **Configuration:** Written to `.torusguard/config/torusguard.json`
|
|
63
79
|
- **Security Policy:** Baseline `SECURITY.md` generated
|
|
64
|
-
- **Next Step:** Run `
|
|
80
|
+
- **Next Step:** Run `torusguard audit` or `/torusguard audit` to scan for flaws
|
|
65
81
|
```
|
|
66
82
|
|
|
67
83
|
## Living Report Ground Truth
|
|
68
84
|
- Read `security_report.md` in the workspace root before taking any action. Update the relevant finding card after completing remediation.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🚨 LLM Trap Table
|
|
89
|
+
|
|
90
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
91
|
+
| :--- | :--- | :--- |
|
|
92
|
+
| **Destructive Overwrite** | Overwrites user-customized `.torusguard/rules/active/` without checking `--force`. | Preserve existing customized rules unless `--force` is explicitly provided. |
|
|
93
|
+
| **Generic Stack Guess** | Guesses Node.js without reading `go.mod`, `pyproject.toml`, or `Cargo.toml` in the repository. | Check actual package manifests to detect real multi-language frameworks. |
|
|
94
|
+
| **Root Directory Clutter** | Spills temporary configuration files across root instead of isolating inside `.torusguard/config/`. | Confine all configuration, snapshots, and run artifacts strictly within `.torusguard/`. |
|
|
95
|
+
| **Missing SECURITY.md** | Fails to verify whether responsible disclosure policy already exists before creating a new one. | Check for existing `SECURITY.md` at workspace root; avoid clobbering existing policies. |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ✅ Pre-Flight Self-Audit
|
|
100
|
+
|
|
101
|
+
Before initializing a workspace:
|
|
102
|
+
- [ ] Did I inspect root manifests (`go.mod`, `package.json`, etc.) to identify the true technology stack?
|
|
103
|
+
- [ ] Did I verify whether `.torusguard/` is already initialized?
|
|
104
|
+
- [ ] Did I check if `SECURITY.md` already exists before writing?
|
|
105
|
+
- [ ] Are all directories properly scoped to `.torusguard/`?
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
VERIFY: Check workspace root for manifest files and existing .torusguard configuration.
|
|
113
|
+
BUILD: Generate directory tree, configure tailored TG-* rules, and draft SECURITY.md.
|
|
114
|
+
CONFIRM: Verify .torusguard/config/torusguard.json is valid JSON and notify user of readiness.
|
|
115
|
+
```
|