torusguard 1.3.6 → 2.0.0-alpha

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.
Files changed (110) hide show
  1. package/.torusguard/.manifest.json +9 -8
  2. package/.torusguard/auth.json +5 -0
  3. package/.torusguard/rules_catalog.json +242 -518
  4. package/.torusguard/runs/report-latest.html +3529 -364
  5. package/.torusguard/runs/run-20260918-105940-audit/manifest.json +2 -1
  6. package/.torusguard/runs/run-20260918-105940-audit/remediation.md +7 -0
  7. package/.torusguard/runs/run-20260919-145701-audit/findings.json +1 -0
  8. package/.torusguard/runs/run-20260919-145701-audit/findings.md +8 -0
  9. package/.torusguard/runs/run-20260919-145701-audit/manifest.json +12 -0
  10. package/.torusguard/runs/run-20260919-145701-audit/summary.md +5 -0
  11. package/.torusguard/runs/run-20260919-151729-audit/findings.json +1 -0
  12. package/.torusguard/runs/run-20260919-151729-audit/findings.md +8 -0
  13. package/.torusguard/runs/run-20260919-151729-audit/manifest.json +13 -0
  14. package/.torusguard/runs/run-20260919-151729-audit/remediation.md +7 -0
  15. package/.torusguard/runs/run-20260919-151729-audit/summary.md +5 -0
  16. package/.torusguard/runs/run-20260919-152340-audit/findings.json +1 -0
  17. package/.torusguard/runs/run-20260919-152340-audit/findings.md +8 -0
  18. package/.torusguard/runs/run-20260919-152340-audit/manifest.json +12 -0
  19. package/.torusguard/runs/run-20260919-152340-audit/summary.md +5 -0
  20. package/.torusguard/runs/run-20260919-152345-audit/findings.json +1 -0
  21. package/.torusguard/runs/run-20260919-152345-audit/findings.md +8 -0
  22. package/.torusguard/runs/run-20260919-152345-audit/manifest.json +12 -0
  23. package/.torusguard/runs/run-20260919-152345-audit/summary.md +5 -0
  24. package/.torusguard/runs/run-20260919-153500-audit/findings.json +1 -0
  25. package/.torusguard/runs/run-20260919-153500-audit/findings.md +8 -0
  26. package/.torusguard/runs/run-20260919-153500-audit/manifest.json +12 -0
  27. package/.torusguard/runs/run-20260919-153500-audit/summary.md +5 -0
  28. package/.torusguard/scripts/__pycache__/apply_runner.cpython-314.pyc +0 -0
  29. package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
  30. package/.torusguard/scripts/__pycache__/harden_runner.cpython-314.pyc +0 -0
  31. package/.torusguard/scripts/__pycache__/html_reporter.cpython-314.pyc +0 -0
  32. package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
  33. package/.torusguard/scripts/__pycache__/recipes_runner.cpython-314.pyc +0 -0
  34. package/.torusguard/scripts/__pycache__/report_sync.cpython-314.pyc +0 -0
  35. package/.torusguard/scripts/apply_runner.py +101 -8
  36. package/.torusguard/scripts/audit_runner.py +116 -11
  37. package/.torusguard/scripts/harden_runner.py +122 -68
  38. package/.torusguard/scripts/html_reporter.py +1170 -253
  39. package/.torusguard/scripts/manifest_builder.py +2 -0
  40. package/.torusguard/scripts/recheck_runner.py +2 -1
  41. package/.torusguard/scripts/recipes_runner.py +91 -8
  42. package/.torusguard/scripts/report_sync.py +134 -7
  43. package/.torusguard/scripts/status_runner.py +267 -0
  44. package/.torusguard/snapshots/20260921-182638/go.mod.bak +11 -0
  45. package/.torusguard/snapshots/20260921-185213/file.go.bak +5 -0
  46. package/README.md +314 -364
  47. package/bin/torusguard.js +190 -20
  48. package/package.json +6 -2
  49. package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
  50. package/skills/torusguard/bootstrap.py +45 -6
  51. package/skills/torusguard/payload/.manifest.json +29 -14
  52. package/skills/torusguard/payload/TORUSGUARD.md +145 -145
  53. package/skills/torusguard/payload/agents/auditor.md +41 -41
  54. package/skills/torusguard/payload/agents/profiler.md +49 -49
  55. package/skills/torusguard/payload/agents/remediator.md +41 -41
  56. package/skills/torusguard/payload/agents/reviewer.md +39 -39
  57. package/skills/torusguard/payload/agents/validator.md +46 -46
  58. package/skills/torusguard/payload/config/scope.json +24 -24
  59. package/skills/torusguard/payload/references/csharp-security.md +41 -41
  60. package/skills/torusguard/payload/references/go-security.md +41 -41
  61. package/skills/torusguard/payload/references/java-security.md +40 -40
  62. package/skills/torusguard/payload/references/polyglot-security-matrix.md +25 -25
  63. package/skills/torusguard/payload/references/rust-security.md +40 -40
  64. package/skills/torusguard/payload/rules/custom/.gitkeep +1 -1
  65. package/skills/torusguard/payload/rules/custom/README.md +30 -30
  66. package/skills/torusguard/payload/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
  67. package/skills/torusguard/payload/scripts/__pycache__/html_reporter.cpython-314.pyc +0 -0
  68. package/skills/torusguard/payload/scripts/__pycache__/report_sync.cpython-314.pyc +0 -0
  69. package/skills/torusguard/payload/scripts/__pycache__/sarif_exporter.cpython-314.pyc +0 -0
  70. package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
  71. package/skills/torusguard/payload/scripts/apply_runner.py +101 -8
  72. package/skills/torusguard/payload/scripts/audit_runner.py +116 -11
  73. package/skills/torusguard/payload/scripts/harden_runner.py +122 -68
  74. package/skills/torusguard/payload/scripts/html_reporter.py +1170 -253
  75. package/skills/torusguard/payload/scripts/manifest_builder.py +2 -0
  76. package/skills/torusguard/payload/scripts/recheck_runner.py +2 -1
  77. package/skills/torusguard/payload/scripts/recipes_runner.py +91 -8
  78. package/skills/torusguard/payload/scripts/report_sync.py +134 -7
  79. package/skills/torusguard/payload/scripts/rules_sync.py +321 -321
  80. package/skills/torusguard/payload/scripts/safety_gate.py +64 -64
  81. package/skills/torusguard/payload/scripts/status_runner.py +267 -0
  82. package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -41
  83. package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -41
  84. package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -40
  85. package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -25
  86. package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -40
  87. package/skills/torusguard/payload/templates/audit-report.template.md +54 -54
  88. package/skills/torusguard/payload/templates/authorization.template.md +34 -34
  89. package/skills/torusguard/payload/templates/finding-card.template.md +32 -32
  90. package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -35
  91. package/skills/torusguard/payload/workflows/apply.md +9 -1
  92. package/skills/torusguard/payload/workflows/audit.md +8 -2
  93. package/skills/torusguard/payload/workflows/harden.md +6 -1
  94. package/skills/torusguard/payload/workflows/init.md +7 -1
  95. package/skills/torusguard/payload/workflows/recipes.md +55 -0
  96. package/skills/torusguard/payload/workflows/report.md +59 -55
  97. package/skills/torusguard/payload/workflows/status.md +4 -1
  98. package/skills/torusguard/payload/workflows/torusguard-apply.md +110 -0
  99. package/skills/torusguard/payload/workflows/torusguard-audit.md +105 -0
  100. package/skills/torusguard/payload/workflows/torusguard-authorize.md +96 -0
  101. package/skills/torusguard/payload/workflows/torusguard-exploit-check.md +98 -0
  102. package/skills/torusguard/payload/workflows/torusguard-harden.md +104 -0
  103. package/skills/torusguard/payload/workflows/torusguard-init.md +106 -0
  104. package/skills/torusguard/payload/workflows/torusguard-recheck.md +101 -0
  105. package/skills/torusguard/payload/workflows/torusguard-recipes.md +55 -0
  106. package/skills/torusguard/payload/workflows/torusguard-report.md +105 -0
  107. package/skills/torusguard/payload/workflows/torusguard-status.md +103 -0
  108. package/skills/torusguard/payload/workflows/torusguard-verify.md +100 -0
  109. package/skills/torusguard/payload/workflows/torusguard-web-validate.md +96 -0
  110. package/skills/torusguard/payload/workflows/torusguard.md +19 -0
