torusguard 1.3.2 โ†’ 1.3.3

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.
@@ -19,11 +19,12 @@ Safely apply approved remediation bundles to disk source files, capturing a byte
19
19
  ## Execution Steps
20
20
 
21
21
  1. **Load Bundle:** Read `patch.diff` and metadata from `.torusguard/runs/<run_id>/remediation/<finding_id>/`.
22
- 2. **Pre-Apply Snapshot:** Save exact backup to `.torusguard/runs/<run_id>/pre_apply/<filename>.bak`.
23
- 3. **Obtain Human Gate:** Confirm user approval for proposed diff.
24
- 4. **Apply Patch:** Execute surgical modification using `replace_file_content` or `patch`.
25
- 5. **Assert Integrity:** Verify modified file compiles cleanly without syntax errors.
26
- 6. **Record Ledger:** Log timestamp, file path, and post-patch SHA-256 in `apply-log.json`.
22
+ 2. **Handle CLI Failures:** If the CLI `npx torusguard apply` throws an error or fails to apply the patch, YOU MUST step in and apply it manually.
23
+ 3. **Pre-Apply Snapshot:** Save exact backup to `.torusguard/runs/<run_id>/pre_apply/<filename>.bak`.
24
+ 4. **Obtain Human Gate:** Confirm user approval for proposed diff.
25
+ 5. **Apply Patch Manually:** Execute the surgical modification directly on the target file using `replace_file_content`. Ensure the lines match the `patch.diff` formulated during harden phase.
26
+ 6. **Assert Integrity:** Verify modified file compiles cleanly without syntax errors (e.g. running `npm run build` or `python -m py_compile`).
27
+ 7. **Record Ledger:** Log timestamp, file path, and post-patch SHA-256 in `apply-log.json`.
27
28
 
28
29
  ---
29
30
 
@@ -32,12 +33,13 @@ Safely apply approved remediation bundles to disk source files, capturing a byte
32
33
  - Always create a rollback snapshot before modifying disk code.
33
34
  - If compile or syntax error occurs, instantly restore from `.bak`.
34
35
  - Require explicit operator confirmation before writing changes.
36
+ - **Do not give up** if the CLI automation fails; the AI Agent must manually complete the patching process.
35
37
 
36
38
  ---
37
39
 
38
40
  ## Output Format
39
41
  ```markdown
40
- ๐Ÿš€ [TorusGuard] Patch Applied Successfully
42
+ ๐Ÿš€ [TorusGuard] Patch Applied Successfully (AI Assisted)
41
43
  - Finding Target: <Finding ID> | File: <Path>
42
44
  - Churn: +<Additions> / -<Deletions>
43
45
  - Rollback Backup: `.torusguard/runs/<run_id>/pre_apply/<file>.bak`
@@ -65,6 +65,11 @@ Execute static AST analysis, query memory context, compute 0โ€“100 confidence sc
65
65
  ```markdown
66
66
  ๐Ÿ›ก๏ธ [TorusGuard] Static Code Audit Completed
67
67
  - Run ID: run-YYYYMMDD-HHMMSS-audit | Files: <Count> | Findings: <Count>
68
+ - Posture Score: <Score>/100 (100 = Perfect, 0 = Extremely Vulnerable)
68
69
  - Clusters: <Count> identified | Memory Patterns Applied: <Count>
70
+
71
+ > [!IMPORTANT]
72
+ > If the posture score is low (e.g. 10/100) and vulnerabilities exist, it is your responsibility as the AI Agent to proactively recommend and manually execute the patches if the automated CLI falls short.
73
+
69
74
  Next: Run `/torusguard harden` to formulate surgical fixes.
70
75
  ```
@@ -24,8 +24,9 @@ Define and validate legal runtime authorization boundaries, verify target owners
24
24
  ```bash
25
25
  python .torusguard/scripts/safety_gate.py check --url <target_url>
26
26
  ```
27
- 5. **Write Scope Record:** Persist authorized targets, rate limits, and expiration timestamp into `.torusguard/config/scope.json`.
28
- 6. **Validate Schema:** Confirm `scope.json` adheres to `auth-boundary.schema.json`.
27
+ 5. **Handle CLI Failures:** If `safety_gate.py` fails or is unavailable, YOU must manually verify the safety invariants and generate the JSON structure below.
28
+ 6. **Write Scope Record:** Persist authorized targets, rate limits, and expiration timestamp into `.torusguard/config/scope.json`.
29
+ 7. **Validate Schema:** Confirm `scope.json` adheres to `auth-boundary.schema.json`.
29
30
 
30
31
  ---
31
32
 
@@ -38,7 +39,7 @@ Define and validate legal runtime authorization boundaries, verify target owners
38
39
 
39
40
  ## Output Format
40
41
  ```markdown
