torusguard 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.torusguard/.manifest.json +95 -0
- package/.torusguard/ARCHITECTURE.md +168 -0
- package/.torusguard/TORUSGUARD.md +145 -0
- package/.torusguard/agents/auditor.md +41 -0
- package/.torusguard/agents/profiler.md +49 -0
- package/.torusguard/agents/remediator.md +41 -0
- package/.torusguard/agents/reviewer.md +39 -0
- package/.torusguard/agents/validator.md +46 -0
- package/.torusguard/config/scope.json +24 -0
- package/.torusguard/config/slash-commands.json +102 -0
- package/.torusguard/config/torusguard.json +30 -0
- package/.torusguard/references/django-security.md +43 -0
- package/.torusguard/references/drf-security.md +20 -0
- package/.torusguard/references/express-security.md +103 -0
- package/.torusguard/references/fastapi-security.md +20 -0
- package/.torusguard/references/firebase-security.md +78 -0
- package/.torusguard/references/flask-security.md +20 -0
- package/.torusguard/references/nextjs-security.md +96 -0
- package/.torusguard/references/react-vite-security.md +97 -0
- package/.torusguard/references/sqlalchemy-security.md +16 -0
- package/.torusguard/references/supabase-security.md +84 -0
- package/.torusguard/rules/README.md +62 -0
- package/.torusguard/rules/TORUSGUARD.md +145 -0
- package/.torusguard/rules/active/.gitkeep +0 -0
- package/.torusguard/rules/active/TG-DIFF-001.md +20 -0
- package/.torusguard/rules/active/TG-DIFF-002.md +20 -0
- package/.torusguard/rules/active/TG-DIFF-003.md +19 -0
- package/.torusguard/runs/.gitkeep +0 -0
- package/.torusguard/schemas/authorization.schema.json +81 -0
- package/.torusguard/schemas/confidence.schema.json +72 -0
- package/.torusguard/schemas/evidence.schema.json +66 -0
- package/.torusguard/schemas/finding.schema.json +164 -0
- package/.torusguard/schemas/provenance.schema.json +46 -0
- package/.torusguard/schemas/remediation.schema.json +59 -0
- package/.torusguard/schemas/retest.schema.json +53 -0
- package/.torusguard/schemas/runtime-evidence.schema.json +72 -0
- package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
- package/.torusguard/scripts/diff_guard.py +171 -0
- package/.torusguard/scripts/finding_scorer.py +86 -0
- package/.torusguard/scripts/manifest_builder.py +130 -0
- package/.torusguard/scripts/monorepo_detector.py +164 -0
- package/.torusguard/scripts/run_manager.py +89 -0
- package/.torusguard/scripts/safety_gate.py +64 -0
- package/.torusguard/scripts/sarif_exporter.py +116 -0
- package/.torusguard/scripts/stack_detect.py +152 -0
- package/.torusguard/skills/torusguard/SKILL.md +37 -0
- package/.torusguard/skills/torusguard/bootstrap.py +158 -0
- package/.torusguard/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/.torusguard/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/.torusguard/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/.torusguard/skills/torusguard/references/client-code-exposure.md +55 -0
- package/.torusguard/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/.torusguard/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/.torusguard/skills/torusguard/references/django-security.md +43 -0
- package/.torusguard/skills/torusguard/references/drf-security.md +20 -0
- package/.torusguard/skills/torusguard/references/fastapi-security.md +20 -0
- package/.torusguard/skills/torusguard/references/flask-security.md +20 -0
- package/.torusguard/skills/torusguard/references/frontend-no-db.md +53 -0
- package/.torusguard/skills/torusguard/references/graphql-security.md +12 -0
- package/.torusguard/skills/torusguard/references/input-and-injection.md +51 -0
- package/.torusguard/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/.torusguard/skills/torusguard/references/platform-hardening.md +56 -0
- package/.torusguard/skills/torusguard/references/python-dependencies.md +16 -0
- package/.torusguard/skills/torusguard/references/python-security-overview.md +12 -0
- package/.torusguard/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/.torusguard/skills/torusguard/references/secrets-and-config.md +64 -0
- package/.torusguard/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/.torusguard/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/.torusguard/skills/torusguard/references/webhook-security.md +15 -0
- package/.torusguard/skills/torusguard/references/websocket-security.md +12 -0
- package/.torusguard/skills/torusguard-apply/SKILL.md +46 -0
- package/.torusguard/skills/torusguard-audit/SKILL.md +70 -0
- package/.torusguard/skills/torusguard-authorize/SKILL.md +47 -0
- package/.torusguard/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/.torusguard/skills/torusguard-full/SKILL.md +70 -0
- package/.torusguard/skills/torusguard-harden/SKILL.md +63 -0
- package/.torusguard/skills/torusguard-init/SKILL.md +52 -0
- package/.torusguard/skills/torusguard-recheck/SKILL.md +53 -0
- package/.torusguard/skills/torusguard-report/SKILL.md +54 -0
- package/.torusguard/skills/torusguard-status/SKILL.md +42 -0
- package/.torusguard/skills/torusguard-verify/SKILL.md +55 -0
- package/.torusguard/skills/torusguard-web-validate/SKILL.md +64 -0
- package/.torusguard/templates/audit-report.template.md +54 -0
- package/.torusguard/templates/authorization.template.md +34 -0
- package/.torusguard/templates/finding-card.template.md +32 -0
- package/.torusguard/templates/remediation-bundle.template.md +35 -0
- package/.torusguard/workflows/apply.md +95 -0
- package/.torusguard/workflows/audit.md +93 -0
- package/.torusguard/workflows/authorize.md +95 -0
- package/.torusguard/workflows/exploit-check.md +97 -0
- package/.torusguard/workflows/harden.md +93 -0
- package/.torusguard/workflows/init.md +95 -0
- package/.torusguard/workflows/recheck.md +95 -0
- package/.torusguard/workflows/report.md +95 -0
- package/.torusguard/workflows/status.md +95 -0
- package/.torusguard/workflows/verify.md +95 -0
- package/.torusguard/workflows/web-validate.md +95 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/bin/torusguard.js +110 -0
- package/install.py +98 -0
- package/package.json +48 -0
- package/skills/torusguard/SKILL.md +41 -0
- package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
- package/skills/torusguard/bootstrap.py +256 -0
- package/skills/torusguard/payload/.manifest.json +95 -0
- package/skills/torusguard/payload/ARCHITECTURE.md +168 -0
- package/skills/torusguard/payload/TORUSGUARD.md +145 -0
- package/skills/torusguard/payload/agents/auditor.md +41 -0
- package/skills/torusguard/payload/agents/profiler.md +49 -0
- package/skills/torusguard/payload/agents/remediator.md +41 -0
- package/skills/torusguard/payload/agents/reviewer.md +39 -0
- package/skills/torusguard/payload/agents/validator.md +46 -0
- package/skills/torusguard/payload/config/scope.json +24 -0
- package/skills/torusguard/payload/config/slash-commands.json +102 -0
- package/skills/torusguard/payload/config/torusguard.json +30 -0
- package/skills/torusguard/payload/references/django-security.md +43 -0
- package/skills/torusguard/payload/references/drf-security.md +20 -0
- package/skills/torusguard/payload/references/express-security.md +103 -0
- package/skills/torusguard/payload/references/fastapi-security.md +20 -0
- package/skills/torusguard/payload/references/firebase-security.md +78 -0
- package/skills/torusguard/payload/references/flask-security.md +20 -0
- package/skills/torusguard/payload/references/nextjs-security.md +96 -0
- package/skills/torusguard/payload/references/react-vite-security.md +97 -0
- package/skills/torusguard/payload/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/payload/references/supabase-security.md +84 -0
- package/skills/torusguard/payload/rules/README.md +62 -0
- package/skills/torusguard/payload/rules/TORUSGUARD.md +145 -0
- package/skills/torusguard/payload/rules/active/.gitkeep +0 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-001.md +20 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-002.md +20 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-003.md +19 -0
- package/skills/torusguard/payload/schemas/authorization.schema.json +81 -0
- package/skills/torusguard/payload/schemas/confidence.schema.json +72 -0
- package/skills/torusguard/payload/schemas/evidence.schema.json +66 -0
- package/skills/torusguard/payload/schemas/finding.schema.json +164 -0
- package/skills/torusguard/payload/schemas/provenance.schema.json +46 -0
- package/skills/torusguard/payload/schemas/remediation.schema.json +59 -0
- package/skills/torusguard/payload/schemas/retest.schema.json +53 -0
- package/skills/torusguard/payload/schemas/runtime-evidence.schema.json +72 -0
- package/skills/torusguard/payload/scripts/diff_guard.py +171 -0
- package/skills/torusguard/payload/scripts/finding_scorer.py +86 -0
- package/skills/torusguard/payload/scripts/manifest_builder.py +130 -0
- package/skills/torusguard/payload/scripts/monorepo_detector.py +164 -0
- package/skills/torusguard/payload/scripts/run_manager.py +89 -0
- package/skills/torusguard/payload/scripts/safety_gate.py +64 -0
- package/skills/torusguard/payload/scripts/sarif_exporter.py +116 -0
- package/skills/torusguard/payload/scripts/stack_detect.py +152 -0
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +37 -0
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +158 -0
- package/skills/torusguard/payload/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/skills/torusguard/payload/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/skills/torusguard/payload/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/skills/torusguard/payload/skills/torusguard/references/client-code-exposure.md +55 -0
- package/skills/torusguard/payload/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/skills/torusguard/payload/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/skills/torusguard/payload/skills/torusguard/references/django-security.md +43 -0
- package/skills/torusguard/payload/skills/torusguard/references/drf-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/fastapi-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/flask-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/frontend-no-db.md +53 -0
- package/skills/torusguard/payload/skills/torusguard/references/graphql-security.md +12 -0
- package/skills/torusguard/payload/skills/torusguard/references/input-and-injection.md +51 -0
- package/skills/torusguard/payload/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/skills/torusguard/payload/skills/torusguard/references/platform-hardening.md +56 -0
- package/skills/torusguard/payload/skills/torusguard/references/python-dependencies.md +16 -0
- package/skills/torusguard/payload/skills/torusguard/references/python-security-overview.md +12 -0
- package/skills/torusguard/payload/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/skills/torusguard/payload/skills/torusguard/references/secrets-and-config.md +64 -0
- package/skills/torusguard/payload/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/payload/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/skills/torusguard/payload/skills/torusguard/references/webhook-security.md +15 -0
- package/skills/torusguard/payload/skills/torusguard/references/websocket-security.md +12 -0
- package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +46 -0
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +70 -0
- package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +47 -0
- package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +70 -0
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +63 -0
- package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +52 -0
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +53 -0
- package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +54 -0
- package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +42 -0
- package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +55 -0
- package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +64 -0
- package/skills/torusguard/payload/templates/audit-report.template.md +54 -0
- package/skills/torusguard/payload/templates/authorization.template.md +34 -0
- package/skills/torusguard/payload/templates/finding-card.template.md +32 -0
- package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -0
- package/skills/torusguard/payload/workflows/apply.md +95 -0
- package/skills/torusguard/payload/workflows/audit.md +93 -0
- package/skills/torusguard/payload/workflows/authorize.md +95 -0
- package/skills/torusguard/payload/workflows/exploit-check.md +97 -0
- package/skills/torusguard/payload/workflows/harden.md +93 -0
- package/skills/torusguard/payload/workflows/init.md +95 -0
- package/skills/torusguard/payload/workflows/recheck.md +95 -0
- package/skills/torusguard/payload/workflows/report.md +95 -0
- package/skills/torusguard/payload/workflows/status.md +95 -0
- package/skills/torusguard/payload/workflows/verify.md +95 -0
- package/skills/torusguard/payload/workflows/web-validate.md +95 -0
- package/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/skills/torusguard/references/client-code-exposure.md +55 -0
- package/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/skills/torusguard/references/django-security.md +43 -0
- package/skills/torusguard/references/drf-security.md +20 -0
- package/skills/torusguard/references/fastapi-security.md +20 -0
- package/skills/torusguard/references/flask-security.md +20 -0
- package/skills/torusguard/references/frontend-no-db.md +53 -0
- package/skills/torusguard/references/graphql-security.md +12 -0
- package/skills/torusguard/references/input-and-injection.md +51 -0
- package/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/skills/torusguard/references/platform-hardening.md +56 -0
- package/skills/torusguard/references/python-dependencies.md +16 -0
- package/skills/torusguard/references/python-security-overview.md +12 -0
- package/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/skills/torusguard/references/secrets-and-config.md +64 -0
- package/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/skills/torusguard/references/webhook-security.md +15 -0
- package/skills/torusguard/references/websocket-security.md +12 -0
- package/skills/torusguard-apply/SKILL.md +46 -0
- package/skills/torusguard-audit/SKILL.md +70 -0
- package/skills/torusguard-authorize/SKILL.md +47 -0
- package/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/skills/torusguard-full/SKILL.md +70 -0
- package/skills/torusguard-harden/SKILL.md +63 -0
- package/skills/torusguard-init/SKILL.md +52 -0
- package/skills/torusguard-recheck/SKILL.md +53 -0
- package/skills/torusguard-report/SKILL.md +54 -0
- package/skills/torusguard-status/SKILL.md +42 -0
- package/skills/torusguard-verify/SKILL.md +55 -0
- package/skills/torusguard-web-validate/SKILL.md +64 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Governed patch application with pre-apply rollback snapshots and Human Gate authorization.
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
agent: remediator
|
|
6
|
+
lifecycle-phase: Phase 5 (Patch Application)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-apply
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/run_manager.py
|
|
11
|
+
- .torusguard/scripts/diff_guard.py
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# /torusguard apply — Governed Patch Application & Rollback Snapshot
|
|
15
|
+
|
|
16
|
+
$ARGUMENTS
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Objective
|
|
21
|
+
Governed patch application with pre-apply rollback snapshots and Human Gate authorization.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Mandatory Pre-Flight Context Inspection
|
|
26
|
+
|
|
27
|
+
Inspect bundle validity and file safety before modifying disk code:
|
|
28
|
+
1. **Bundle Verification:** Assert `patch.diff` exists in active run's remediation folder.
|
|
29
|
+
2. **Pre-Apply Snapshot:** Save a byte-for-byte backup copy (`.bak` or `pre_apply/`) prior to editing.
|
|
30
|
+
3. **Uncommitted Changes:** Check git status; ensure target file has clean baseline.
|
|
31
|
+
4. **Ponytail Check:** Re-verify that patch additions $\le 35$ and deletions $\le 25$.
|
|
32
|
+
5. **Human Gate:** Confirm operator approval before committing edits to disk.
|
|
33
|
+
6. **Workspace Cleanliness:** Verify git working tree has no uncommitted merge conflicts.
|
|
34
|
+
7. **Execution Privilege:** Verify write access to targeted file locations.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## When to Use /torusguard apply
|
|
39
|
+
|
|
40
|
+
| Trigger Scenario | Recommended Action |
|
|
41
|
+
| :--- | :--- |
|
|
42
|
+
| Applying an approved remediation patch to disk | Run `/torusguard apply` |
|
|
43
|
+
| Generating patch diff without modifying disk | Run `/torusguard harden` |
|
|
44
|
+
| Verifying that patch eliminated flaw without regression | Run `/torusguard recheck` |
|
|
45
|
+
| Reverting an applied patch | Restore from `.bak` snapshot |
|
|
46
|
+
| Checking workspace status | Run `/torusguard status` |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Execution Steps
|
|
51
|
+
|
|
52
|
+
1. **Load Remediation Bundle:** Read `patch.diff` and metadata from active run directory.
|
|
53
|
+
2. **Audit Patch Invariants:** Run `python .torusguard/scripts/diff_guard.py <patch.diff>`.
|
|
54
|
+
3. **Create Rollback Backup:** Copy target file to `.torusguard/runs/<run_id>/pre_apply/<filename>.bak`.
|
|
55
|
+
4. **Apply Minimal Diff:** Execute precise surgical edit using `replace_file_content` or `patch`.
|
|
56
|
+
5. **Assert Syntax & Integrity:** Check that modified file compiles cleanly without syntax errors.
|
|
57
|
+
6. **Log Application Ledger:** Record timestamp, original SHA-256, and patched SHA-256 in `apply-log.json`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Failure Recovery
|
|
62
|
+
|
|
63
|
+
- **Syntax Error After Patch:** Instantly revert target file from `.bak` backup snapshot.
|
|
64
|
+
- **Merge / Context Conflict:** Re-run `/torusguard harden` to regenerate diff against latest disk lines.
|
|
65
|
+
- **Missing Backup File:** Do not apply patch if backup copy cannot be written.
|
|
66
|
+
- **Halt Trigger:** Abort if git working tree is dirty on conflicting lines.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Hallucination Guard
|
|
71
|
+
|
|
72
|
+
- ❌ Never apply code changes without creating an exact pre-apply rollback backup first.
|
|
73
|
+
- ❌ Never touch files not explicitly listed in the approved `patch.diff`.
|
|
74
|
+
- ✅ Always verify syntax compilation immediately after modifying source files.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Output Card Format
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
### 🚀 TorusGuard Patch Application
|
|
82
|
+
- **Finding Addressed:** `TG-XXX-HASH`
|
|
83
|
+
- **File Patched:** `src/path/to/file.py`
|
|
84
|
+
- **Rollback Backup:** `.torusguard/runs/<run_id>/pre_apply/<file>.bak`
|
|
85
|
+
- **Churn Applied:** +[Additions] / -[Deletions] lines
|
|
86
|
+
- **Syntax Check:** PASSED (clean compile)
|
|
87
|
+
- **Status:** APPLIED — run `/torusguard recheck` to verify fix
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Next Steps
|
|
93
|
+
|
|
94
|
+
1. Run `/torusguard recheck` to perform differential audit on the modified file.
|
|
95
|
+
2. Run test suites to verify that business logic and regressions remain intact.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
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: 0.9.2
|
|
5
|
+
agent: auditor
|
|
6
|
+
lifecycle-phase: Phase 2 (Static Audit & Clustering)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-audit
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/run_manager.py
|
|
11
|
+
- .torusguard/scripts/finding_scorer.py
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# /torusguard audit — Static Security Code Scan & Clustering
|
|
15
|
+
|
|
16
|
+
$ARGUMENTS
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Objective
|
|
21
|
+
Static security AST scanning, stable fingerprinting, root-cause clustering, and 0-100 scoring.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Mandatory Pre-Flight Context Inspection
|
|
26
|
+
|
|
27
|
+
Inspect workspace prerequisites before launching static audit:
|
|
28
|
+
1. **Init State (`torusguard.json`):** Assert repository is initialized.
|
|
29
|
+
2. **Active Rules (`rules/active/`):** Confirm rule definitions exist.
|
|
30
|
+
3. **Exclusions:** Assert `node_modules/`, `.venv/`, `dist/`, `.git/` are skipped.
|
|
31
|
+
4. **Run Folder:** Allocate isolated folder in `.torusguard/runs/`.
|
|
32
|
+
5. **Syntax Check:** Check for syntax errors before parsing ASTs.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## When to Use /torusguard audit
|
|
37
|
+
|
|
38
|
+
| Trigger Scenario | Recommended Action |
|
|
39
|
+
| :--- | :--- |
|
|
40
|
+
| First-time scan of repository or new branch | Run `/torusguard audit` |
|
|
41
|
+
| Pre-commit review and PR security checks | Run `/torusguard audit` |
|
|
42
|
+
| Uninitialized project | Run `/torusguard init` first |
|
|
43
|
+
| Live endpoint or runtime probing | Run `/torusguard web-validate` |
|
|
44
|
+
| Differential check after patch | Run `/torusguard recheck` |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Execution Steps
|
|
49
|
+
|
|
50
|
+
1. **Allocate Run Folder:** Run `python .torusguard/scripts/run_manager.py create audit`.
|
|
51
|
+
2. **Scan Codebase ASTs:** Match active rules against source trees.
|
|
52
|
+
3. **Compute Stable Fingerprints:** Hash AST context to produce stable IDs.
|
|
53
|
+
4. **Cluster Root Causes:** Group findings sharing identical sinks.
|
|
54
|
+
5. **Score Confidence (0–100):** Run `python .torusguard/scripts/finding_scorer.py --run <run_dir>`.
|
|
55
|
+
6. **Emit Artifacts:** Write `findings.md`, `findings.json`, and `summary.md`.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Failure Recovery
|
|
60
|
+
|
|
61
|
+
- **Zero Rules Active:** Re-run `/torusguard init` to activate rules.
|
|
62
|
+
- **AST Parse Error:** Log syntax error on malformed file, skip, and continue.
|
|
63
|
+
- **Scorer Failure:** Ensure Python 3.10+; verify finding JSON structure.
|
|
64
|
+
- **Halt Trigger:** Abort if run folder cannot be allocated or disk write fails.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Hallucination Guard
|
|
69
|
+
|
|
70
|
+
- ❌ Never invent finding IDs without AST line hashing.
|
|
71
|
+
- ❌ Never flag test fixtures as critical security flaws.
|
|
72
|
+
- ✅ Always calculate scores using `.torusguard/scripts/finding_scorer.py`.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Output Card Format
|
|
77
|
+
|
|
78
|
+
```markdown
|
|
79
|
+
### 🔎 TorusGuard Static Audit Results
|
|
80
|
+
- **Run ID:** `run-YYYYMMDD-HHMMSS-audit`
|
|
81
|
+
- **Files Scanned:** [Count] source files
|
|
82
|
+
- **Total Findings:** [Count] ([Critical] Critical, [High] High)
|
|
83
|
+
- **Root Cause Clusters:** [Count] architectural issues
|
|
84
|
+
- **Confidence:** [Score]/100
|
|
85
|
+
- **Artifact:** `.torusguard/runs/<run_id>/findings.md`
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Next Steps
|
|
91
|
+
|
|
92
|
+
1. Run `/torusguard verify` to validate exploitability and review evidence.
|
|
93
|
+
2. Run `/torusguard harden` to generate minimal surgical remediation plans.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
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: 0.9.2
|
|
5
|
+
agent: reviewer
|
|
6
|
+
lifecycle-phase: Phase 1 (Authorization Gate)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-authorize
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/safety_gate.py
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /torusguard authorize — Legal Scope & Safety Gate
|
|
14
|
+
|
|
15
|
+
$ARGUMENTS
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Objective
|
|
20
|
+
Legal scope definition, target ownership proof verification, and safety boundary enforcement.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Mandatory Pre-Flight Context Inspection
|
|
25
|
+
|
|
26
|
+
Inspect authorization parameters and environment safety before executing:
|
|
27
|
+
1. **Config Record (`.torusguard/config/torusguard.json`):** Assert repository is initialized.
|
|
28
|
+
2. **Current Scope (`.torusguard/config/scope.json`):** Inspect active allowed targets, paths, and TTL expiry.
|
|
29
|
+
3. **Environment Classification:** Assert target is local or staging (`localhost`, `127.0.0.1`, `*.local`, `*.staging.*`). Production targets require explicit approval.
|
|
30
|
+
4. **Destructive Guard:** Ensure state-changing operations (`DELETE`, bulk drops) remain blocked by default.
|
|
31
|
+
5. **Ownership Proof:** Verify target ownership token or local process binding.
|
|
32
|
+
6. **TTL Window:** Ensure authorization window does not exceed 24 hours.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## When to Use /torusguard authorize
|
|
37
|
+
|
|
38
|
+
| Trigger Scenario | Recommended Action |
|
|
39
|
+
| :--- | :--- |
|
|
40
|
+
| Preparing for live HTTP probes or API validation | Run `/torusguard authorize` |
|
|
41
|
+
| Updating allowed hosts, path prefixes, or rate limits | Run `/torusguard authorize` |
|
|
42
|
+
| Static-only security audit | Skip authorize; run `/torusguard audit` |
|
|
43
|
+
| Checking active legal scope status | Run `/torusguard status` |
|
|
44
|
+
| Expired authorization window | Re-run `/torusguard authorize` |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Execution Steps
|
|
49
|
+
|
|
50
|
+
1. **Capture Scope Parameters:** Collect target URL, allowed paths, forbidden prefixes, and max request budget.
|
|
51
|
+
2. **Validate Host Ownership:** Verify target is local or matches authorized test domains.
|
|
52
|
+
3. **Invoke Safety Gate:**
|
|
53
|
+
```bash
|
|
54
|
+
python .torusguard/scripts/safety_gate.py check --url <target_url>
|
|
55
|
+
```
|
|
56
|
+
4. **Write Scope File (`.torusguard/config/scope.json`):** Save authorized targets, valid TTL timestamp, and request rate caps.
|
|
57
|
+
5. **Confirm Scope Binding:** Verify `.torusguard/config/scope.json` parses as valid JSON against schema.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Failure Recovery
|
|
62
|
+
|
|
63
|
+
- **Unreachable Host:** Verify local server is running on the specified port.
|
|
64
|
+
- **Production Target Warning:** If target resolves to an external production host, halt and request operator override.
|
|
65
|
+
- **Malformed JSON:** Re-initialize `scope.json` from `.torusguard/schemas/auth-boundary.schema.json`.
|
|
66
|
+
- **Halt Trigger:** Abort immediately if user provides wildcard target (`*`) or third-party domain.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Hallucination Guard
|
|
71
|
+
|
|
72
|
+
- ❌ Never proceed with runtime probing without an explicit, valid `.torusguard/config/scope.json`.
|
|
73
|
+
- ❌ Never authorize destructive HTTP methods (`DELETE`, `DROP`) under default non-destructive policy.
|
|
74
|
+
- ✅ Always validate targets through `.torusguard/scripts/safety_gate.py`.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Output Card Format
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
### 🔒 TorusGuard Authorization Gate
|
|
82
|
+
- **Target URL:** [Target Host or URL]
|
|
83
|
+
- **Environment:** [Localhost / Staging / Container]
|
|
84
|
+
- **Allowed Paths:** [Path prefixes or all authorized]
|
|
85
|
+
- **Rate Limit:** [Max requests / concurrency limit]
|
|
86
|
+
- **Scope File:** `.torusguard/config/scope.json`
|
|
87
|
+
- **Status:** AUTHORIZED — ready for `/torusguard web-validate`
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Next Steps
|
|
93
|
+
|
|
94
|
+
1. Run `/torusguard audit` to scan codebase for AST security vulnerabilities.
|
|
95
|
+
2. Run `/torusguard web-validate` to begin safe, authorized endpoint validation.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Safe, bounded, single-step exploitability confirmation across 5 standard verification statuses.
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
agent: validator
|
|
6
|
+
lifecycle-phase: Phase 3c (Exploitability Check)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-exploit-check
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/safety_gate.py
|
|
11
|
+
- .torusguard/scripts/finding_scorer.py
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# /torusguard exploit-check — Bounded Exploitability Confirmation
|
|
15
|
+
|
|
16
|
+
$ARGUMENTS
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Objective
|
|
21
|
+
Safe, bounded, single-step exploitability confirmation across 5 standard verification statuses.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Mandatory Pre-Flight Context Inspection
|
|
26
|
+
|
|
27
|
+
Inspect authorization parameters and probe safety constraints:
|
|
28
|
+
1. **Scope Check (`scope.json`):** Assert endpoint is authorized.
|
|
29
|
+
2. **Approved Probes:** Use benign canaries (SQLi math, HTML marker, unauth read).
|
|
30
|
+
3. **Destructive Ban:** Strictly prohibit drops, DOS, or weaponized payloads.
|
|
31
|
+
4. **Safety Gate:** Verify probe with `safety_gate.py` prior to dispatch.
|
|
32
|
+
5. **Bound:** Limit to single non-destructive HTTP request per finding.
|
|
33
|
+
6. **Audit Trail:** Inject `X-TorusGuard-AuthID` header on all outbound requests.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## When to Use /torusguard exploit-check
|
|
38
|
+
|
|
39
|
+
| Trigger Scenario | Recommended Action |
|
|
40
|
+
| :--- | :--- |
|
|
41
|
+
| Confirming whether a flaw is practically exploitable | Run `/torusguard exploit-check` |
|
|
42
|
+
| Upgrading Medium confidence finding to Confirmed | Run `/torusguard exploit-check` |
|
|
43
|
+
| Verifying IDOR or tenant isolation boundaries | Run `/torusguard exploit-check` |
|
|
44
|
+
| Routine endpoint header inspection | Run `/torusguard web-validate` |
|
|
45
|
+
| Applying approved remediation patch | Run `/torusguard apply` |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Execution Steps
|
|
50
|
+
|
|
51
|
+
1. **Verify Authorization Scope:** Confirm target host and route in `scope.json`.
|
|
52
|
+
2. **Select Safe Canary:** Choose inert mathematical sentinel or unauth GET.
|
|
53
|
+
3. **Validate With Safety Gate:**
|
|
54
|
+
```bash
|
|
55
|
+
python .torusguard/scripts/safety_gate.py check --url <target_url> --payload <canary>
|
|
56
|
+
```
|
|
57
|
+
4. **Dispatch Bounded Single Probe:** Send request with header `X-TorusGuard-AuthID`.
|
|
58
|
+
5. **Classify Status:** Evaluate response against 5 outcomes: `Confirmed`, `Needs Review`, `Not Reproducible`, `Blocked by Controls`, `Out of Scope`.
|
|
59
|
+
6. **Emit Artifacts:** Write `exploit-check.md` and update `findings.json`.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Failure Recovery
|
|
64
|
+
|
|
65
|
+
- **Connection Refused:** Verify target server is running locally on port.
|
|
66
|
+
- **Safety Gate Block:** If `Manual Only`, halt automated probe and request human review.
|
|
67
|
+
- **Ambiguous Response:** Mark finding as `Needs Review`; never assume exploit without proof.
|
|
68
|
+
- **Halt Trigger:** Abort if probe causes server 500 error or unexpected crash.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Hallucination Guard
|
|
73
|
+
|
|
74
|
+
- ❌ Never classify a vulnerability as `Confirmed` without direct sentinel reflection.
|
|
75
|
+
- ❌ Never execute brute force attacks or automated password spraying.
|
|
76
|
+
- ✅ Always provide reproducible curl commands with redacted credentials.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Output Card Format
|
|
81
|
+
|
|
82
|
+
```markdown
|
|
83
|
+
### 🎯 TorusGuard Exploitability Confirmation
|
|
84
|
+
- **Target Route:** `[METHOD] /path`
|
|
85
|
+
- **Finding ID:** `TG-XXX-HASH`
|
|
86
|
+
- **Canary Used:** [Inert Math Sentinel / Unauth Read]
|
|
87
|
+
- **Status:** [Confirmed / Not Reproducible / Blocked]
|
|
88
|
+
- **Evidence:** [Response snippet demonstrating leak or block]
|
|
89
|
+
- **Replay Curl:** `curl -X [METHOD] http://localhost:PORT/path ...`
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Next Steps
|
|
95
|
+
|
|
96
|
+
1. Run `/torusguard harden` to formulate surgical patch bundles for confirmed flaws.
|
|
97
|
+
2. Run `/torusguard report` to export findings into SARIF v2.1.0 format.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Governed remediation formulation under strict Ponytail Protocol bounds (<= 35 additions, <= 25 deletions) and bundle packaging.
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
agent: remediator
|
|
6
|
+
lifecycle-phase: Phase 4 (Remediation Formulation)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-harden
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/run_manager.py
|
|
11
|
+
- .torusguard/scripts/diff_guard.py
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# /torusguard harden — Governed Remediation & Bundle Packaging
|
|
15
|
+
|
|
16
|
+
$ARGUMENTS
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Objective
|
|
21
|
+
Governed remediation formulation under strict Ponytail Protocol bounds (<=35 add, <=25 del).
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Mandatory Pre-Flight Context Inspection
|
|
26
|
+
|
|
27
|
+
Inspect finding targets and patch constraints before generating diffs:
|
|
28
|
+
1. **Target Finding (`findings.md`):** Identify prioritized verified findings.
|
|
29
|
+
2. **Ponytail Protocol:** Enforce hard limit ($\le 35$ additions, $\le 25$ deletions). Ban rewrites.
|
|
30
|
+
3. **Sensitive Path Review:** Flag changes touching `auth/` or `settings.py` for human sign-off.
|
|
31
|
+
4. **Behavior Preservation:** Ensure patch addresses flaw without breaking public APIs.
|
|
32
|
+
5. **Dry-Run Rule:** Do NOT apply changes to disk during harden; emit bundle for review.
|
|
33
|
+
6. **Backup Readiness:** Ensure rollback procedures are prepared before staging patch.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## When to Use /torusguard harden
|
|
38
|
+
|
|
39
|
+
| Trigger Scenario | Recommended Action |
|
|
40
|
+
| :--- | :--- |
|
|
41
|
+
| Formulating minimal patches for verified findings | Run `/torusguard harden` |
|
|
42
|
+
| Packaging a 4-artifact remediation bundle for review | Run `/torusguard harden` |
|
|
43
|
+
| Writing and applying changes to code files | Run `/torusguard apply` |
|
|
44
|
+
| Differentially re-scanning code after patch application | Run `/torusguard recheck` |
|
|
45
|
+
| Discovering new vulnerabilities | Run `/torusguard audit` |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Execution Steps
|
|
50
|
+
|
|
51
|
+
1. **Select Target Finding:** Choose verified flaw from active run directory.
|
|
52
|
+
2. **Examine Live Code Context:** Read surrounding lines (±15) of vulnerable sink.
|
|
53
|
+
3. **Draft Unified Diff:** Formulate minimal fix adhering to Ponytail Protocol limits.
|
|
54
|
+
4. **Audit Patch Safety:** Run `python .torusguard/scripts/diff_guard.py <patch.diff>`.
|
|
55
|
+
5. **Package 4-Artifact Bundle:** Write `patch.diff`, `plan.md`, `verification.md`, `rollback.md` to `.torusguard/runs/<run_id>/remediation/<finding_id>/`.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Failure Recovery
|
|
60
|
+
|
|
61
|
+
- **Line Churn Exceeded (>35 add or >25 del):** Decompose patch into smaller sequential sub-fixes.
|
|
62
|
+
- **Sensitive Path Conflict:** Mark bundle with `Requires Sensitive-Path Sign-Off` in `plan.md`.
|
|
63
|
+
- **Finding Not Found:** Ensure finding ID exists in active `findings.md`.
|
|
64
|
+
- **Halt Trigger:** Abort if target source file cannot be read from disk.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Hallucination Guard
|
|
69
|
+
|
|
70
|
+
- ❌ Never generate full-file replacements or unconstrained cosmetic code refactoring.
|
|
71
|
+
- ❌ Never modify imports, variables, or functions unrelated to the vulnerability.
|
|
72
|
+
- ✅ Always calculate addition and deletion line counts before emitting `patch.diff`.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Output Card Format
|
|
77
|
+
|
|
78
|
+
```markdown
|
|
79
|
+
### 🛠️ TorusGuard Remediation Bundle
|
|
80
|
+
- **Finding Target:** `TG-XXX-HASH` ([Vulnerability Name])
|
|
81
|
+
- **File Affected:** `src/path/to/file.py`
|
|
82
|
+
- **Line Churn:** +[Additions] / -[Deletions] (Ponytail: PASS)
|
|
83
|
+
- **Sensitive Path:** [Yes (Sign-Off Needed) / No (Standard)]
|
|
84
|
+
- **Bundle Path:** `.torusguard/runs/<run_id>/remediation/<finding_id>/`
|
|
85
|
+
- **Status:** READY FOR REVIEW — run `/torusguard apply` to execute
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Next Steps
|
|
91
|
+
|
|
92
|
+
1. Review proposed diff in `.torusguard/runs/<run_id>/remediation/<finding_id>/patch.diff`.
|
|
93
|
+
2. Run `/torusguard apply` to execute the governed patch with automatic rollback backup.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Baseline project discovery, workspace scaffolding, stack detection, and framework-tailored security rule activation.
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
agent: profiler
|
|
6
|
+
lifecycle-phase: Phase 0 (Baseline Setup)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-init
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/stack_detect.py
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /torusguard init — Project Baseline & Workspace Initialization
|
|
14
|
+
|
|
15
|
+
$ARGUMENTS
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Objective
|
|
20
|
+
Baseline project discovery, workspace scaffolding, stack detection, and security rule activation.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Mandatory Pre-Flight Context Inspection
|
|
25
|
+
|
|
26
|
+
Inspect workspace state before running initialization:
|
|
27
|
+
1. **Config State (`.torusguard/config/torusguard.json`):** Check if workspace is already initialized. If active, prompt before re-writing.
|
|
28
|
+
2. **Project Manifests:** Check root for `package.json`, `manage.py`, `requirements.txt`, `pyproject.toml`, `go.mod`, or `Cargo.toml`.
|
|
29
|
+
3. **Disclosure Policy (`SECURITY.md`):** Check for existing responsible disclosure policy.
|
|
30
|
+
4. **Bootstrapper:** If `.torusguard/` is absent, invoke `python skills/torusguard/bootstrap.py` to unpack offline assets.
|
|
31
|
+
5. **Runtime Preconditions:** Ensure Python 3.10+ is available in the current execution shell.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## When to Use /torusguard init
|
|
36
|
+
|
|
37
|
+
| Trigger Scenario | Recommended Command |
|
|
38
|
+
| :--- | :--- |
|
|
39
|
+
| First-time onboarding in any repository | Run `/torusguard init` |
|
|
40
|
+
| Framework upgrade or major dependency changes | Run `/torusguard init` to refresh tailored rules |
|
|
41
|
+
| Repository already configured | Run `/torusguard audit` |
|
|
42
|
+
| Inspecting existing configuration | Run `/torusguard status` |
|
|
43
|
+
| Testing legal boundaries | Run `/torusguard authorize` |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Execution Steps
|
|
48
|
+
|
|
49
|
+
1. **Scaffold Directory Topology:** Verify `.torusguard/` structure (`config/`, `rules/active/`, `runs/`, `scripts/`, `workflows/`, `templates/`, `schemas/`).
|
|
50
|
+
2. **Execute Stack Detection:**
|
|
51
|
+
```bash
|
|
52
|
+
python .torusguard/scripts/stack_detect.py .
|
|
53
|
+
```
|
|
54
|
+
3. **Activate Tailored Rules:** Symlink or copy matching security rules from `.torusguard/rules/` into `.torusguard/rules/active/`.
|
|
55
|
+
4. **Write Configuration (`.torusguard/config/torusguard.json`):**
|
|
56
|
+
Record detected stack, enabled rules count, timestamp, and runtime constraints.
|
|
57
|
+
5. **Verify Initialization:** Assert `.torusguard/config/torusguard.json` and `.torusguard/config/scope.json` exist.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Failure Recovery
|
|
62
|
+
|
|
63
|
+
- **Script Exit 1 (Detection Failed):** Check Python version (`python --version` >= 3.10) and verify read access to root manifests.
|
|
64
|
+
- **Permission Error:** Verify write permissions for `.torusguard/config/` and `.torusguard/rules/active/`.
|
|
65
|
+
- **Missing Directories:** Re-run directory scaffolding if any subfolder creation fails.
|
|
66
|
+
- **Halt Condition:** If root directory is empty, halt and prompt user to open the project root.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Hallucination Guard
|
|
71
|
+
|
|
72
|
+
- ❌ Never invent framework dependencies not present in `package.json` or `requirements.txt`.
|
|
73
|
+
- ❌ Never overwrite an existing `.torusguard/config/scope.json` containing authorized domains.
|
|
74
|
+
- ✅ Always execute `.torusguard/scripts/stack_detect.py` to ground detected technologies.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Output Card Format
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
### 🛡️ TorusGuard Workspace Initialization
|
|
82
|
+
- **Primary Framework:** [Detected Stack or None]
|
|
83
|
+
- **Components:** [Backend / Frontend / Database]
|
|
84
|
+
- **Active Rules:** [Count] rules enabled in `.torusguard/rules/active/`
|
|
85
|
+
- **Config:** `.torusguard/config/torusguard.json` generated
|
|
86
|
+
- **Scope Template:** `.torusguard/config/scope.json` ready
|
|
87
|
+
- **Status:** READY — run `/torusguard audit` to scan codebase
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Next Steps
|
|
93
|
+
|
|
94
|
+
1. Run `/torusguard authorize` to define allowed target URLs and legal scan boundaries.
|
|
95
|
+
2. Run `/torusguard audit` to execute the baseline static security audit.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Targeted differential AST re-scan, fix closure verification, and regression state machine transitions.
|
|
3
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
agent: reviewer
|
|
6
|
+
lifecycle-phase: Phase 6 (Targeted Recheck & Verification)
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard-recheck
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/run_manager.py
|
|
11
|
+
- .torusguard/scripts/finding_scorer.py
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# /torusguard recheck — Targeted Differential Recheck & Regression Audit
|
|
15
|
+
|
|
16
|
+
$ARGUMENTS
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Objective
|
|
21
|
+
Targeted differential AST re-scan, fix closure verification, and regression state transitions.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Mandatory Pre-Flight Context Inspection
|
|
26
|
+
|
|
27
|
+
Inspect applied patch history and target file scope before re-checking:
|
|
28
|
+
1. **Applied Patch Record:** Verify `apply-log.json` or modified file list exists in the active run.
|
|
29
|
+
2. **Scope Limitation:** Restrict differential scan strictly to modified files to conserve token budget.
|
|
30
|
+
3. **Rollback Availability:** Confirm `.bak` snapshot exists in `pre_apply/` in case regression is detected.
|
|
31
|
+
4. **4-State Transition Engine:** Prepare to transition findings to `Fixed`, `Partially Fixed`, `Not Fixed`, or `Regression`.
|
|
32
|
+
5. **Fresh Syntax Validation:** Ensure no compiler or syntax errors exist before re-evaluating rules.
|
|
33
|
+
6. **AST Consistency:** Ensure imported dependencies on modified lines resolve correctly.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## When to Use /torusguard recheck
|
|
38
|
+
|
|
39
|
+
| Trigger Scenario | Recommended Action |
|
|
40
|
+
| :--- | :--- |
|
|
41
|
+
| Immediately after applying a remediation patch | Run `/torusguard recheck` |
|
|
42
|
+
| Verifying that a specific finding is eliminated | Run `/torusguard recheck` |
|
|
43
|
+
| Checking whether a patch introduced new security flaws | Run `/torusguard recheck` |
|
|
44
|
+
| Whole repository baseline audit | Run `/torusguard audit` |
|
|
45
|
+
| Generating final signed release report | Run `/torusguard report` |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Execution Steps
|
|
50
|
+
|
|
51
|
+
1. **Identify Modified Files:** Extract list of altered files from latest apply step.
|
|
52
|
+
2. **Execute Differential AST Scan:** Re-run active security rules exclusively against modified files.
|
|
53
|
+
3. **Evaluate Finding Status:**
|
|
54
|
+
- If original vulnerable AST pattern is absent and no new sink appears: transition to `Fixed`.
|
|
55
|
+
- If new security rule triggers on altered lines: classify as `Regression`.
|
|
56
|
+
4. **Update Finding State:** Record verified resolution status into `findings.json`.
|
|
57
|
+
5. **Emit Recheck Report:** Write `recheck-report.md` into the active run folder.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Failure Recovery
|
|
62
|
+
|
|
63
|
+
- **Finding Still Present (`Not Fixed`):** Review patch diff; the remediation did not neutralize the AST sink.
|
|
64
|
+
- **New Vulnerability Detected (`Regression`):** Alert operator; prompt to revert from `.bak` snapshot.
|
|
65
|
+
- **File Not Found:** Verify file path matches git repository layout.
|
|
66
|
+
- **Halt Trigger:** Abort if diff shows changes outside approved patch scope.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Hallucination Guard
|
|
71
|
+
|
|
72
|
+
- ❌ Never mark a finding as `Fixed` without re-scanning the actual AST of the patched file.
|
|
73
|
+
- ❌ Never ignore new warnings introduced in modified lines.
|
|
74
|
+
- ✅ Always provide before/after line comparisons confirming sink removal.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Output Card Format
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
### ✅ TorusGuard Differential Recheck
|
|
82
|
+
- **Files Re-scanned:** [List of modified files]
|
|
83
|
+
- **Target Finding:** `TG-XXX-HASH`
|
|
84
|
+
- **Result:** [FIXED / REGRESSION / PARTIAL]
|
|
85
|
+
- **Regressions Introduced:** 0
|
|
86
|
+
- **Report:** `.torusguard/runs/<run_id>/recheck-report.md`
|
|
87
|
+
- **Status:** VERIFIED — ready for `/torusguard report`
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Next Steps
|
|
93
|
+
|
|
94
|
+
1. Run `/torusguard report` to generate executive summary and export OASIS SARIF v2.1.0 data.
|
|
95
|
+
2. Commit the verified patch to version control.
|