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,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-recheck
|
|
3
|
+
description: Execute targeted differential AST re-scan against modified files, verify fix closure, and assert zero regressions.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/recheck.md
|
|
6
|
+
tools: Read, Grep, Glob, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/run_manager.py
|
|
9
|
+
- .torusguard/scripts/finding_scorer.py
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Recheck — Targeted Differential Audit & Regression Verification
|
|
13
|
+
|
|
14
|
+
## Objective
|
|
15
|
+
Re-scan only files modified by remediation patches, confirming that targeted vulnerability sinks have been neutralized and verifying that no new security regressions were introduced.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Identify Modified Files:** Read `apply-log.json` from active run directory.
|
|
22
|
+
2. **Execute Differential Scan:** Re-run active `TG-*` rules exclusively against the modified files.
|
|
23
|
+
3. **Evaluate Finding Status:** Transition finding state according to transition rules below.
|
|
24
|
+
4. **Assert Regression-Free:** Ensure no new security warnings triggered on altered lines.
|
|
25
|
+
5. **Update State:** Record verified status in `findings.json`.
|
|
26
|
+
6. **Emit Recheck Report:** Save summary in `.torusguard/runs/<run_id>/recheck-report.md`.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## State Transition Rules
|
|
31
|
+
- **`Fixed`:** Targeted vulnerable AST pattern is absent and no new issues appear on modified lines.
|
|
32
|
+
- **`Partially Fixed`:** Vulnerability surface was reduced but sanitization remains incomplete.
|
|
33
|
+
- **`Not Fixed`:** Vulnerable AST sink remains present in patched file.
|
|
34
|
+
- **`Regression`:** Patch introduced a new security rule violation on modified lines.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Safety Constraints
|
|
39
|
+
- Restrict AST scan strictly to modified files and direct callers.
|
|
40
|
+
- If regression is detected, halt and recommend immediate rollback via `.bak` snapshot.
|
|
41
|
+
- Read-only differential analysis.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Output Format
|
|
46
|
+
```markdown
|
|
47
|
+
✅ [TorusGuard] Differential Recheck Completed
|
|
48
|
+
- Modified Files Scanned: <Count>
|
|
49
|
+
- Target Finding: <Finding ID> ──► FIXED
|
|
50
|
+
- Regressions Detected: 0
|
|
51
|
+
- Report: `.torusguard/runs/<run_id>/recheck-report.md`
|
|
52
|
+
Next: Run `/torusguard report` to export final SARIF and release summary.
|
|
53
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-report
|
|
3
|
+
description: Generate unified security posture reports and export OASIS SARIF v2.1.0 logs for CI/CD integration.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/report.md
|
|
6
|
+
tools: Read, Grep, Glob, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/sarif_exporter.py
|
|
9
|
+
- .torusguard/scripts/run_manager.py
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Report — Unified Security Posture Report & SARIF Export
|
|
13
|
+
|
|
14
|
+
## Objective
|
|
15
|
+
Aggregate findings, verification traces, and recheck results into a signed executive security summary and export schema-compliant OASIS SARIF v2.1.0 logs for CI/CD pipelines.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Aggregate Run Data:** Read findings, verified evidence, and recheck records from active run.
|
|
22
|
+
2. **Export OASIS SARIF v2.1.0:**
|
|
23
|
+
```bash
|
|
24
|
+
python .torusguard/scripts/sarif_exporter.py --run <run_dir> --output <run_dir>/results.sarif
|
|
25
|
+
```
|
|
26
|
+
3. **Compile Executive Markdown Report:** Generate `report.md` with posture score, open/closed finding tables, and risk breakdown.
|
|
27
|
+
4. **Update Run Manifest:** Finalize `manifest.json` status counts.
|
|
28
|
+
5. **Archive Release Artifacts:** Ensure `report.md` and `results.sarif` are serialized to disk.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## SARIF v2.1.0 Output Specification
|
|
33
|
+
- **Version:** `$schema: https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json`, `version: 2.1.0`.
|
|
34
|
+
- **Tool Driver:** `name: TorusGuard`, `semanticVersion: 0.9.2`, full rules catalog in `driver.rules`.
|
|
35
|
+
- **Category Hygiene:** Set `automationDetails.id: "torusguard/static"` to avoid collisions in multi-analysis CI.
|
|
36
|
+
- **Fingerprinting:** Populate `partialFingerprints.primaryLocationLineHash` with SHA-256 context hash.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Safety Constraints
|
|
41
|
+
- Redact all tokens, passwords, and API keys before saving report.
|
|
42
|
+
- Strictly read-only reporting; no source code modifications.
|
|
43
|
+
- Ensure SARIF passes JSON schema validation.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Output Format
|
|
48
|
+
```markdown
|
|
49
|
+
📊 [TorusGuard] Security Posture Report Emitted
|
|
50
|
+
- Run ID: <Run ID> | Posture Score: <Score>/100
|
|
51
|
+
- Findings: <Total> (<Fixed> Fixed · <Open> Open)
|
|
52
|
+
- SARIF Export: `.torusguard/runs/<run_id>/results.sarif`
|
|
53
|
+
- Executive Report: `.torusguard/runs/<run_id>/report.md`
|
|
54
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-status
|
|
3
|
+
description: Display current TorusGuard security posture, active configuration, rules catalog, and run history.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/status.md
|
|
6
|
+
tools: Read, Grep, Glob
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/run_manager.py
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# TorusGuard Status — Workspace Security Posture & Diagnostic Overview
|
|
12
|
+
|
|
13
|
+
## Objective
|
|
14
|
+
Provide an instant diagnostic summary of the repository's security state, active framework rules, historical run results, and runtime scope validity.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Execution Steps
|
|
19
|
+
|
|
20
|
+
1. **Read Configuration:** Parse `.torusguard/config/torusguard.json` to verify initialization state and detected framework stack.
|
|
21
|
+
2. **Enumerate Active Rules:** Count rule files physically present in `.torusguard/rules/active/`.
|
|
22
|
+
3. **Inspect Run History:** List historical run folders in `.torusguard/runs/` via `run_manager.py`.
|
|
23
|
+
4. **Check Authorization Scope:** Check `.torusguard/config/scope.json` for active targets and TTL expiration.
|
|
24
|
+
5. **Render Diagnostic Overview:** Output formatted status card.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Safety Constraints
|
|
29
|
+
- Read-only execution; zero file modifications.
|
|
30
|
+
- Handle uninitialized workspaces gracefully with advice to run `/torusguard init`.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Output Format
|
|
35
|
+
```markdown
|
|
36
|
+
🛡️ [TorusGuard] Workspace Status Overview
|
|
37
|
+
- Version: v0.9.2 | Stack: <Detected Framework>
|
|
38
|
+
- Active Rules: <Count> rules active in `.torusguard/rules/active/`
|
|
39
|
+
- Historical Runs: <Count> runs recorded
|
|
40
|
+
- Scope: <Authorized (TTL Active) / Expired / Unconfigured>
|
|
41
|
+
- Posture: <SECURE / ACTION REQUIRED>
|
|
42
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-verify
|
|
3
|
+
description: Verify finding evidence sufficiency, audit live code line matches, and calibrate 0–100 confidence scores.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/verify.md
|
|
6
|
+
tools: Read, Grep, Glob, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/finding_scorer.py
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# TorusGuard Verify — Finding Evidence Verification & Calibration
|
|
12
|
+
|
|
13
|
+
## Objective
|
|
14
|
+
Audit the evidence sufficiency of candidate findings by reading current disk lines, evaluating unbroken taint source-to-sink flow, filtering false alarms, and calibrating final 0–100 confidence scores.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Execution Steps
|
|
19
|
+
|
|
20
|
+
1. **Locate Target Findings:** Load active findings from `.torusguard/runs/<latest-run>/findings.md`.
|
|
21
|
+
2. **Live Disk Line Match:** Inspect exact cited lines using `view_file` to confirm code presence.
|
|
22
|
+
3. **Audit Evidence Sufficiency:** Verify source-to-sink flow against criteria below.
|
|
23
|
+
4. **Calibrate Confidence Score:**
|
|
24
|
+
```bash
|
|
25
|
+
python .torusguard/scripts/finding_scorer.py --run <run_dir> --verify
|
|
26
|
+
```
|
|
27
|
+
5. **Update State:** Mark finding as `Confirmed`, `Needs Review`, or `False Positive`.
|
|
28
|
+
6. **Emit Verified Evidence:** Save report in `.torusguard/runs/<run_id>/verified-evidence.md`.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Evidence Sufficiency
|
|
33
|
+
A finding is verified as sufficient when:
|
|
34
|
+
- **Direct AST Match:** The vulnerable API or sink call exists on disk at the cited location.
|
|
35
|
+
- **Exposed Surface:** The sink is reachable from an external route, view, or public method.
|
|
36
|
+
- **Absence of Sanitizer:** No escaping function, parameterization, or validating middleware neutralizes the input.
|
|
37
|
+
- **Taint Integrity:** Untrusted request data flows into the sink without structural validation.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Safety Constraints
|
|
42
|
+
- Read-only analysis; no files are modified.
|
|
43
|
+
- Never guess line numbers; always verify via active disk read.
|
|
44
|
+
- Downgrade findings with sanitizer presence to `False Positive`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Output Format
|
|
49
|
+
```markdown
|
|
50
|
+
🧪 [TorusGuard] Finding Verification Complete
|
|
51
|
+
- Findings Audited: <Count> | Confirmed Real: <Count>
|
|
52
|
+
- False Positives Filtered: <Count> | Refined Mean Score: <Score>/100
|
|
53
|
+
- Artifact: `.torusguard/runs/<run_id>/verified-evidence.md`
|
|
54
|
+
Next: Run `/torusguard harden` to formulate surgical fixes for confirmed flaws.
|
|
55
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-web-validate
|
|
3
|
+
description: Execute authorized HTTP probing against local/staging web applications — session capture, transparent audit headers, and secret redaction.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/web-validate.md
|
|
6
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/safety_gate.py
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# TorusGuard Web Validate — Bounded HTTP Probing & Session Capture
|
|
12
|
+
|
|
13
|
+
## Objective
|
|
14
|
+
Safely probe live web applications within authorized scope, injecting transparent audit headers, verifying security headers and cookies, redacting sensitive tokens, and recording deterministic replay traces.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Authorization Gate Check
|
|
19
|
+
Before dispatching any HTTP request:
|
|
20
|
+
1. Verify `.torusguard/config/scope.json` exists and contains target URL.
|
|
21
|
+
2. Confirm current timestamp is prior to `expires_at` TTL.
|
|
22
|
+
3. Assert target is local or non-production staging.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Safety Gate
|
|
27
|
+
All requests pass through `.torusguard/scripts/safety_gate.py`:
|
|
28
|
+
- `Auto-Allowed`: Read-only `GET`, `HEAD`, `OPTIONS` on non-sensitive paths.
|
|
29
|
+
- `Approval Required`: Requests touching auth, sessions, or parameters.
|
|
30
|
+
- `Manual Only`: Any destructive method (`DELETE`, `DROP`) is strictly blocked.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Execution Steps
|
|
35
|
+
|
|
36
|
+
1. **Gate Check:** Validate scope in `scope.json` and query `safety_gate.py`.
|
|
37
|
+
2. **Inject Audit Header:** Attach `X-TorusGuard-AuthID: <auth_id>` to all outbound requests.
|
|
38
|
+
3. **Dispatch Bounded Probe:** Send single non-destructive HTTP request.
|
|
39
|
+
4. **Validate Security Headers:** Check for CSP, HSTS, X-Content-Type-Options, and CORS configurations.
|
|
40
|
+
5. **Audit Cookie Flags:** Verify `HttpOnly`, `Secure`, and `SameSite` on session cookies.
|
|
41
|
+
6. **Capture Replay Trace:** Save sanitized trace in `.torusguard/runs/<run_id>/requests.json`.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Credential Redaction
|
|
46
|
+
All Bearer tokens, cookies, passwords, and API keys are redacted prior to disk serialization (`Bearer [REDACTED]`).
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Safety Constraints
|
|
51
|
+
- Max 50 requests per validation session.
|
|
52
|
+
- Never test unauthorized domains or third-party APIs.
|
|
53
|
+
- Zero state-changing destructive operations.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Output Format
|
|
58
|
+
```markdown
|
|
59
|
+
🌐 [TorusGuard] Web Validation Completed
|
|
60
|
+
- Target: <Host URL> | Endpoints Tested: <Count>
|
|
61
|
+
- Header Posture: <CSP/HSTS Status> | Cookies: <Flags Status>
|
|
62
|
+
- Replay Trace: `.torusguard/runs/<run_id>/requests.json`
|
|
63
|
+
Next: Run `/torusguard exploit-check` to confirm exploitability of candidate flaws.
|
|
64
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# TorusGuard Security Audit & Runtime Verification Report
|
|
2
|
+
|
|
3
|
+
> **TorusGuard Version:** `{{torusguard_version}}`
|
|
4
|
+
> **Target:** `{{target_name}}`
|
|
5
|
+
> **Run ID:** `{{run_id}}`
|
|
6
|
+
> **Timestamp:** `{{timestamp}}`
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Detected Stack
|
|
11
|
+
- **Language:** {{stack_language}}
|
|
12
|
+
- **Framework:** {{stack_framework}}
|
|
13
|
+
- **Data Layer:** {{stack_data_layer}}
|
|
14
|
+
- **Dependency Files:** {{stack_dependency_files}}
|
|
15
|
+
- **Detection Confidence:** {{stack_confidence}}
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Executive Posture
|
|
20
|
+
**Posture:** {{posture_indicator}}
|
|
21
|
+
**Average Confidence Score:** `{{avg_confidence_score}}/100`
|
|
22
|
+
|
|
23
|
+
### Finding Summary
|
|
24
|
+
| Severity | Count | Confirmed | Needs Review | Remediated |
|
|
25
|
+
| :--- | :---: | :---: | :---: | :---: |
|
|
26
|
+
| 🔴 **Critical** | {{critical_count}} | {{critical_confirmed}} | {{critical_review}} | {{critical_fixed}} |
|
|
27
|
+
| 🟠 **High** | {{high_count}} | {{high_confirmed}} | {{high_review}} | {{high_fixed}} |
|
|
28
|
+
| 🟡 **Medium** | {{medium_count}} | {{medium_confirmed}} | {{medium_review}} | {{medium_fixed}} |
|
|
29
|
+
| 🔵 **Low** | {{low_count}} | {{low_confirmed}} | {{low_review}} | {{low_fixed}} |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Root-Cause Clusters
|
|
34
|
+
{{cluster_summary_table}}
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Detailed Findings
|
|
39
|
+
{{finding_cards_section}}
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Governance & Safety Audit Statement
|
|
44
|
+
This execution complied with TorusGuard v0.8.0 governance rules:
|
|
45
|
+
- **Authorization Gate:** {{authorization_status}}
|
|
46
|
+
- **Patch Governance (Ponytail):** Additions $\le 35$, Deletions $\le 25$.
|
|
47
|
+
- **Token Redaction:** All captured authorization headers, bearer tokens, and passwords were redacted.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Prioritized Next Steps
|
|
52
|
+
1. **Remediate Confirmed Sinks:** Run `/torusguard harden` to package remediation bundles.
|
|
53
|
+
2. **Apply Governed Fixes:** Run `/torusguard apply <bundle_id>` to apply targeted fixes.
|
|
54
|
+
3. **Verify Fixes:** Run `/torusguard recheck` to ensure no regressions exist.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# TorusGuard Target Authorization Record
|
|
2
|
+
|
|
3
|
+
**Authorization ID:** `{{authorization_id}}`
|
|
4
|
+
**Generated At:** `{{timestamp}}`
|
|
5
|
+
**Valid Until:** `{{valid_until}}`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Target Identification
|
|
10
|
+
- **Project / Application:** `{{target_name}}`
|
|
11
|
+
- **Target URL / Hosts:** `{{target_hosts}}`
|
|
12
|
+
- **Scope Type:** `{{scope_type}}`
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 2. Permitted Boundaries
|
|
17
|
+
- **Allowed Path Prefixes:**
|
|
18
|
+
{{allowed_path_prefixes_list}}
|
|
19
|
+
|
|
20
|
+
- **Explicitly Forbidden / Excluded Paths:**
|
|
21
|
+
{{forbidden_paths_list}}
|
|
22
|
+
|
|
23
|
+
- **Max Navigation Depth:** `{{max_depth}}`
|
|
24
|
+
- **Max Request Budget:** `{{max_requests}}`
|
|
25
|
+
- **Allow State-Changing Methods:** `{{allow_state_changing_methods}}`
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 3. Owner Confirmation & Legal Statement
|
|
30
|
+
> [!IMPORTANT]
|
|
31
|
+
> The target application owner has confirmed that this testing environment is authorized for non-destructive, bounded runtime security validation.
|
|
32
|
+
|
|
33
|
+
- **Authorized By:** `{{authorized_by}}`
|
|
34
|
+
- **Confirmation Status:** `Owner Confirmed`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
### [{{rule_id}}] {{finding_title}}
|
|
2
|
+
|
|
3
|
+
**Severity:** `{{severity_badge}}` | **Auditable Confidence:** `{{confidence_score}}/100 {{confidence_band_badge}}`
|
|
4
|
+
**Finding ID:** `{{finding_id}}` | **Fingerprint:** `{{fingerprint_hash}}`
|
|
5
|
+
**Target Location:** `{{file_path}}:{{line_number}}` (`{{code_symbol}}`)
|
|
6
|
+
**Lifecycle Status:** `{{lifecycle_status}}` | **Exploitability:** `{{exploitability_status}}`
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
#### 1. Provenance Chain
|
|
11
|
+
- **Detection Rule:** `{{rule_id}}` (CWE-{{cwe_id}})
|
|
12
|
+
- **Triggering Input:** `{{triggering_source}}`
|
|
13
|
+
- **Sink Path:** `{{sink_expression}}`
|
|
14
|
+
|
|
15
|
+
#### 2. Raw Verified Evidence
|
|
16
|
+
```{{code_language}}
|
|
17
|
+
{{raw_evidence_snippet}}
|
|
18
|
+
```
|
|
19
|
+
> **Evidence Checksum (SHA-256):** `{{evidence_sha256}}`
|
|
20
|
+
|
|
21
|
+
#### 3. Objective Facts vs AI Interpretation
|
|
22
|
+
- **Verified Facts:** {{raw_facts_summary}}
|
|
23
|
+
- **AI Risk Analysis:** {{ai_interpretation}}
|
|
24
|
+
|
|
25
|
+
#### 4. Remediation Diff (Minimal Churn)
|
|
26
|
+
```diff
|
|
27
|
+
{{remediation_diff_preview}}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### 5. Retest & Verification
|
|
31
|
+
- **Verification Method:** {{verification_method}}
|
|
32
|
+
- **Current Retest Status:** `{{retest_status}}`
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Remediation Bundle: `{{bundle_id}}`
|
|
2
|
+
|
|
3
|
+
**Cluster ID:** `{{cluster_id}}`
|
|
4
|
+
**Target Rule:** `{{rule_id}}` (`{{rule_title}}`)
|
|
5
|
+
**Affected Files:** `{{affected_files}}`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Problem Statement & Risk
|
|
10
|
+
{{problem_statement}}
|
|
11
|
+
|
|
12
|
+
**Adversarial Abuse & Practical Impact:**
|
|
13
|
+
{{risk_explanation}}
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 2. Governed Minimal Patch Plan
|
|
18
|
+
- **Max Additions Boundary:** $\le 35$ lines (Proposed: `+{{additions_count}}`)
|
|
19
|
+
- **Max Deletions Boundary:** $\le 25$ lines (Proposed: `-{{deletions_count}}`)
|
|
20
|
+
- **Governance Review Level:** `{{governance_review_level}}`
|
|
21
|
+
|
|
22
|
+
### Framework-Native Diff
|
|
23
|
+
```diff
|
|
24
|
+
{{candidate_patch_diff}}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 3. Verification & Retest Method
|
|
30
|
+
{{verification_method}}
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 4. Residual Risk & Edge Cases
|
|
35
|
+
{{residual_risk_notes}}
|
|
@@ -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.
|