41
- ๐Ÿ”’ [TorusGuard] Target Scope Authorized
42
+ ๐Ÿ”’ [TorusGuard] Target Scope Authorized (AI Assisted)
42
43
  - Target Host: <Host URL> | Environment: <Local / Staging>
43
44
  - Allowed Paths: <Prefixes> | Rate Limit: <Max Req/sec>
44
45
  - Expiration TTL: <Timestamp>
@@ -36,14 +36,15 @@ Before dispatching any exploitability probe:
36
36
 
37
37
  1. **Verify Scope:** Read `scope.json`; assert authorized endpoint.
38
38
  2. **Select Canary:** Choose matching non-destructive probe strategy.
39
- 3. **Dispatch Probe:** Send request with header `X-TorusGuard-AuthID`.
40
- 4. **Classify Status:** Transition finding into one of 5 canonical outcomes:
39
+ 3. **Handle Automation Failure:** If automated exploit check scripts fail, YOU must manually construct the safe HTTP request (using `curl` or `fetch`) and inspect the response.
40
+ 4. **Dispatch Probe:** Send request with header `X-TorusGuard-AuthID`.
41
+ 5. **Classify Status:** Transition finding into one of 5 canonical outcomes:
41
42
  - `Confirmed`: Canary reflected or secondary tenant data leaked.
42
43
  - `Not Reproducible`: Endpoint responded with 401/403 or sanitized input.
43
44
  - `Needs Review`: Ambiguous status code or incomplete response.
44
45
  - `Blocked by Controls`: WAF or rate limiter stopped probe.
45
46
  - `Out of Scope`: Target endpoint is not authorized.
46
- 5. **Record Evidence:** Save trace in `.torusguard/runs/<run_id>/exploit-evidence.md`.
47
+ 6. **Record Evidence:** Save trace in `.torusguard/runs/<run_id>/exploit-evidence.md`.
47
48
 
48
49
  ---
49
50
 
@@ -56,7 +57,7 @@ Before dispatching any exploitability probe:
56
57
 
57
58
  ## Output Format
58
59
  ```markdown
59
- ๐ŸŽฏ [TorusGuard] Exploitability Confirmation
60
+ ๐ŸŽฏ [TorusGuard] Exploitability Confirmation (AI Assisted)
60
61
  - Finding ID: <Finding ID> | Target: <Route>
61
62
  - Status: <Confirmed / Not Reproducible / Blocked>
62
63
  - Evidence: <Response snippet or status code>
@@ -36,17 +36,17 @@ Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$
36
36
 
37
37
  ## Execution Steps
38
38
 
39
- 1. **Select Finding:** Choose prioritized verified flaw from active run's `findings.md`.
40
- 2. **Read AST Context:** View target file surrounding lines (ยฑ15) using `view_file`.
41
- 3. **Formulate Minimal Fix:** Consult `.torusguard/memory/context.json` for verified idioms; parameterize SQL, add tenant filters.
42
- 4. **Validate Line Churn:** Assert additions $\le 35$ and deletions $\le 25$ via `diff_guard.py`.
43
- 5. **Package Bundle:** Write 4 artifacts (`patch.diff`, `plan.md`, `verification.md`, `rollback.md`).
39
+ 1. **Evaluate Findings:** First, review the active run's `findings.md`. If the user has already run the CLI `npx torusguard harden` and it formulated `0` patches (or skipped complex findings), it is **YOUR RESPONSIBILITY** as the AI Agent to manually remediate the remaining findings.
40
+ 2. **Read AST Context:** View target file surrounding lines (ยฑ15) using `view_file` to deeply understand the vulnerability.
41
+ 3. **Formulate Minimal Fix:** Actively rewrite the code to fix the vulnerability (e.g. parameterize SQL, add tenant filters, use safe DOM APIs). Do NOT wait for the CLI to do it. You must generate the fix. Consult `.torusguard/memory/context.json` for verified idioms.
42
+ 4. **Validate Line Churn:** Assert additions $\le 35$ and deletions $\le 25$ via `diff_guard.py`. If it's too complex, partition into sequential sub-bundles.
43
+ 5. **Package Bundle Manually:** Write 4 artifacts (`patch.diff`, `plan.md`, `verification.md`, `rollback.md`) into `.torusguard/runs/<run_id>/remediation/<finding_id>/`.
44
44
  6. **Flag Sensitive Paths:** Mark changes touching auth or billing with `Requires Sensitive-Path Sign-Off`.
45
45
 
46
46
  ---
47
47
 
48
48
  ## Safety Constraints
49
- - Dry-run only; do NOT apply modifications to source code during harden.
49
+ - Dry-run only; do NOT apply modifications directly to source code during harden. Only write to the `patch.diff` artifact.
50
50
  - Keep surrounding formatting and comments intact.
51
51
  - Never touch files outside the targeted vulnerable sink.
52
52
 
@@ -54,10 +54,14 @@ Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$
54
54
 
55
55
  ## Output Format
56
56
  ```markdown