@@ -0,0 +1,104 @@
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: 1.4.0
5
+ agent: remediator
6
+ lifecycle-phase: Phase 4 (Remediation Formulation)
7
+ required-skills:
8
+ - torusguard-harden
9
+ scripts-binding:
10
+ - .torusguard/scripts/harden_runner.py
11
+ - .torusguard/scripts/report_sync.py
12
+ - .torusguard/scripts/run_manager.py
13
+ - .torusguard/scripts/diff_guard.py
14
+ ---
15
+
16
+ # /torusguard harden — Governed Remediation & Bundle Packaging
17
+
18
+ $ARGUMENTS
19
+
20
+ ---
21
+
22
+ ## Objective
23
+ Governed remediation formulation under strict Ponytail Protocol bounds (<=35 add, <=25 del).
24
+
25
+ Supported CLI flags:
26
+ - `npx torusguard harden [--target <dir>]` : Specify project root directory
27
+ - `npx torusguard harden --dry-run` : Preview candidate patches without modifying disk files
28
+ - `npx torusguard harden --severity <critical|high|medium|low>` : Filter findings by minimum severity floor
29
+
30
+ ---
31
+
32
+ ## Mandatory Pre-Flight Context Inspection
33
+
34
+ Inspect finding targets and patch constraints before generating diffs:
35
+ 1. **Target Finding (`findings.md`):** Identify prioritized verified findings.
36
+ 2. **Ponytail Protocol:** Enforce hard limit ($\le 35$ additions, $\le 25$ deletions). Ban rewrites.
37
+ 3. **Sensitive Path Review:** Flag changes touching `auth/` or `settings.py` for human sign-off.
38
+ 4. **Behavior Preservation:** Ensure patch addresses flaw without breaking public APIs.
39
+ 5. **Dry-Run Rule:** Do NOT apply changes to disk during harden; emit bundle for review.
40
+ 6. **Backup Readiness:** Ensure rollback procedures are prepared before staging patch.
41
+
42
+ ---
43
+
44
+ ## When to Use /torusguard harden
45
+
46
+ | Trigger Scenario | Recommended Action |
47
+ | :--- | :--- |
48
+ | Formulating minimal patches for verified findings | Run `/torusguard harden` |
49
+ | Packaging a 4-artifact remediation bundle for review | Run `/torusguard harden` |
50
+ | Writing and applying changes to code files | Run `/torusguard apply` |
51
+ | Differentially re-scanning code after patch application | Run `/torusguard recheck` |
52
+ | Discovering new vulnerabilities | Run `/torusguard audit` |
53
+
54
+ ---
55
+
56
+ ## Living Report Invariant
57
+ - Candidate patches transition findings in `security_report.md` into `CANDIDATE 🟡` status.
58
+ - Every patch strictly conforms to Ponytail bounds (<= 35 additions, <= 25 deletions).
59
+
60
+ ## Execution Steps
61
+
62
+ 1. **Select Target Finding:** Choose verified flaw from active run directory.
63
+ 2. **Examine Live Code Context:** Read surrounding lines (±15) of vulnerable sink.
64
+ 3. **Draft Unified Diff:** Formulate minimal fix adhering to Ponytail Protocol limits.
65
+ 4. **Audit Patch Safety:** Run `python .torusguard/scripts/diff_guard.py <patch.diff>`.
66
+ 5. **Package 4-Artifact Bundle:** Write `patch.diff`, `plan.md`, `verification.md`, `rollback.md` to `.torusguard/runs/<run_id>/remediation/<finding_id>/`.
67
+
68
+ ---
69
+
70
+ ## Failure Recovery
71
+
72
+ - **Line Churn Exceeded (>35 add or >25 del):** Decompose patch into smaller sequential sub-fixes.
73
+ - **Sensitive Path Conflict:** Mark bundle with `Requires Sensitive-Path Sign-Off` in `plan.md`.
74
+ - **Finding Not Found:** Ensure finding ID exists in active `findings.md`.
75
+ - **Halt Trigger:** Abort if target source file cannot be read from disk.
76
+
77
+ ---
78
+
79
+ ## Hallucination Guard
80
+
81
+ - ❌ Never generate full-file replacements or unconstrained cosmetic code refactoring.
82
+ - ❌ Never modify imports, variables, or functions unrelated to the vulnerability.
83
+ - ✅ Always calculate addition and deletion line counts before emitting `patch.diff`.
84
+
85
+ ---
86
+
87
+ ## Output Card Format
88
+
89
+ ```markdown
90
+ ### 🛠️ TorusGuard Remediation Bundle
91
+ - **Finding Target:** `TG-XXX-HASH` ([Vulnerability Name])
92
+ - **File Affected:** `src/path/to/file.py`
93
+ - **Line Churn:** +[Additions] / -[Deletions] (Ponytail: PASS)
94
+ - **Sensitive Path:** [Yes (Sign-Off Needed) / No (Standard)]
95
+ - **Bundle Path:** `.torusguard/runs/<run_id>/remediation/<finding_id>/`
96
+ - **Status:** READY FOR REVIEW — run `/torusguard apply` to execute
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Next Steps
102
+
103
+ 1. Review proposed diff in `.torusguard/runs/<run_id>/remediation/<finding_id>/patch.diff`.
104
+ 2. Run `/torusguard apply` to execute the governed patch with automatic rollback backup.
@@ -0,0 +1,106 @@
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: 1.4.0
5
+ agent: profiler
6
+ lifecycle-phase: Phase 0 (Baseline Setup)
7
+ required-skills:
8
+ - torusguard-init
9
+ scripts-binding:
10
+ - .torusguard/scripts/report_sync.py
11
+ - .torusguard/scripts/stack_detect.py
12
+ ---
13
+
14
+ # /torusguard init — Project Baseline & Workspace Initialization
15
+
16
+ $ARGUMENTS
17
+
18
+ ---
19
+
20
+ ## Objective
21
+ Baseline project discovery, workspace scaffolding, stack detection, and security rule activation.
22
+
23
+ Supported CLI flags:
24
+ - `npx torusguard init [--target <dir>]` : Scaffold workspace into specified root directory
25
+ - `npx torusguard init --template <golang|nextjs|fastapi|express|django|react>` : Guide stack configuration explicitly
26
+ - `npx torusguard init --audit` : Run immediate baseline audit post-initialization
27
+ - `npx torusguard init --force` : Force overwrite existing workspace and re-scaffold baseline
28
+
29
+ ---
30
+
31
+ ## Mandatory Pre-Flight Context Inspection
32
+
33
+ Inspect workspace state before running initialization:
34
+ 1. **Config State (`.torusguard/config/torusguard.json`):** Check if workspace is already initialized. If active, prompt before re-writing.
35
+ 2. **Project Manifests:** Check root for `package.json`, `manage.py`, `requirements.txt`, `pyproject.toml`, `go.mod`, or `Cargo.toml`.
36
+ 3. **Disclosure Policy (`SECURITY.md`):** Check for existing responsible disclosure policy.
37
+ 4. **Bootstrapper:** If `.torusguard/` is absent, invoke `python skills/torusguard/bootstrap.py` to unpack offline assets.
38
+ 5. **Runtime Preconditions:** Ensure Python 3.10+ is available in the current execution shell.
39
+
40
+ ---
41
+
42
+ ## When to Use /torusguard init
43
+
44
+ | Trigger Scenario | Recommended Command |
45
+ | :--- | :--- |
46
+ | First-time onboarding in any repository | Run `/torusguard init` |
47
+ | Framework upgrade or major dependency changes | Run `/torusguard init` to refresh tailored rules |
48
+ | Repository already configured | Run `/torusguard audit` |
49
+ | Inspecting existing configuration | Run `/torusguard status` |
50
+ | Testing legal boundaries | Run `/torusguard authorize` |
51
+
52
+ ---
53
+
54
+ ## Living Report Invariant
55
+ - Provisions baseline `security_report.md` single-source-of-truth ledger.
56
+ - Activates tailored rules across 18 families based on detected stack.
57
+
58
+ ## Execution Steps
59
+
60
+ 1. **Scaffold Directory Topology:** Verify `.torusguard/` structure (`config/`, `rules/active/`, `runs/`, `scripts/`, `workflows/`, `templates/`, `schemas/`).
61
+ 2. **Execute Stack Detection:**
62
+ ```bash
63
+ python .torusguard/scripts/stack_detect.py .
64
+ ```
65
+ 3. **Activate Tailored Rules:** Symlink or copy matching security rules from `.torusguard/rules/` into `.torusguard/rules/active/`.
66
+ 4. **Write Configuration (`.torusguard/config/torusguard.json`):**
67
+ Record detected stack, enabled rules count, timestamp, and runtime constraints.
68
+ 5. **Verify Initialization:** Assert `.torusguard/config/torusguard.json` and `.torusguard/config/scope.json` exist.
69
+
70
+ ---
71
+
72
+ ## Failure Recovery
73
+
74
+ - **Script Exit 1 (Detection Failed):** Check Python version (`python --version` >= 3.10) and verify read access to root manifests.
75
+ - **Permission Error:** Verify write permissions for `.torusguard/config/` and `.torusguard/rules/active/`.
76
+ - **Missing Directories:** Re-run directory scaffolding if any subfolder creation fails.
77
+ - **Halt Condition:** If root directory is empty, halt and prompt user to open the project root.
78
+
79
+ ---
80
+
81
+ ## Hallucination Guard
82
+
83
+ - ❌ Never invent framework dependencies not present in `package.json` or `requirements.txt`.
84
+ - ❌ Never overwrite an existing `.torusguard/config/scope.json` containing authorized domains.
85
+ - ✅ Always execute `.torusguard/scripts/stack_detect.py` to ground detected technologies.
86
+
87
+ ---
88
+
89
+ ## Output Card Format
90
+
91
+ ```markdown
92
+ ### 🛡️ TorusGuard Workspace Initialization
93
+ - **Primary Framework:** [Detected Stack or None]
94
+ - **Components:** [Backend / Frontend / Database]
95
+ - **Active Rules:** [Count] rules enabled in `.torusguard/rules/active/`
96
+ - **Config:** `.torusguard/config/torusguard.json` generated
97
+ - **Scope Template:** `.torusguard/config/scope.json` ready
98
+ - **Status:** READY — run `/torusguard audit` to scan codebase
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Next Steps
104
+
105
+ 1. Run `/torusguard authorize` to define allowed target URLs and legal scan boundaries.
106
+ 2. Run `/torusguard audit` to execute the baseline static security audit.
@@ -0,0 +1,101 @@
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: 1.3.6
5
+ agent: reviewer
6
+ lifecycle-phase: Phase 6 (Targeted Recheck & Verification)
7
+ required-skills:
8
+ - torusguard-recheck
9
+ scripts-binding:
10
+ - .torusguard/scripts/recheck_runner.py
11
+ - .torusguard/scripts/report_sync.py
12
+ - .torusguard/scripts/run_manager.py
13
+ - .torusguard/scripts/finding_scorer.py
14
+ ---
15
+
16
+ # /torusguard recheck — Targeted Differential Recheck & Regression Audit
17
+
18
+ $ARGUMENTS
19
+
20
+ ---
21
+
22
+ ## Objective
23
+ Targeted differential AST re-scan, fix closure verification, and regression state transitions.
24
+
25
+ ---
26
+
27
+ ## Mandatory Pre-Flight Context Inspection
28
+
29
+ Inspect applied patch history and target file scope before re-checking:
30
+ 1. **Applied Patch Record:** Verify `apply-log.json` or modified file list exists in the active run.
31
+ 2. **Scope Limitation:** Restrict differential scan strictly to modified files to conserve token budget.
32
+ 3. **Rollback Availability:** Confirm `.bak` snapshot exists in `pre_apply/` in case regression is detected.
33
+ 4. **4-State Transition Engine:** Prepare to transition findings to `Fixed`, `Partially Fixed`, `Not Fixed`, or `Regression`.
34
+ 5. **Fresh Syntax Validation:** Ensure no compiler or syntax errors exist before re-evaluating rules.
35
+ 6. **AST Consistency:** Ensure imported dependencies on modified lines resolve correctly.
36
+
37
+ ---
38
+
39
+ ## When to Use /torusguard recheck
40
+
41
+ | Trigger Scenario | Recommended Action |
42
+ | :--- | :--- |
43
+ | Immediately after applying a remediation patch | Run `/torusguard recheck` |
44
+ | Verifying that a specific finding is eliminated | Run `/torusguard recheck` |
45
+ | Checking whether a patch introduced new security flaws | Run `/torusguard recheck` |
46
+ | Whole repository baseline audit | Run `/torusguard audit` |
47
+ | Generating final signed release report | Run `/torusguard report` |
48
+
49
+ ---
50
+
51
+ ## Living Report Invariant
52
+ - Verified fix closures transition findings in `security_report.md` to `RESOLVED 🟢`.
53
+ - Regressions transition findings to `REGRESSED ❌`.
54
+
55
+ ## Execution Steps
56
+
57
+ 1. **Identify Modified Files:** Extract list of altered files from latest apply step.
58
+ 2. **Execute Differential AST Scan:** Re-run active security rules exclusively against modified files.
59
+ 3. **Evaluate Finding Status:**
60
+ - If original vulnerable AST pattern is absent and no new sink appears: transition to `Fixed`.
61
+ - If new security rule triggers on altered lines: classify as `Regression`.
62
+ 4. **Update Finding State:** Record verified resolution status into `findings.json`.
63
+ 5. **Emit Recheck Report:** Write `recheck-report.md` into the active run folder.
64
+
65
+ ---
66
+
67
+ ## Failure Recovery
68
+
69
+ - **Finding Still Present (`Not Fixed`):** Review patch diff; the remediation did not neutralize the AST sink.
70
+ - **New Vulnerability Detected (`Regression`):** Alert operator; prompt to revert from `.bak` snapshot.
71
+ - **File Not Found:** Verify file path matches git repository layout.
72
+ - **Halt Trigger:** Abort if diff shows changes outside approved patch scope.
73
+
74
+ ---
75
+
76
+ ## Hallucination Guard
77
+
78
+ - ❌ Never mark a finding as `Fixed` without re-scanning the actual AST of the patched file.
79
+ - ❌ Never ignore new warnings introduced in modified lines.
80
+ - ✅ Always provide before/after line comparisons confirming sink removal.
81
+
82
+ ---
83
+
84
+ ## Output Card Format
85
+
86
+ ```markdown
87
+ ### ✅ TorusGuard Differential Recheck
88
+ - **Files Re-scanned:** [List of modified files]
89
+ - **Target Finding:** `TG-XXX-HASH`
90
+ - **Result:** [FIXED / REGRESSION / PARTIAL]
91
+ - **Regressions Introduced:** 0
92
+ - **Report:** `.torusguard/runs/<run_id>/recheck-report.md`
93
+ - **Status:** VERIFIED — ready for `/torusguard report`
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Next Steps
99
+
100
+ 1. Run `/torusguard report` to generate executive summary and export OASIS SARIF v2.1.0 data.
101
+ 2. Commit the verified patch to version control.
@@ -0,0 +1,55 @@
1
+ ---
2
+ description: Explore, search, export, and project distilled Golden Fix Recipes in persistent security memory.
3
+ tools: Read, Grep, Glob, Bash, Write
4
+ version: 1.4.0
5
+ agent: remediator
6
+ lifecycle-phase: Phase 6 (Memory & Recipes)
7
+ required-skills:
8
+ - torusguard-recipes
9
+ scripts-binding:
10
+ - .torusguard/scripts/recipes_runner.py
11
+ - .torusguard/scripts/memory_engine.py
12
+ ---
13
+
14
+ # /torusguard recipes — Golden Fix Recipe Explorer & Memory Distillation
15
+
16
+ $ARGUMENTS
17
+
18
+ ---
19
+
20
+ ## Objective
21
+ Inspect, search, export, and project reusable, verified Ponytail remediation code snippets distilled from passing security patches and persistent memory patterns.
22
+
23
+ ---
24
+
25
+ ## Command Flags & Arguments
26
+
27
+ | Mode | Command Syntax | Description |
28
+ | :--- | :--- | :--- |
29
+ | **List Recipes** | `npx torusguard recipes` | List all distilled golden fix recipes with verification counts and churn |
30
+ | **Search Filter** | `npx torusguard recipes --search <query>` | Filter recipes by keyword, rule family (e.g. `TG-SEC`), or language |
31
+ | **Inspect Detail** | `npx torusguard recipes --detail <id>` | View complete unified diff snippet for a specific recipe |
32
+ | **Export Catalog** | `npx torusguard recipes --export <file>` | Export recipes to `.json` or `.md` catalog format |
33
+ | **Apply Preview** | `npx torusguard recipes --apply <id>` | Project recipe diff onto codebase for manual review |
34
+ | **Target Directory** | `npx torusguard recipes --target <dir>` | Specify custom project root directory |
35
+
36
+ ---
37
+
38
+ ## Execution Steps
39
+
40
+ 1. **Query Memory Patterns:** Read `.torusguard/memory/patterns.json` for verified `golden_fix_recipe` entries.
41
+ 2. **Apply Filter / Search:** Match `--search` query against rule IDs, titles, diffs, and target file types.
42
+ 3. **Render 75-Column Cards:** Format recipe cards showing verified counts, rule family, and Ponytail additions/deletions.
43
+ 4. **Export / Apply:** If requested, write export file or render projected patch snippet.
44
+
45
+ ---
46
+
47
+ ## Output Card Format
48
+
49
+ ```markdown
50
+ ### 🛡️ TorusGuard Golden Fix Recipes
51
+ - **Total Distilled:** [Count] verified recipes
52
+ - **Filter:** [Query or None]
53
+ - **Ponytail Bounds:** All recipes strictly <= 35 additions, <= 25 deletions
54
+ - **Storage:** `.torusguard/memory/patterns.json`
55
+ ```
@@ -0,0 +1,105 @@
1
+ ---
2
+ description: Executive posture reporting, interactive HTML dashboard generation, directory attack surface heatmap, and OASIS SARIF v2.1.0 structured export.
3
+ tools: Read, Grep, Glob, Bash, Write
4
+ version: 2.2.0
5
+ agent: reviewer
6
+ lifecycle-phase: Phase 7 (Reporting & SARIF Export)
7
+ required-skills:
8
+ - torusguard-report
9
+ scripts-binding:
10
+ - .torusguard/scripts/html_reporter.py
11
+ - .torusguard/scripts/report_sync.py
12
+ - .torusguard/scripts/sarif_exporter.py
13
+ - .torusguard/scripts/run_manager.py
14
+ - .torusguard/scripts/term_ui.py
15
+ ---
16
+
17
+ # /torusguard report — Unified Security Posture Report & SARIF / HTML Export
18
+
19
+ $ARGUMENTS
20
+
21
+ ---
22
+
23
+ ## Objective
24
+ Generate an executive security posture report, interactive dark-mode HTML dashboard (`report.html`), and schema-compliant OASIS SARIF v2.1.0 log (`results.sarif`) with zero network dependencies.
25
+
26
+ ---
27
+
28
+ ## Dual Mode Execution Syntax
29
+
30
+ | Target Artifact | Mode A: Terminal CLI | Mode B: AI Chat Slash Command | Output Location |
31
+ | :--- | :--- | :--- | :--- |
32
+ | **Interactive HTML Dashboard** | `npx torusguard report --html` | `/torusguard report --html` or `/torusguard-report` | `report.html` (workspace root) + `.torusguard/runs/report-latest.html` |
33
+ | **OASIS SARIF v2.1.0 Log** | `npx torusguard report --sarif` | `/torusguard report --sarif` | `.torusguard/runs/results-latest.sarif` |
34
+ | **Combined (Both)** | `npx torusguard report --html --sarif` | `/torusguard report --html --sarif` | Both `report.html` and `results-latest.sarif` in a single pass |
35
+ | **Custom Path** | `npx torusguard report --html --out <path>` | `/torusguard report --out <path>` | Specified path + latest run mirror |
36
+ | **Monorepo Subproject** | `npx torusguard report --target <dir> --html` | `/torusguard report --target <dir>` | `<dir>/report.html` |
37
+
38
+ ---
39
+
40
+ ## Mandatory Pre-Flight Context Inspection
41
+
42
+ Inspect run records and reporting parameters before generating release artifacts:
43
+ 1. **Active Run Records:** Ensure target run folder or `.torusguard/runs/` contains valid run records.
44
+ 2. **Dual-Ledger Ground Truth:** Confirm that `security_report.md` at workspace root is in lockstep with findings.
45
+ 3. **SARIF v2.1.0 Schema:** Validate output structure against official OASIS SARIF standard (`sarif-schema-2.1.0.json`).
46
+ 4. **Multi-Analysis Category:** Tag static findings under category `torusguard/static` to prevent CI collisions.
47
+ 5. **Zero External CDN:** Ensure all icons, gauges, and scripts in `report.html` are 100% self-contained and offline-ready.
48
+ 6. **Secret Masking:** Ensure zero unredacted authorization tokens or API keys appear in report text.
49
+
50
+ ---
51
+
52
+ ## Interactive Dashboard Features (v2.2.0)
53
+
54
+ When viewing `report.html` in any browser:
55
+ 1. **Safe Defenses vs Harmed Exposure:** Complete Defended Invariants inventory across all 74 rules in 18 architectural families. Clean codebases earn 100/100 (74 Defended, 0 Harmed).
56
+ 2. **Directory Attack Surface Heatmap:** Visual directory tree of exposure risk. Clicking any directory card filters the findings table to that specific folder.
57
+ 3. **Golden Recipe Explorer:** Distilled, verified fix patterns with before/after code templates and one-click clipboard copying.
58
+ 4. **Prescriptive Next Best Defenses:** Stack-aware security recommendations with copyable `npx torusguard harden` commands.
59
+ 5. **Client-Side Exporters:** Zero-network buttons to download OASIS SARIF v2.1.0 and CSV records directly from browser memory.
60
+ 6. **Multi-Agent AI Prompt Presets:** One-click prompts tailored for Cursor (`.cursorrules`), Claude Code (`CLAUDE.md`), Antigravity, and GitHub Copilot.
61
+ 7. **Print & PDF Styling:** Built-in high-contrast `@media print` layout for boardroom and compliance distribution.
62
+
63
+ ---
64
+
65
+ ## Execution Steps
66
+
67
+ 1. **Detect Mode & Arguments:**
68
+ - Parse `--html`, `--sarif`, `--out`, `--target`, and `--run` from `$ARGUMENTS`.
69
+ - If no format flag is specified in chat, default to generating the visual HTML dashboard (`report.html`).
70
+ 2. **Execute Reporter Scripts:**
71
+ - **For SARIF:**
72
+ ```bash
73
+ python .torusguard/scripts/sarif_exporter.py [--output <path>] [--root <target>]
74
+ ```
75
+ - **For HTML:**
76
+ ```bash
77
+ python .torusguard/scripts/html_reporter.py [--out <path>] [--root <target>]
78
+ ```
79
+ 3. **Synchronize Dual Ledger:**
80
+ - Verify `security_report.md` matches `report.html` findings and posture score.
81
+ 4. **Emit 75-Column Visual Summary Card:**
82
+ - Present markdown output card with direct clickable links to both `report.html` and `security_report.md`.
83
+
84
+ ---
85
+
86
+ ## Output Card Format
87
+
88
+ ```markdown
89
+ ### 🛡️ TorusGuard Security Posture Report Emitted
90
+ - **Posture Score:** [Score]/100 ([Status Label])
91
+ - **Invariants Defended:** [N] Defended · [M] Harmed (74 Rules)
92
+ - **Living Ledger:** [security_report.md](file:///path/to/security_report.md)
93
+ - **HTML Dashboard:** [report.html](file:///path/to/report.html)
94
+ - **SARIF v2.1.0 Export:** [results-latest.sarif](file:///path/to/results-latest.sarif)
95
+ - **Status:** COMPLETE — dual-ledger synchronized
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Failure Recovery
101
+
102
+ - **Missing Run Folder:** Auto-discover the latest timestamped run in `.torusguard/runs/`.
103
+ - **Windows File Lock:** `html_reporter.py` uses atomic temporary write swapping with exponential retry.
104
+ - **Missing SARIF Input:** Auto-discovers findings from the latest audit run in `.torusguard/runs/`.
105
+ - **Clean Workspace:** Emits 100/100 posture score with all 74 defended invariants listed.
@@ -0,0 +1,103 @@
1
+ ---
2
+ description: Read-only diagnostic overview of workspace security posture, active configuration, rules catalog, and run history.
3
+ tools: Read, Grep, Glob, Bash
4
+ version: 1.4.0
5
+ agent: reviewer
6
+ lifecycle-phase: System / Diagnostics
7
+ required-skills:
8
+ - torusguard-status
9
+ scripts-binding:
10
+ - .torusguard/scripts/report_sync.py
11
+ - .torusguard/scripts/run_manager.py
12
+ ---
13
+
14
+ # /torusguard status — Workspace Security Posture & Diagnostic Overview
15
+
16
+ $ARGUMENTS
17
+
18
+ ---
19
+
20
+ ## Objective
21
+ Read-only diagnostic overview of workspace security posture, active configuration, and run history.
22
+
23
+ Supported CLI flags:
24
+ - `npx torusguard status [--target <dir>]` : Diagnostic check on specified project directory
25
+
26
+ ---
27
+
28
+ ## Mandatory Pre-Flight Context Inspection
29
+
30
+ Inspect workspace state and configuration records prior to status display:
31
+ 1. **Config State (`.torusguard/config/torusguard.json`):** Confirm workspace initialization and read detected stack.
32
+ 2. **Active Rules Directory (`.torusguard/rules/active/`):** Count active rule files.
33
+ 3. **Run Folder Ledger (`.torusguard/runs/`):** Check run history and locate latest `manifest.json`.
34
+ 4. **Scope Record (`.torusguard/config/scope.json`):** Check whether runtime authorization TTL is active or expired.
35
+ 5. **Read-Only Invariant:** Ensure command performs zero file modifications or disk mutations.
36
+
37
+ ---
38
+
39
+ ## When to Use /torusguard status
40
+
41
+ | Trigger Scenario | Recommended Action |
42
+ | :--- | :--- |
43
+ | Checking workspace configuration and active security posture | Run `/torusguard status` |
44
+ | Reviewing recent audit runs and finding counts | Run `/torusguard status` |
45
+ | Checking active legal scope authorization TTL | Run `/torusguard status` |
46
+ | Initializing workspace for the first time | Run `/torusguard init` |
47
+ | Executing full security scan | Run `/torusguard audit` |
48
+
49
+ ---
50
+
51
+ ## Living Report Invariant
52
+ - Reads current health score and status breakdown directly from `security_report.md`.
53
+ - Displays 18 rule families and 74 rules in standardized 75-column terminal cards.
54
+
55
+ ## Execution Steps
56
+
57
+ 1. **Read Configuration:** Load `.torusguard/config/torusguard.json`; extract stack, version, and enabled rule count.
58
+ 2. **Enumerate Active Rules:** Count rule files physically present in `.torusguard/rules/active/`.
59
+ 3. **Inspect Run History:**
60
+ ```bash
61
+ python .torusguard/scripts/run_manager.py list
62
+ ```
63
+ 4. **Evaluate Scope Expiry:** Parse `.torusguard/config/scope.json`; report if TTL is valid or expired.
64
+ 5. **Print Status Overview:** Render complete workspace diagnostic overview card.
65
+
66
+ ---
67
+
68
+ ## Failure Recovery
69
+
70
+ - **Uninitialized Workspace:** If config is missing, prompt user to execute `/torusguard init`.
71
+ - **Zero Runs Found:** Display clean status card noting no historical audit runs exist yet.
72
+ - **Corrupt Config File:** Report parsing error and recommend re-running `/torusguard init`.
73
+ - **Halt Trigger:** Abort command if read access to `.torusguard/` is denied.
74
+
75
+ ---
76
+
77
+ ## Hallucination Guard
78
+
79
+ - ❌ Never display fabricated finding counts not substantiated by run manifests.
80
+ - ❌ Never execute modifying shell commands or edit source code during status inspection.
81
+ - ✅ Always report factual file counts from `.torusguard/rules/active/` and `.torusguard/runs/`.
82
+
83
+ ---
84
+
85
+ ## Output Card Format
86
+
87
+ ```markdown
88
+ ### 🛡️ TorusGuard Workspace Status
89
+ - **Version:** v0.9.2
90
+ - **Framework Detected:** [Stack or None]
91
+ - **Active Rules:** [Count] rules active in `.torusguard/rules/active/`
92
+ - **Total Runs:** [Count] historical runs recorded
93
+ - **Latest Run:** `run-YYYYMMDD-HHMMSS` ([Findings Count] findings)
94
+ - **Scope Status:** [Authorized (TTL Active) / Expired / Unconfigured]
95
+ - **Health Posture:** [GOOD / ACTION NEEDED]
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Next Steps
101
+
102
+ 1. Run `/torusguard audit` to scan codebase for security vulnerabilities.
103
+ 2. Run `/torusguard authorize` to configure or refresh live target scope.
@@ -0,0 +1,100 @@
1
+ ---
2
+ description: Evidence sufficiency verification, live disk line match audit, and finding score refinement.
3
+ tools: Read, Grep, Glob, Bash, Write
4
+ version: 1.3.6
5
+ agent: validator
6
+ lifecycle-phase: Phase 3a (Evidence Verification)
7
+ required-skills:
8
+ - torusguard-verify
9
+ scripts-binding:
10
+ - .torusguard/scripts/report_sync.py
11
+ - .torusguard/scripts/finding_scorer.py
12
+ ---
13
+
14
+ # /torusguard verify — Evidence Verification & Score Refinement
15
+
16
+ $ARGUMENTS
17
+
18
+ ---
19
+
20
+ ## Objective
21
+ Evidence sufficiency verification, live disk line match audit, and finding score refinement.
22
+
23
+ ---
24
+
25
+ ## Mandatory Pre-Flight Context Inspection
26
+
27
+ Inspect finding records and evidence integrity before verification:
28
+ 1. **Latest Run Records (`.torusguard/runs/`):** Locate most recent audit run directory.
29
+ 2. **Finding Files:** Confirm `findings.md` or `findings.json` exists in the target run folder.
30
+ 3. **Live File Drift:** Assert cited source files have not been edited or relocated on disk.
31
+ 4. **Scoring Model Calibration:** Ensure `finding_scorer.py` evaluates all 5 rubric dimensions.
32
+ 5. **Role Boundary:** Enforce validator role; do not apply code modifications during verification.
33
+
34
+ ---
35
+
36
+ ## When to Use /torusguard verify
37
+
38
+ | Trigger Scenario | Recommended Action |
39
+ | :--- | :--- |
40
+ | Auditing whether static findings are valid code flaws | Run `/torusguard verify` |
41
+ | Upgrading Medium confidence finding to Confirmed | Run `/torusguard verify` |
42
+ | No audit run executed yet | Run `/torusguard audit` first |
43
+ | Running live network requests against endpoints | Run `/torusguard web-validate` |
44
+ | Generating patch after verification | Run `/torusguard harden` |
45
+
46
+ ---
47
+
48
+ ## Living Report Invariant
49
+ - Confirmed evidence sufficiency transitions findings in `security_report.md` to `VERIFIED 🟠`.
50
+ - False positives transition to `FALSE POSITIVE ⚪`.
51
+
52
+ ## Execution Steps
53
+
54
+ 1. **Locate Target Findings:** Load active findings from latest run directory.
55
+ 2. **Live Disk Line Match:** Read current code at cited line ranges; verify AST snippet matches.
56
+ 3. **Audit Evidence Sufficiency:** Assess whether taint path is unbroken and caller context is exposed.
57
+ 4. **Refine Confidence Scores:**
58
+ ```bash
59
+ python .torusguard/scripts/finding_scorer.py --run <run_dir> --verify
60
+ ```
61
+ 5. **Classify Status:** Assign verified state (`Confirmed`, `Plausible`, or `False Positive / Disputed`).
62
+ 6. **Emit Verification Ledger:** Write `verified-evidence.md` into the active run folder.
63
+
64
+ ---
65
+
66
+ ## Failure Recovery
67
+
68
+ - **Missing Run Folder:** Run `/torusguard audit` first to produce a valid run baseline.
69
+ - **Line Drift Detected:** Flag line mismatch; scan nearby lines (±25) for relocated AST sink.
70
+ - **Malformed Finding JSON:** Repair JSON structure using finding schema before scoring.
71
+ - **Halt Trigger:** Abort if cited files are completely deleted from disk.
72
+
73
+ ---
74
+
75
+ ## Hallucination Guard
76
+
77
+ - ❌ Never confirm a finding if the cited sink has already been sanitized by middleware.
78
+ - ❌ Never bump confidence score without documenting unbroken taint source-to-sink flow.
79
+ - ✅ Always anchor line matches to live disk reads using `view_file`.
80
+
81
+ ---
82
+
83
+ ## Output Card Format
84
+
85
+ ```markdown
86
+ ### 🧪 TorusGuard Evidence Verification
87
+ - **Run ID:** `run-YYYYMMDD-HHMMSS-audit`
88
+ - **Findings Evaluated:** [Count] findings
89
+ - **Confirmed Real:** [Count] verified flaws
90
+ - **Downgraded / False Positives:** [Count] filtered out
91
+ - **Refined Mean Score:** [Score]/100
92
+ - **Ledger:** `.torusguard/runs/<run_id>/verified-evidence.md`
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Next Steps
98
+
99
+ 1. Run `/torusguard web-validate` if live endpoint probing is required.
100
+ 2. Run `/torusguard harden` to build surgical patch bundles for verified flaws.