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-web-validate
|
|
3
3
|
description: Execute authorized HTTP probing against local/staging web applications — session capture, transparent audit headers, and secret redaction.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/web-validate.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
|
---
|
|
@@ -16,16 +17,27 @@ Safely probe live web applications within authorized scope, injecting transparen
|
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
20
|
+
## Tri-Mode Parity
|
|
21
|
+
|
|
22
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Mode A: CLI Terminal** | `torusguard web-validate` | Dispatches bounded HTTP probes with transparent audit headers and redaction. |
|
|
25
|
+
| **Mode B: AI Chat Slash** | `/torusguard web-validate` | Interactive verification of endpoints, security headers, and cookie flags. |
|
|
26
|
+
| **Mode C: Native MCP Tool**| — | Safe runtime execution guarded by scope.json boundaries. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
19
30
|
## Authorization Gate Check
|
|
20
31
|
Before dispatching any HTTP request:
|
|
21
32
|
1. Verify `.torusguard/config/scope.json` exists and contains target URL.
|
|
22
33
|
2. Confirm current timestamp is prior to `expires_at` TTL.
|
|
23
34
|
3. Assert target is local or non-production staging.
|
|
35
|
+
4. **SSRF Boundary Enforcement:** Resolve target IP and assert it does not target cloud metadata endpoints (`169.254.169.254`) or unintended internal subnets (`127.0.0.1` unless explicitly authorized as local dev).
|
|
24
36
|
|
|
25
37
|
---
|
|
26
38
|
|
|
27
39
|
## Safety Gate
|
|
28
|
-
All requests pass through
|
|
40
|
+
All requests pass through safety boundary checks:
|
|
29
41
|
- `Auto-Allowed`: Read-only `GET`, `HEAD`, `OPTIONS` on non-sensitive paths.
|
|
30
42
|
- `Approval Required`: Requests touching auth, sessions, or parameters.
|
|
31
43
|
- `Manual Only`: Any destructive method (`DELETE`, `DROP`) is strictly blocked.
|
|
@@ -34,13 +46,15 @@ All requests pass through `.torusguard/scripts/safety_gate.py`:
|
|
|
34
46
|
|
|
35
47
|
## Execution Steps
|
|
36
48
|
|
|
37
|
-
1. **Gate Check:** Validate scope in `scope.json
|
|
38
|
-
2. **
|
|
49
|
+
1. **Gate Check:** Validate scope in `scope.json`.
|
|
50
|
+
2. **Execute Probe:**
|
|
51
|
+
```bash
|
|
52
|
+
torusguard web-validate --target http://localhost:3000
|
|
53
|
+
```
|
|
39
54
|
3. **Inject Audit Header:** Attach `X-TorusGuard-AuthID: <auth_id>` to all outbound requests.
|
|
40
|
-
4. **
|
|
41
|
-
5. **
|
|
42
|
-
6. **
|
|
43
|
-
7. **Capture Replay Trace:** Save sanitized trace in `.torusguard/runs/<run_id>/requests.json`.
|
|
55
|
+
4. **Validate Security Headers:** Check for CSP, HSTS, X-Content-Type-Options, and CORS configurations.
|
|
56
|
+
5. **Audit Cookie Flags:** Verify `HttpOnly`, `Secure`, and `SameSite` on session cookies.
|
|
57
|
+
6. **Capture Replay Trace:** Save sanitized trace in `.torusguard/runs/<run_id>/requests.json`.
|
|
44
58
|
|
|
45
59
|
---
|
|
46
60
|
|
|
@@ -68,3 +82,34 @@ All Bearer tokens, cookies, passwords, and API keys are redacted prior to disk s
|
|
|
68
82
|
- Replay Trace: `.torusguard/runs/<run_id>/requests.json`
|
|
69
83
|
Next: Run `/torusguard exploit-check` to confirm exploitability of candidate flaws.
|
|
70
84
|
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🚨 LLM Trap Table
|
|
89
|
+
|
|
90
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
91
|
+
| :--- | :--- | :--- |
|
|
92
|
+
| **Scope Bypass Probing** | Sends HTTP requests to arbitrary endpoints without validating `.torusguard/config/scope.json`. | Check `scope.json` and verify TTL before every outbound probe. |
|
|
93
|
+
| **Token Exposure in Traces** | Writes unredacted `Authorization: Bearer <secret>` or session cookies to `requests.json`. | Redact all credentials to `[REDACTED]` before saving traces to disk. |
|
|
94
|
+
| **SSRF Blindness** | Follows redirects or probes endpoints pointing to AWS/GCP metadata (`169.254.169.254`). | Block private IP ranges and metadata addresses under invariant 9. |
|
|
95
|
+
| **Unbounded Flooding** | Launches high-concurrency request loops or stress tests against local dev server. | Enforce rate limiting and cap session probes to maximum 50 requests. |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ✅ Pre-Flight Self-Audit
|
|
100
|
+
|
|
101
|
+
Before dispatching web probes:
|
|
102
|
+
- [ ] Is the target URL verified inside `scope.json` and within valid TTL?
|
|
103
|
+
- [ ] Are transparent audit headers (`X-TorusGuard-AuthID`) attached?
|
|
104
|
+
- [ ] Are destructive operations (`DELETE`, drops) blocked?
|
|
105
|
+
- [ ] Are sensitive tokens and cookies redacted from trace logs?
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
VERIFY: Check scope.json validity, TTL, and SSRF boundaries for the target URL.
|
|
113
|
+
BUILD: Construct bounded HTTP request with X-TorusGuard-AuthID audit header.
|
|
114
|
+
CONFIRM: Redact sensitive tokens and save sanitized trace into requests.json.
|
|
115
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# /torusguard-ai-guard — AI Application & RAG Pipeline Guard
|
|
2
|
+
|
|
3
|
+
$ARGUMENTS
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Objective
|
|
8
|
+
Detect and remediate prompt injection, unsandboxed autonomous tool executions, and cross-tenant vector contamination across AI agent and RAG architectures.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Tri-Mode Parity
|
|
13
|
+
- **Mode A (Terminal CLI):** `torusguard ai-guard [target]`
|
|
14
|
+
- **Mode B (AI Chat Slash Command):** `/torusguard ai-guard [target]`
|
|
15
|
+
- **Mode C (Native MCP Tool):** `torusguard_ai_guard`
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Discover LLM & Agent Call Sites:** Locate AI framework usage (OpenAI, Anthropic, LangChain, LlamaIndex, Vercel AI SDK).
|
|
22
|
+
2. **Audit Prompt Templates:**
|
|
23
|
+
- Detect raw user string concatenation into system instructions (`TG-AGENT-001`).
|
|
24
|
+
- Flag raw document chunk ingestion in RAG without inert delimiters (`TG-RAG-002`).
|
|
25
|
+
3. **Audit Tool Registry & Dispatchers:**
|
|
26
|
+
- Check for unsandboxed shell, file, or database tool calls lacking Human Gates (`TG-AGENT-002`).
|
|
27
|
+
- Enforce Zod/Pydantic schema validation on all tool argument payloads (`TG-AGENT-003`).
|
|
28
|
+
4. **Audit Vector Store Queries:**
|
|
29
|
+
- Assert all similarity searches (`pgvector`, `pinecone`, `qdrant`, `chroma`) include tenant/user metadata filters (`TG-RAG-001`).
|
|
30
|
+
- Flag ingestion of unvalidated external document payloads (`TG-RAG-003`).
|
|
31
|
+
5. **Formulate Patches & Synchronize:** Propose surgical fixes and record findings in `security_report.md`.
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Governed patch application with pre-apply rollback snapshots and Human Gate authorization.
|
|
3
|
-
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
4
|
-
version:
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Edit, Write, run_command
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
agent: remediator
|
|
6
6
|
lifecycle-phase: Phase 5 (Patch Application)
|
|
7
7
|
required-skills:
|
|
8
8
|
- torusguard-apply
|
|
9
9
|
scripts-binding:
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- .torusguard/scripts/run_manager.py
|
|
13
|
-
- .torusguard/scripts/diff_guard.py
|
|
10
|
+
- internal/apply/apply.go
|
|
11
|
+
- cmd/torusguard/main.go
|
|
14
12
|
---
|
|
15
13
|
|
|
16
14
|
# /torusguard apply — Governed Patch Application & Rollback Snapshot
|
|
@@ -20,91 +18,62 @@ $ARGUMENTS
|
|
|
20
18
|
---
|
|
21
19
|
|
|
22
20
|
## Objective
|
|
23
|
-
|
|
21
|
+
Safely apply approved remediation bundles to disk source files, creating an automated byte-for-byte pre-apply backup snapshot (`.bak`) in `.torusguard/snapshots/<run_id>/`, asserting syntax validity, and distilling passing patterns into Golden Fix Recipes.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Tri-Mode Execution
|
|
26
|
+
|
|
27
|
+
| Mode | Command / Tool | Execution Method |
|
|
28
|
+
| :--- | :--- | :--- |
|
|
29
|
+
| **Mode A: Terminal CLI** | `torusguard apply candidate.patch [--yes]` | Shell execution of patch applier with snapshot creation. |
|
|
30
|
+
| **Mode B: AI Chat Slash** | `/torusguard apply` | Guided conversational application with explicit Human Gate approval. |
|
|
31
|
+
| **Mode C: Native MCP Tool** | Autonomous Agent Flow | Formulates patch with `torusguard_harden`, awaits Human Gate, invokes CLI. |
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
35
|
## Mandatory Pre-Flight Context Inspection
|
|
36
36
|
|
|
37
37
|
Inspect bundle validity and file safety before modifying disk code:
|
|
38
|
-
1. **Bundle Verification:** Assert `patch
|
|
39
|
-
2. **Pre-Apply Snapshot:** Save a byte-for-byte backup copy (`.
|
|
38
|
+
1. **Bundle Verification:** Assert `candidate.patch` or semantic `patch.json` exists.
|
|
39
|
+
2. **Pre-Apply Snapshot:** Save a byte-for-byte backup copy (`.torusguard/snapshots/<run_id>/<rel_path>.bak`) prior to editing.
|
|
40
40
|
3. **Uncommitted Changes:** Check git status; ensure target file has clean baseline.
|
|
41
41
|
4. **Ponytail Check:** Re-verify that patch additions $\le 35$ and deletions $\le 25$.
|
|
42
42
|
5. **Human Gate:** Confirm operator approval before committing edits to disk.
|
|
43
|
-
6. **Workspace Cleanliness:** Verify git working tree has no uncommitted merge conflicts.
|
|
44
|
-
7. **Execution Privilege:** Verify write access to targeted file locations.
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## When to Use /torusguard apply
|
|
49
|
-
|
|
50
|
-
| Trigger Scenario | Recommended Action |
|
|
51
|
-
| :--- | :--- |
|
|
52
|
-
| Applying an approved remediation patch to disk | Run `/torusguard apply` |
|
|
53
|
-
| Generating patch diff without modifying disk | Run `/torusguard harden` |
|
|
54
|
-
| Verifying that patch eliminated flaw without regression | Run `/torusguard recheck` |
|
|
55
|
-
| Reverting an applied patch | Restore from `.bak` snapshot |
|
|
56
|
-
| Checking workspace status | Run `/torusguard status` |
|
|
57
43
|
|
|
58
44
|
---
|
|
59
45
|
|
|
60
46
|
## Living Report Invariant
|
|
61
47
|
- Applied patches create pre-apply `.bak` snapshots in `.torusguard/snapshots/<run_id>/`.
|
|
62
48
|
- Finding statuses transition in `security_report.md` to `APPLIED 🔵`.
|
|
63
|
-
- Instant rollback available via `
|
|
64
|
-
|
|
65
|
-
## Execution Steps
|
|
66
|
-
|
|
67
|
-
1. **Load Remediation Bundle:** Read `patch.diff` and metadata from active run directory.
|
|
68
|
-
2. **Audit Patch Invariants:** Run `python .torusguard/scripts/diff_guard.py <patch.diff>`.
|
|
69
|
-
3. **Create Rollback Backup:** Copy target file to `.torusguard/runs/<run_id>/.torusguard/snapshots/<run_id>/<filename>.bak`.
|
|
70
|
-
4. **Apply Minimal Diff:** Execute precise surgical edit using `replace_file_content` or `patch`.
|
|
71
|
-
5. **Assert Syntax & Integrity:** Check that modified file compiles cleanly without syntax errors.
|
|
72
|
-
6. **Log Application Ledger:** Record timestamp, original SHA-256, and patched SHA-256 in `apply-log.json`.
|
|
49
|
+
- Instant rollback available via `torusguard rollback`.
|
|
73
50
|
|
|
74
51
|
---
|
|
75
52
|
|
|
76
|
-
##
|
|
77
|
-
|
|
78
|
-
- **Syntax Error After Patch:** Instantly revert target file from `.bak` backup snapshot.
|
|
79
|
-
- **Merge / Context Conflict:** Re-run `/torusguard harden` to regenerate diff against latest disk lines.
|
|
80
|
-
- **Missing Backup File:** Do not apply patch if backup copy cannot be written.
|
|
81
|
-
- **Halt Trigger:** Abort if git working tree is dirty on conflicting lines.
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## Hallucination Guard
|
|
53
|
+
## Execution Steps
|
|
86
54
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
55
|
+
1. **Load Remediation Bundle:** Read `candidate.patch` or `patch.json`.
|
|
56
|
+
2. **Obtain Human Gate:** Confirm user approval to modify target source file.
|
|
57
|
+
3. **Create Rollback Backup:** Capture `.bak` in `.torusguard/snapshots/<run_id>/`.
|
|
58
|
+
4. **Apply Surgical Edit:** Run `torusguard apply <patch> --yes` or apply semantic reflection.
|
|
59
|
+
5. **Assert Syntax & Integrity:** Check that modified file compiles cleanly (`go test ./...`, syntax lint).
|
|
60
|
+
6. **Recommend Recheck:** Run `torusguard recheck` or `/torusguard recheck`.
|
|
90
61
|
|
|
91
62
|
---
|
|
92
63
|
|
|
93
64
|
## Output Card Format
|
|
94
65
|
|
|
95
66
|
```markdown
|
|
96
|
-
### 🚀 TorusGuard Patch
|
|
97
|
-
- **
|
|
98
|
-
- **
|
|
99
|
-
- **Rollback
|
|
100
|
-
- **
|
|
101
|
-
- **Syntax Check:** PASSED (clean compile)
|
|
102
|
-
- **Status:** APPLIED — run `/torusguard recheck` to verify fix
|
|
67
|
+
### 🚀 TorusGuard Patch Applied Successfully
|
|
68
|
+
- **Target File:** `src/path/to/file`
|
|
69
|
+
- **Backup Snapshot:** `.torusguard/snapshots/<run_id>/<file>.bak`
|
|
70
|
+
- **Rollback Command:** `torusguard rollback`
|
|
71
|
+
- **Next Step:** Run `/torusguard recheck` to verify closure
|
|
103
72
|
```
|
|
104
73
|
|
|
105
74
|
---
|
|
106
75
|
|
|
107
76
|
## Next Steps
|
|
108
77
|
|
|
109
|
-
1. Run `/torusguard recheck`
|
|
110
|
-
2.
|
|
78
|
+
1. Run `/torusguard recheck` or `torusguard recheck` to verify closure and zero regressions.
|
|
79
|
+
2. If unexpected behavior occurs, run `torusguard rollback`.
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Static security AST scanning, stable line-shift invariant fingerprinting, root-cause clustering, and 0-100 confidence scoring.
|
|
3
|
-
tools: Read, Grep, Glob, Bash, Write
|
|
4
|
-
version:
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Write, run_command
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
agent: auditor
|
|
6
6
|
lifecycle-phase: Phase 2 (Static Audit & Clustering)
|
|
7
7
|
required-skills:
|
|
8
8
|
- torusguard-audit
|
|
9
9
|
scripts-binding:
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- .torusguard/scripts/finding_scorer.py
|
|
10
|
+
- internal/scanner/scanner.go
|
|
11
|
+
- cmd/torusguard/main.go
|
|
12
|
+
- cmd/torusguard/mcp.go
|
|
14
13
|
---
|
|
15
14
|
|
|
16
15
|
# /torusguard audit — Static Security Code Scan & Clustering
|
|
@@ -20,36 +19,27 @@ $ARGUMENTS
|
|
|
20
19
|
---
|
|
21
20
|
|
|
22
21
|
## Objective
|
|
23
|
-
|
|
22
|
+
Execute static AST analysis across polyglot project files, evaluate code against 74 canonical security rules across 18 families, assign stable line-shift invariant fingerprints, cluster architectural root causes, synchronize findings with `security_report.md`, and score findings with auditable 0–100 confidence ratings.
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Tri-Mode Execution
|
|
27
|
+
|
|
28
|
+
| Mode | Command / Tool | Execution Method |
|
|
29
|
+
| :--- | :--- | :--- |
|
|
30
|
+
| **Mode A: Terminal CLI** | `torusguard audit [--include-tests] [--json]` | Shell execution of compiled Go binary. |
|
|
31
|
+
| **Mode B: AI Chat Slash** | `/torusguard audit` | Conversational guided audit with bounded context inspection. |
|
|
32
|
+
| **Mode C: Native MCP Tool** | `torusguard_audit` | Autonomous agent tool invocation via stdio JSON-RPC. |
|
|
30
33
|
|
|
31
34
|
---
|
|
32
35
|
|
|
33
36
|
## Mandatory Pre-Flight Context Inspection
|
|
34
37
|
|
|
35
38
|
Inspect workspace prerequisites before launching static audit:
|
|
36
|
-
1. **Init State (`torusguard.json`):** Assert repository is initialized
|
|
39
|
+
1. **Init State (`torusguard.json`):** Assert repository is initialized or run `torusguard init`.
|
|
37
40
|
2. **Active Rules (`rules/active/`):** Confirm rule definitions exist.
|
|
38
41
|
3. **Exclusions:** Assert `node_modules/`, `.venv/`, `dist/`, `.git/` are skipped.
|
|
39
|
-
4. **
|
|
40
|
-
5. **Syntax Check:** Check for syntax errors before parsing ASTs.
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## When to Use /torusguard audit
|
|
45
|
-
|
|
46
|
-
| Trigger Scenario | Recommended Action |
|
|
47
|
-
| :--- | :--- |
|
|
48
|
-
| First-time scan of repository or new branch | Run `/torusguard audit` |
|
|
49
|
-
| Pre-commit review and PR security checks | Run `/torusguard audit` |
|
|
50
|
-
| Uninitialized project | Run `/torusguard init` first |
|
|
51
|
-
| Live endpoint or runtime probing | Run `/torusguard web-validate` |
|
|
52
|
-
| Differential check after patch | Run `/torusguard recheck` |
|
|
42
|
+
4. **Syntax Check:** Check for syntax errors before parsing ASTs.
|
|
53
43
|
|
|
54
44
|
---
|
|
55
45
|
|
|
@@ -57,31 +47,18 @@ Inspect workspace prerequisites before launching static audit:
|
|
|
57
47
|
- Audit discoveries automatically synchronize to `security_report.md` at workspace root.
|
|
58
48
|
- Findings transition into `OPEN 🔴` status with stable invariant fingerprints.
|
|
59
49
|
|
|
60
|
-
## Execution Steps
|
|
61
|
-
|
|
62
|
-
1. **Allocate Run Folder:** Run `python .torusguard/scripts/run_manager.py create audit`.
|
|
63
|
-
2. **Scan Codebase ASTs:** Match active rules against source trees.
|
|
64
|
-
3. **Compute Stable Fingerprints:** Hash AST context to produce stable IDs.
|
|
65
|
-
4. **Cluster Root Causes:** Group findings sharing identical sinks.
|
|
66
|
-
5. **Score Confidence (0–100):** Run `python .torusguard/scripts/finding_scorer.py --run <run_dir>`.
|
|
67
|
-
6. **Emit Artifacts:** Write `findings.md`, `findings.json`, and `summary.md`.
|
|
68
|
-
|
|
69
50
|
---
|
|
70
51
|
|
|
71
|
-
##
|
|
72
|
-
|
|
73
|
-
- **Zero Rules Active:** Re-run `/torusguard init` to activate rules.
|
|
74
|
-
- **AST Parse Error:** Log syntax error on malformed file, skip, and continue.
|
|
75
|
-
- **Scorer Failure:** Ensure Python 3.10+; verify finding JSON structure.
|
|
76
|
-
- **Halt Trigger:** Abort if run folder cannot be allocated or disk write fails.
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Hallucination Guard
|
|
52
|
+
## Execution Steps
|
|
81
53
|
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
54
|
+
1. **Launch Audit Scan:**
|
|
55
|
+
- **Mode A (CLI):** Run `torusguard audit` in terminal.
|
|
56
|
+
- **Mode B (Chat):** Parse AST sinks using `grep_search` and bounded `ExtractContext`.
|
|
57
|
+
- **Mode C (MCP):** Call `torusguard_audit` with `{"target": "."}`.
|
|
58
|
+
2. **Scan Codebase ASTs:** Match 74 canonical rules across 18 families against source trees.
|
|
59
|
+
3. **Compute Stable Fingerprints:** Hash AST context to produce stable line-shift invariant IDs.
|
|
60
|
+
4. **Cluster Root Causes:** Group findings sharing identical sinks or causal architecture.
|
|
61
|
+
5. **Synchronize Ground Truth:** Update `security_report.md` at workspace root.
|
|
85
62
|
|
|
86
63
|
---
|
|
87
64
|
|
|
@@ -89,12 +66,11 @@ Inspect workspace prerequisites before launching static audit:
|
|
|
89
66
|
|
|
90
67
|
```markdown
|
|
91
68
|
### 🔎 TorusGuard Static Audit Results
|
|
92
|
-
- **Run ID:** `run-YYYYMMDD-HHMMSS-audit`
|
|
93
69
|
- **Files Scanned:** [Count] source files
|
|
94
70
|
- **Total Findings:** [Count] ([Critical] Critical, [High] High)
|
|
95
71
|
- **Root Cause Clusters:** [Count] architectural issues
|
|
96
72
|
- **Confidence:** [Score]/100
|
|
97
|
-
- **
|
|
73
|
+
- **Living Report:** `security_report.md`
|
|
98
74
|
```
|
|
99
75
|
|
|
100
76
|
---
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Legal scope definition, target ownership proof verification, and safety boundary enforcement for runtime validation.
|
|
3
|
-
tools: Read, Grep, Glob, Bash, Write
|
|
4
|
-
version:
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Write, run_command
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
agent: reviewer
|
|
6
6
|
lifecycle-phase: Phase 1 (Authorization Gate)
|
|
7
7
|
required-skills:
|
|
8
8
|
- torusguard-authorize
|
|
9
9
|
scripts-binding:
|
|
10
|
-
-
|
|
11
|
-
-
|
|
10
|
+
- internal/validate/validate.go
|
|
11
|
+
- cmd/torusguard/main.go
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# /torusguard authorize — Legal Scope & Safety Gate
|
|
@@ -18,7 +18,17 @@ $ARGUMENTS
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## Objective
|
|
21
|
-
Legal scope definition, target ownership proof verification, and safety boundary enforcement.
|
|
21
|
+
Legal scope definition, target ownership proof verification, and safety boundary enforcement for runtime validation.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Tri-Mode Execution
|
|
26
|
+
|
|
27
|
+
| Mode | Command / Tool | Execution Method |
|
|
28
|
+
| :--- | :--- | :--- |
|
|
29
|
+
| **Mode A: Terminal CLI** | `torusguard authorize` | Interactive boundary setup and cryptographic token generation. |
|
|
30
|
+
| **Mode B: AI Chat Slash** | `/torusguard authorize` | Conversational parameter collection and scope validation. |
|
|
31
|
+
| **Mode C: Native MCP Tool** | Safety Gate Guard | Administrative gatekeeper ensuring strict safety boundaries before probes. |
|
|
22
32
|
|
|
23
33
|
---
|
|
24
34
|
|
|
@@ -27,52 +37,20 @@ Legal scope definition, target ownership proof verification, and safety boundary
|
|
|
27
37
|
Inspect authorization parameters and environment safety before executing:
|
|
28
38
|
1. **Config Record (`.torusguard/config/torusguard.json`):** Assert repository is initialized.
|
|
29
39
|
2. **Current Scope (`.torusguard/config/scope.json`):** Inspect active allowed targets, paths, and TTL expiry.
|
|
30
|
-
3. **Environment Classification:** Assert target is local or staging (`localhost`, `127.0.0.1`, `*.
|
|
40
|
+
3. **Environment Classification:** Assert target is local or staging (`localhost`, `127.0.0.1`, `*.staging.*`).
|
|
31
41
|
4. **Destructive Guard:** Ensure state-changing operations (`DELETE`, bulk drops) remain blocked by default.
|
|
32
|
-
5. **
|
|
33
|
-
6. **TTL Window:** Ensure authorization window does not exceed 24 hours.
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## When to Use /torusguard authorize
|
|
38
|
-
|
|
39
|
-
| Trigger Scenario | Recommended Action |
|
|
40
|
-
| :--- | :--- |
|
|
41
|
-
| Preparing for live HTTP probes or API validation | Run `/torusguard authorize` |
|
|
42
|
-
| Updating allowed hosts, path prefixes, or rate limits | Run `/torusguard authorize` |
|
|
43
|
-
| Static-only security audit | Skip authorize; run `/torusguard audit` |
|
|
44
|
-
| Checking active legal scope status | Run `/torusguard status` |
|
|
45
|
-
| Expired authorization window | Re-run `/torusguard authorize` |
|
|
42
|
+
5. **TTL Window:** Ensure authorization window does not exceed 24 hours.
|
|
46
43
|
|
|
47
44
|
---
|
|
48
45
|
|
|
49
46
|
## Execution Steps
|
|
50
47
|
|
|
51
|
-
1. **
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
4. **Write Scope File (`.torusguard/config/scope.json`):** Save authorized targets, valid TTL timestamp, and request rate caps.
|
|
58
|
-
5. **Confirm Scope Binding:** Verify `.torusguard/config/scope.json` parses as valid JSON against schema.
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Failure Recovery
|
|
63
|
-
|
|
64
|
-
- **Unreachable Host:** Verify local server is running on the specified port.
|
|
65
|
-
- **Production Target Warning:** If target resolves to an external production host, halt and request operator override.
|
|
66
|
-
- **Malformed JSON:** Re-initialize `scope.json` from `.torusguard/schemas/auth-boundary.schema.json`.
|
|
67
|
-
- **Halt Trigger:** Abort immediately if user provides wildcard target (`*`) or third-party domain.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Hallucination Guard
|
|
72
|
-
|
|
73
|
-
- ❌ Never proceed with runtime probing without an explicit, valid `.torusguard/config/scope.json`.
|
|
74
|
-
- ❌ Never authorize destructive HTTP methods (`DELETE`, `DROP`) under default non-destructive policy.
|
|
75
|
-
- ✅ Always validate targets through `.torusguard/scripts/safety_gate.py`.
|
|
48
|
+
1. **Trigger Authorization:**
|
|
49
|
+
- **Mode A (CLI):** Run `torusguard authorize`.
|
|
50
|
+
- **Mode B (Chat):** Collect target host URL and allowed prefixes.
|
|
51
|
+
2. **Generate Token:** Persist cryptographic authorization token into `.torusguard/auth.json`.
|
|
52
|
+
3. **Write Scope Record:** Persist authorized targets and expiration TTL into `.torusguard/config/scope.json`.
|
|
53
|
+
4. **Confirm Readiness:** Prepare environment for `/torusguard web-validate`.
|
|
76
54
|
|
|
77
55
|
---
|
|
78
56
|
|
|
@@ -81,9 +59,8 @@ Inspect authorization parameters and environment safety before executing:
|
|
|
81
59
|
```markdown
|
|
82
60
|
### 🔒 TorusGuard Authorization Gate
|
|
83
61
|
- **Target URL:** [Target Host or URL]
|
|
84
|
-
- **Environment:** [Localhost / Staging
|
|
85
|
-
- **
|
|
86
|
-
- **Rate Limit:** [Max requests / concurrency limit]
|
|
62
|
+
- **Environment:** [Localhost / Staging]
|
|
63
|
+
- **Session TTL:** 24 Hours
|
|
87
64
|
- **Scope File:** `.torusguard/config/scope.json`
|
|
88
65
|
- **Status:** AUTHORIZED — ready for `/torusguard web-validate`
|
|
89
66
|
```
|
|
@@ -92,5 +69,5 @@ Inspect authorization parameters and environment safety before executing:
|
|
|
92
69
|
|
|
93
70
|
## Next Steps
|
|
94
71
|
|
|
95
|
-
1. Run `/torusguard
|
|
96
|
-
2. Run `/torusguard
|
|
72
|
+
1. Run `/torusguard web-validate` to begin safe, authorized endpoint validation.
|
|
73
|
+
2. Run `/torusguard audit` to scan codebase for AST vulnerabilities.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# /torusguard-container — Container & Docker Security Audit
|
|
2
|
+
|
|
3
|
+
$ARGUMENTS
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Objective
|
|
8
|
+
Detect and remediate container privilege escalation, root execution, docker socket exposure, and build-time secret injection across `Dockerfile`, `Containerfile`, and `docker-compose.yml` configurations.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Tri-Mode Parity
|
|
13
|
+
- **Mode A (Terminal CLI):** `torusguard container [target]`
|
|
14
|
+
- **Mode B (AI Chat Slash Command):** `/torusguard container [target]`
|
|
15
|
+
- **Mode C (Native MCP Tool):** `torusguard_container`
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Discover Container Configurations:** Discover all Dockerfiles and compose YAML files in the workspace.
|
|
22
|
+
2. **Execute Static Heuristic Audit:** Run `ScanContainerFiles` or `torusguard_container` against discovered files.
|
|
23
|
+
3. **Assert Security Invariants:**
|
|
24
|
+
- Enforce non-root user declarations (`TG-CONT-001`).
|
|
25
|
+
- Block Docker daemon socket mounts (`/var/run/docker.sock`) (`TG-CONT-002`).
|
|
26
|
+
- Disallow `privileged: true` and unconfined seccomp profiles (`TG-CONT-003`).
|
|
27
|
+
- Ban build-time secrets in `ARG` or `ENV` directives (`TG-CONT-004`).
|
|
28
|
+
4. **Formulate Surgical Patches:** Propose minimal diffs adding non-root users (`USER appuser`) and secret mounts within Ponytail bounds (≤35 additions, ≤25 deletions).
|
|
29
|
+
5. **Synchronize Report:** Log all container findings in `security_report.md`.
|