57
- ๐Ÿ› ๏ธ [TorusGuard] Remediation Bundle Packaged
57
+ ๐Ÿ› ๏ธ [TorusGuard] Remediation Bundle Packaged (AI Assisted)
58
58
  - Finding Target: <Finding ID> | File: <Path>
59
59
  - Line Churn: +<Additions> / -<Deletions> (Ponytail: PASS)
60
60
  - Sensitive Path: <Yes/No>
61
61
  - Bundle Path: `.torusguard/runs/<run_id>/remediation/<finding_id>/`
62
+
63
+ > [!NOTE]
64
+ > This patch was formulated manually by the TorusGuard AI Agent because it required architectural changes beyond the CLI's automated templates.
65
+
62
66
  Next: Run `/torusguard apply` to review diff and apply with rollback backup.
63
67
  ```
@@ -28,10 +28,11 @@ Auto-detect repository technology stack via indicators or `stack_detect.py`, act
28
28
  - Python: Django (`manage.py`), FastAPI (`fastapi`), Flask (`flask`), SQLAlchemy.
29
29
  - Node: Next.js (`"next"`), Express (`"express"`), React/Vite (`"vite"`).
30
30
  - BaaS: Supabase (`@supabase/supabase-js`), Firebase (`firebase-admin`).
31
- 2. **Emit Stack Record:** Log detected language, framework, ORM, and client SDKs.
32
- 3. **Activate Tailored Rules:** Copy matching `TG-*` rules from `.torusguard/rules/` into `.torusguard/rules/active/`.
33
- 4. **Provision Policy:** Create `SECURITY.md` if absent, configuring responsible disclosure contacts.
34
- 5. **Write Configuration:** Persist detected stack and active rules count to `.torusguard/config/torusguard.json`.
31
+ 2. **Handle CLI Failures:** If `stack_detect.py` crashes or is unable to determine the stack, YOU must manually analyze the directory structure and determine the stack.
32
+ 3. **Emit Stack Record:** Log detected language, framework, ORM, and client SDKs.
33
+ 4. **Activate Tailored Rules:** Copy matching `TG-*` rules from `.torusguard/rules/` into `.torusguard/rules/active/`.
34
+ 5. **Provision Policy:** Create `SECURITY.md` if absent, configuring responsible disclosure contacts.
35
+ 6. **Write Configuration:** Persist detected stack and active rules count to `.torusguard/config/torusguard.json`.
35
36
 
36
37
  ---
37
38
 
@@ -44,7 +45,7 @@ Auto-detect repository technology stack via indicators or `stack_detect.py`, act
44
45
 
45
46
  ## Output Format
46
47
  ```markdown
47
- ๐Ÿ›ก๏ธ [TorusGuard] Workspace Initialized
48
+ ๐Ÿ›ก๏ธ [TorusGuard] Workspace Initialized (AI Assisted)
48
49
  - Primary Stack: <Detected Stack> | Components: <Backend/Frontend/DB>
49
50
  - Active Rules: <Count> rules enabled in `.torusguard/rules/active/`
50
51
  - Configuration: `.torusguard/config/torusguard.json` written
@@ -19,11 +19,12 @@ Re-scan only files modified by remediation patches, confirming that targeted vul
19
19
  ## Execution Steps
20
20
 
21
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 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 & Memory:** Record status in `findings.json` and sync verified results to memory engine.
26
- 6. **Emit Recheck Report:** Save summary in `.torusguard/runs/<run_id>/recheck-report.md`.
22
+ 2. **Handle CLI Failures:** If `npx torusguard recheck` crashes or reports a false negative, YOU must act as the manual arbiter.
23
+ 3. **Execute Differential Scan:** Re-run active `TG-*` rules exclusively against modified files. If doing this manually, use `view_file` to read the patched file and cross-reference with the active rules.
24
+ 4. **Evaluate Finding Status:** Transition finding state according to transition rules below.
25
+ 5. **Assert Regression-Free:** Ensure no new security warnings triggered on altered lines.
26
+ 6. **Update State & Memory:** Record status in `findings.json` and sync verified results to memory engine.
27
+ 7. **Emit Recheck Report:** Save summary in `.torusguard/runs/<run_id>/recheck-report.md`.
27
28
 
28
29
  ---
29
30
 
@@ -37,14 +38,14 @@ Re-scan only files modified by remediation patches, confirming that targeted vul
37
38
 
38
39
  ## Safety Constraints
39
40
  - Restrict AST scan strictly to modified files and direct callers.
40
- - If regression is detected, halt and recommend immediate rollback via `.bak` snapshot.
41
+ - If regression is detected, halt and recommend immediate rollback via `.bak` snapshot. If CLI rollback fails, you MUST manually revert the file using your write tools.
41
42
  - Read-only differential analysis.
42
43
 
43
44
  ---
44
45
 
45
46
  ## Output Format
46
47
  ```markdown
47
- โœ… [TorusGuard] Differential Recheck Completed
48
+ โœ… [TorusGuard] Differential Recheck Completed (AI Assisted)
48
49
  - Modified Files Scanned: <Count>
49
50
  - Target Finding: <Finding ID> โ”€โ”€โ–บ FIXED
50
51
  - Regressions Detected: 0
@@ -19,13 +19,14 @@ Aggregate findings, verification traces, and recheck results into a signed execu
19
19
  ## Execution Steps
20
20
 
21
21
  1. **Aggregate Run Data:** Read findings, verified evidence, and recheck records from active run.
22
- 2. **Export OASIS SARIF v2.1.0:**
22
+ 2. **Handle CLI Failures:** If `npx torusguard report --html` or SARIF export crashes, YOU must manually gather the metrics and format the report.
23
+ 3. **Export OASIS SARIF v2.1.0:**
23
24
  ```bash
24
25
  python .torusguard/scripts/sarif_exporter.py --run <run_dir> --output <run_dir>/results.sarif
25
26
  ```
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.
27
+ 4. **Compile Executive Markdown/HTML Report:** Generate `report.md` or `.html` with posture score, open/closed finding tables, and risk breakdown. Make sure the polyglot stack detected during audit is explicitly summarized.
28
+ 5. **Update Run Manifest:** Finalize `manifest.json` status counts.
29
+ 6. **Archive Release Artifacts:** Ensure `report.md` and `results.sarif` are serialized to disk.
29
30
 
30
31
  ---
31
32
 
@@ -46,7 +47,7 @@ Aggregate findings, verification traces, and recheck results into a signed execu
46
47
 
47
48
  ## Output Format
48
49
  ```markdown
49
- ๐Ÿ“Š [TorusGuard] Security Posture Report Emitted
50
+ ๐Ÿ“Š [TorusGuard] Security Posture Report Emitted (AI Assisted)
50
51
  - Run ID: <Run ID> | Posture Score: <Score>/100
51
52
  - Findings: <Total> (<Fixed> Fixed ยท <Open> Open)
52
53
  - SARIF Export: `.torusguard/runs/<run_id>/results.sarif`
@@ -18,22 +18,23 @@ Provide an instant diagnostic summary of the repository's security state, active
18
18
  ## Execution Steps
19
19
 
20
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.
21
+ 2. **Handle CLI Failures:** If `npx torusguard status` throws an error, YOU must manually parse the local files (e.g. `torusguard.json`, `scope.json`) to deduce the status instead of just returning the CLI error.
22
+ 3. **Enumerate Active Rules:** Count rule files physically present in `.torusguard/rules/active/`.
23
+ 4. **Inspect Run History:** List historical run folders in `.torusguard/runs/` via `run_manager.py`.
24
+ 5. **Check Authorization Scope:** Check `.torusguard/config/scope.json` for active targets and TTL expiration.
25
+ 6. **Render Diagnostic Overview:** Output formatted status card.
25
26
 
26
27
  ---
27
28
 
28
29
  ## Safety Constraints
29
30
  - Read-only execution; zero file modifications.
30
- - Handle uninitialized workspaces gracefully with advice to run `/torusguard init`.
31
+ - Handle uninitialized workspaces gracefully with advice to run `/torusguard init` (or manual AI initialization).
31
32
 
32
33
  ---
33
34
 
34
35
  ## Output Format
35
36
  ```markdown
36
- ๐Ÿ›ก๏ธ [TorusGuard] Workspace Status Overview
37
+ ๐Ÿ›ก๏ธ [TorusGuard] Workspace Status Overview (AI Assisted)
37
38
  - Version: v0.9.2 | Stack: <Detected Framework>
38
39
  - Active Rules: <Count> rules active in `.torusguard/rules/active/`
39
40
  - Historical Runs: <Count> runs recorded
@@ -18,14 +18,15 @@ Audit the evidence sufficiency of candidate findings by reading current disk lin
18
18
  ## Execution Steps
19
19
 
20
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:**
21
+ 2. **Handle CLI Failures:** If `python .torusguard/scripts/finding_scorer.py` or the verify workflow fails, YOU must manually read the code and calibrate the score based on the evidence parameters.
22
+ 3. **Live Disk Line Match:** Inspect exact cited lines using `view_file` to confirm code presence.
23
+ 4. **Audit Evidence Sufficiency:** Verify source-to-sink flow against criteria below.
24
+ 5. **Calibrate Confidence Score:**
24
25
  ```bash
25
26
  python .torusguard/scripts/finding_scorer.py --run <run_dir> --verify
26
27
  ```
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`.
28
+ 6. **Update State:** Mark finding as `Confirmed`, `Needs Review`, or `False Positive`.
29
+ 7. **Emit Verified Evidence:** Save report in `.torusguard/runs/<run_id>/verified-evidence.md`.
29
30
 
30
31
  ---
31
32
 
@@ -47,7 +48,7 @@ A finding is verified as sufficient when:
47
48
 
48
49
  ## Output Format
49
50
  ```markdown
50
- ๐Ÿงช [TorusGuard] Finding Verification Complete
51
+ ๐Ÿงช [TorusGuard] Finding Verification Complete (AI Assisted)
51
52
  - Findings Audited: <Count> | Confirmed Real: <Count>
52
53
  - False Positives Filtered: <Count> | Refined Mean Score: <Score>/100
53
54
  - Artifact: `.torusguard/runs/<run_id>/verified-evidence.md`
@@ -34,11 +34,12 @@ All requests pass through `.torusguard/scripts/safety_gate.py`:
34
34
  ## Execution Steps
35
35
 
36
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`.
37
+ 2. **Handle Automation Failure:** If automated web validation scripts fail, YOU must manually construct the HTTP requests (using `curl` or `fetch`) and inspect the responses.
38
+ 3. **Inject Audit Header:** Attach `X-TorusGuard-AuthID: <auth_id>` to all outbound requests.
39
+ 4. **Dispatch Bounded Probe:** Send single non-destructive HTTP request.
40
+ 5. **Validate Security Headers:** Check for CSP, HSTS, X-Content-Type-Options, and CORS configurations.
41
+ 6. **Audit Cookie Flags:** Verify `HttpOnly`, `Secure`, and `SameSite` on session cookies.
42
+ 7. **Capture Replay Trace:** Save sanitized trace in `.torusguard/runs/<run_id>/requests.json`.
42
43
 
43
44
  ---
44
45
 
@@ -56,7 +57,7 @@ All Bearer tokens, cookies, passwords, and API keys are redacted prior to disk s
56
57
 
57
58
  ## Output Format
58
59
  ```markdown
59
- ๐ŸŒ [TorusGuard] Web Validation Completed
60
+ ๐ŸŒ [TorusGuard] Web Validation Completed (AI Assisted)
60
61
  - Target: <Host URL> | Endpoints Tested: <Count>
61
62
  - Header Posture: <CSP/HSTS Status> | Cookies: <Flags Status>
62
63
  - Replay Trace: `.torusguard/runs/<run_id>/requests.json`