torusguard 0.9.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.torusguard/.manifest.json +98 -79
- package/.torusguard/config/torusguard.json +1 -1
- package/.torusguard/references/csharp-security.md +41 -0
- package/.torusguard/references/go-security.md +41 -0
- package/.torusguard/references/java-security.md +40 -0
- package/.torusguard/references/polyglot-security-matrix.md +25 -0
- package/.torusguard/references/rust-security.md +40 -0
- package/.torusguard/rules/custom/.gitkeep +1 -0
- package/.torusguard/rules/custom/README.md +30 -0
- package/.torusguard/runs/report-latest.html +328 -0
- package/.torusguard/schemas/golden-recipe.schema.json +75 -0
- package/.torusguard/schemas/memory-context.schema.json +95 -0
- package/.torusguard/schemas/memory-event.schema.json +70 -0
- package/.torusguard/schemas/memory-pattern.schema.json +65 -0
- package/.torusguard/scripts/diff_guard.py +202 -15
- package/.torusguard/scripts/finding_scorer.py +199 -86
- package/.torusguard/scripts/html_reporter.py +628 -0
- package/.torusguard/scripts/manifest_builder.py +7 -5
- package/.torusguard/scripts/memory_engine.py +1334 -0
- package/.torusguard/scripts/monorepo_detector.py +123 -10
- package/.torusguard/scripts/rules_sync.py +321 -0
- package/.torusguard/scripts/run_manager.py +171 -89
- package/.torusguard/scripts/stack_detect.py +458 -26
- package/.torusguard/skills/torusguard/SKILL.md +4 -3
- package/.torusguard/skills/torusguard/bootstrap.py +344 -56
- package/.torusguard/skills/torusguard/references/csharp-security.md +41 -0
- package/.torusguard/skills/torusguard/references/go-security.md +41 -0
- package/.torusguard/skills/torusguard/references/java-security.md +40 -0
- package/.torusguard/skills/torusguard/references/polyglot-security-matrix.md +25 -0
- package/.torusguard/skills/torusguard/references/rust-security.md +40 -0
- package/.torusguard/skills/torusguard-audit/SKILL.md +25 -25
- package/.torusguard/skills/torusguard-harden/SKILL.md +3 -3
- package/.torusguard/skills/torusguard-recheck/SKILL.md +3 -3
- package/.torusguard/workflows/memory.md +53 -0
- package/README.md +307 -401
- package/bin/torusguard.js +204 -6
- package/package.json +1 -1
- package/skills/torusguard/SKILL.md +4 -3
- package/skills/torusguard/bootstrap.py +68 -4
- package/skills/torusguard/payload/.manifest.json +98 -79
- package/skills/torusguard/payload/config/torusguard.json +1 -1
- package/skills/torusguard/payload/references/csharp-security.md +41 -0
- package/skills/torusguard/payload/references/go-security.md +41 -0
- package/skills/torusguard/payload/references/java-security.md +40 -0
- package/skills/torusguard/payload/references/polyglot-security-matrix.md +25 -0
- package/skills/torusguard/payload/references/rust-security.md +40 -0
- package/skills/torusguard/payload/rules/custom/.gitkeep +1 -0
- package/skills/torusguard/payload/rules/custom/README.md +30 -0
- package/skills/torusguard/payload/schemas/golden-recipe.schema.json +75 -0
- package/skills/torusguard/payload/schemas/memory-context.schema.json +95 -0
- package/skills/torusguard/payload/schemas/memory-event.schema.json +70 -0
- package/skills/torusguard/payload/schemas/memory-pattern.schema.json +65 -0
- package/skills/torusguard/payload/scripts/diff_guard.py +202 -15
- package/skills/torusguard/payload/scripts/finding_scorer.py +199 -86
- package/skills/torusguard/payload/scripts/html_reporter.py +628 -0
- package/skills/torusguard/payload/scripts/manifest_builder.py +7 -5
- package/skills/torusguard/payload/scripts/memory_engine.py +1334 -0
- package/skills/torusguard/payload/scripts/monorepo_detector.py +123 -10
- package/skills/torusguard/payload/scripts/rules_sync.py +321 -0
- package/skills/torusguard/payload/scripts/run_manager.py +171 -89
- package/skills/torusguard/payload/scripts/stack_detect.py +458 -26
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +4 -3
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +344 -56
- package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -0
- package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -0
- package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -0
- package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -0
- package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -0
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +25 -25
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +3 -3
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +3 -3
- package/skills/torusguard/payload/workflows/memory.md +53 -0
- package/skills/torusguard-audit/SKILL.md +25 -25
- package/skills/torusguard-harden/SKILL.md +3 -3
- package/skills/torusguard-recheck/SKILL.md +3 -3
- package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
- package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Rust Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** A project is identified as a Rust application (`Cargo.toml` or `.rs` files detected).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Memory Safety & Unsafe Blocks
|
|
10
|
+
* `TG-INPUT-003`: Audit and restrict `unsafe { ... }` blocks. Must include a `// SAFETY:` rationale comment.
|
|
11
|
+
* Never disable standard borrow checker lints via `#![allow(unsafe_code)]`.
|
|
12
|
+
|
|
13
|
+
### 2. Database & SQL Queries
|
|
14
|
+
* `TG-INPUT-002`: Use compile-time checked `sqlx::query!` or Diesel query builder methods.
|
|
15
|
+
* `TG-DB-004`: Enforce tenant filtering in queries (`filter(tenant_id.eq(current_tenant_id))`).
|
|
16
|
+
|
|
17
|
+
### 3. Outbound Requests & TLS
|
|
18
|
+
* `TG-DIFF-001`: Prohibit `danger_accept_invalid_certs(true)` in `reqwest::ClientBuilder`.
|
|
19
|
+
* `TG-SSRF-001`: Enforce IP allowlists before dispatching network calls.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🛠️ Safe Patterns Summary
|
|
24
|
+
|
|
25
|
+
```rust
|
|
26
|
+
// Safe sqlx Parameterized Query
|
|
27
|
+
let user = sqlx::query_as!(
|
|
28
|
+
User,
|
|
29
|
+
"SELECT id, email FROM users WHERE id = $1 AND tenant_id = $2",
|
|
30
|
+
user_id,
|
|
31
|
+
current_tenant_id
|
|
32
|
+
)
|
|
33
|
+
.fetch_one(&pool)
|
|
34
|
+
.await?;
|
|
35
|
+
|
|
36
|
+
// Safe reqwest Client (Strict TLS)
|
|
37
|
+
let client = reqwest::Client::builder()
|
|
38
|
+
.timeout(std::time::Duration::from_secs(10))
|
|
39
|
+
.build()?;
|
|
40
|
+
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-audit
|
|
3
|
-
description: Static
|
|
4
|
-
version: 0.
|
|
3
|
+
description: Static AST scanning, memory pattern boosting, and 0–100 confidence scoring.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
workflow: .torusguard/workflows/audit.md
|
|
6
6
|
tools: Read, Grep, Glob, Write
|
|
7
7
|
scripts-binding:
|
|
@@ -9,36 +9,37 @@ scripts-binding:
|
|
|
9
9
|
- .torusguard/scripts/run_manager.py
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
# TorusGuard Audit — Static Code Analysis &
|
|
12
|
+
# TorusGuard Audit — Static Code Analysis & Memory Scanning
|
|
13
13
|
|
|
14
14
|
## Objective
|
|
15
|
-
Execute static analysis
|
|
15
|
+
Execute static AST analysis, query memory context, compute 0–100 confidence scores with memory boosts, and record findings to runs and memory.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
## Execution Steps
|
|
20
20
|
|
|
21
|
-
1. **
|
|
22
|
-
2. **
|
|
21
|
+
1. **Run Setup:** Initialize `.torusguard/runs/run-YYYYMMDD-HHMMSS-audit/` via `run_manager.py`.
|
|
22
|
+
2. **Context & Rules:** Load `.torusguard/memory/context.json` for patterns and false positives. Load rules from `.torusguard/rules/active/`.
|
|
23
23
|
3. **AST Scan Sinks:** Match files against active rules:
|
|
24
|
-
- `TG-SEC-*`:
|
|
25
|
-
- `TG-INPUT-*`:
|
|
26
|
-
- `TG-DB-*`: Unscoped
|
|
27
|
-
- `TG-AUTH-*`:
|
|
28
|
-
- `TG-CLIENT-*`:
|
|
29
|
-
4. **Stable Fingerprinting:** Compute SHA-256 hash of
|
|
30
|
-
5. **Root-Cause Clustering:** Group findings by
|
|
31
|
-
6. **
|
|
32
|
-
7. **Write
|
|
24
|
+
- `TG-SEC-*`: Secrets and API keys.
|
|
25
|
+
- `TG-INPUT-*`: SQL injection, unvalidated input.
|
|
26
|
+
- `TG-DB-*`: Unscoped tenant queries (`Model.get(id=id)`).
|
|
27
|
+
- `TG-AUTH-*`: Insecure cookies, open CORS.
|
|
28
|
+
- `TG-CLIENT-*`: Client bundle secret leaks.
|
|
29
|
+
4. **Stable Fingerprinting:** Compute SHA-256 hash of surrounding AST context.
|
|
30
|
+
5. **Root-Cause Clustering:** Group findings by causal sink (`cluster-tenant-isolation`).
|
|
31
|
+
6. **Scoring:** Calculate 0–100 score via `finding_scorer.py` (applies memory boost/suppression).
|
|
32
|
+
7. **Write Artifacts:** Save `findings.json` and sync findings to memory engine.
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
36
|
## Confidence Scoring Rubric
|
|
37
|
-
- **1. Evidence (35):** AST flow (35), regex
|
|
38
|
-
- **2. Reproduction (25):**
|
|
37
|
+
- **1. Evidence (35):** AST flow (35), regex sink (20), heuristic (10).
|
|
38
|
+
- **2. Reproduction (25):** Automated test (25), simulated (15), hypothesis (0).
|
|
39
39
|
- **3. Corroboration (15):** >=3 files (15), 2 files (10), single (5).
|
|
40
|
-
- **4. Environment (15):** Explicit route (15),
|
|
41
|
-
- **5. Review Status (10):** Human
|
|
40
|
+
- **4. Environment (15):** Explicit route (15), ambiguous (8), unknown (0).
|
|
41
|
+
- **5. Review Status (10):** Human confirmed (10), agent verified (5), auto (0).
|
|
42
|
+
- **Memory Modifier:** False positive (-30), regression (+15), recurring (+10).
|
|
42
43
|
- **Bands:** 90–100 (`Confirmed`), 70–89 (`High`), 50–69 (`Medium`), <50 (`Review`).
|
|
43
44
|
|
|
44
45
|
---
|
|
@@ -46,17 +47,16 @@ Execute static analysis across ASTs, generate line-shift invariant fingerprints,
|
|
|
46
47
|
## Finding Card Format
|
|
47
48
|
```markdown
|
|
48
49
|
### [TG-DB-004] Missing Tenant Scoping in /invoices/
|
|
49
|
-
- **Severity**: High | **Confidence**: 90/100 (Confirmed)
|
|
50
|
+
- **Severity**: High | **Confidence**: 90/100 (Confirmed) | **Memory Boost**: +10
|
|
50
51
|
- **File**: `views.py:42` | **Cluster**: `cluster-tenant-isolation`
|
|
51
|
-
- **
|
|
52
|
-
- **Remediation**: Scope by `tenant=request.user.tenant`.
|
|
52
|
+
- **Remediation**: Apply `.filter(tenant=request.user.tenant)`.
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
57
|
## Safety Constraints
|
|
58
|
-
- Read-only
|
|
59
|
-
- Exclude build
|
|
58
|
+
- Read-only analysis; zero code modifications during audit.
|
|
59
|
+
- Exclude build directories (`node_modules/`, `.venv/`, `dist/`).
|
|
60
60
|
- Redact secrets before saving to `findings.md`.
|
|
61
61
|
|
|
62
62
|
---
|
|
@@ -65,6 +65,6 @@ Execute static analysis across ASTs, generate line-shift invariant fingerprints,
|
|
|
65
65
|
```markdown
|
|
66
66
|
🛡️ [TorusGuard] Static Code Audit Completed
|
|
67
67
|
- Run ID: run-YYYYMMDD-HHMMSS-audit | Files: <Count> | Findings: <Count>
|
|
68
|
-
- Clusters: <Count> identified |
|
|
68
|
+
- Clusters: <Count> identified | Memory Patterns Applied: <Count>
|
|
69
69
|
Next: Run `/torusguard harden` to formulate surgical fixes.
|
|
70
70
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-harden
|
|
3
3
|
description: Package surgical remediation bundles conforming to the Ponytail Protocol (<= 35 additions, <= 25 deletions).
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
workflow: .torusguard/workflows/harden.md
|
|
6
6
|
tools: Read, Grep, Glob, Write
|
|
7
7
|
scripts-binding:
|
|
@@ -38,8 +38,8 @@ Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$
|
|
|
38
38
|
|
|
39
39
|
1. **Select Finding:** Choose prioritized verified flaw from active run's `findings.md`.
|
|
40
40
|
2. **Read AST Context:** View target file surrounding lines (±15) using `view_file`.
|
|
41
|
-
3. **Formulate Minimal Fix:**
|
|
42
|
-
4. **Validate Line Churn:** Assert additions $\le 35$ and deletions $\le 25
|
|
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
43
|
5. **Package Bundle:** Write 4 artifacts (`patch.diff`, `plan.md`, `verification.md`, `rollback.md`).
|
|
44
44
|
6. **Flag Sensitive Paths:** Mark changes touching auth or billing with `Requires Sensitive-Path Sign-Off`.
|
|
45
45
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-recheck
|
|
3
3
|
description: Execute targeted differential AST re-scan against modified files, verify fix closure, and assert zero regressions.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
workflow: .torusguard/workflows/recheck.md
|
|
6
6
|
tools: Read, Grep, Glob, Write
|
|
7
7
|
scripts-binding:
|
|
@@ -19,10 +19,10 @@ 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
|
|
22
|
+
2. **Execute Differential Scan:** Re-run active `TG-*` rules exclusively against modified files.
|
|
23
23
|
3. **Evaluate Finding Status:** Transition finding state according to transition rules below.
|
|
24
24
|
4. **Assert Regression-Free:** Ensure no new security warnings triggered on altered lines.
|
|
25
|
-
5. **Update State:** Record
|
|
25
|
+
5. **Update State & Memory:** Record status in `findings.json` and sync verified results to memory engine.
|
|
26
26
|
6. **Emit Recheck Report:** Save summary in `.torusguard/runs/<run_id>/recheck-report.md`.
|
|
27
27
|
|
|
28
28
|
---
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: TorusGuard Adaptive Security Memory Engine — view memory stats, export/import intelligence, apply TTL decay, and manage false positives.
|
|
3
|
+
tools: Read, Grep, Glob, Bash
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
agent: reviewer
|
|
6
|
+
lifecycle-phase: Intelligence / Memory
|
|
7
|
+
required-skills:
|
|
8
|
+
- torusguard
|
|
9
|
+
scripts-binding:
|
|
10
|
+
- .torusguard/scripts/memory_engine.py
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# /torusguard memory — Adaptive Security Memory Engine & Intelligence Management
|
|
14
|
+
|
|
15
|
+
$ARGUMENTS
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Objective
|
|
20
|
+
Inspect, manage, export, import, or compact persistent local security memory patterns, context window cards, and false positive suppressions.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Subcommands & Usage
|
|
25
|
+
|
|
26
|
+
| Command | Action | Description |
|
|
27
|
+
| :--- | :--- | :--- |
|
|
28
|
+
| `npx torusguard memory` | Status | Display memory stats, pattern count, and context token estimate |
|
|
29
|
+
| `npx torusguard memory context` | Context Dump | Output the active pre-computed context window cards |
|
|
30
|
+
| `npx torusguard memory fp --rule <RULE_ID>` | False Positive | Suppress rule as false positive across future scans |
|
|
31
|
+
| `npx torusguard memory decay [--ttl 90]` | TTL Decay | Apply confidence decay to stale, unconfirmed patterns |
|
|
32
|
+
| `npx torusguard memory export --path <FILE>` | Export | Export memory bundle for team sharing |
|
|
33
|
+
| `npx torusguard memory import --path <FILE>` | Import | Merge external memory bundle into local project intelligence |
|
|
34
|
+
| `npx torusguard memory compact` | Compaction | Archive raw events older than 30 days into single archive |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Execution Steps
|
|
39
|
+
|
|
40
|
+
1. **Verify Memory Subsystem:** Confirm `.torusguard/memory/` exists and is shielded by `.gitignore`.
|
|
41
|
+
2. **Execute Requested Action:** Invoke `.torusguard/scripts/memory_engine.py` with appropriate action flag:
|
|
42
|
+
```bash
|
|
43
|
+
python .torusguard/scripts/memory_engine.py --action status
|
|
44
|
+
```
|
|
45
|
+
3. **Verify Context Token Budget:** Confirm `context.json` remains within token budget ($\le 2,000$ tokens).
|
|
46
|
+
4. **Display Intelligence Card:** Render summary card to user.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Privacy & Security Invariants
|
|
51
|
+
- Memory files remain strictly local under `.torusguard/memory/` and are always gitignored.
|
|
52
|
+
- Memory files are never packaged into npm release tarballs.
|
|
53
|
+
- Export operations only occur when explicitly invoked by user command.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-audit
|
|
3
|
-
description: Static
|
|
4
|
-
version: 0.
|
|
3
|
+
description: Static AST scanning, memory pattern boosting, and 0–100 confidence scoring.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
workflow: .torusguard/workflows/audit.md
|
|
6
6
|
tools: Read, Grep, Glob, Write
|
|
7
7
|
scripts-binding:
|
|
@@ -9,36 +9,37 @@ scripts-binding:
|
|
|
9
9
|
- .torusguard/scripts/run_manager.py
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
# TorusGuard Audit — Static Code Analysis &
|
|
12
|
+
# TorusGuard Audit — Static Code Analysis & Memory Scanning
|
|
13
13
|
|
|
14
14
|
## Objective
|
|
15
|
-
Execute static analysis
|
|
15
|
+
Execute static AST analysis, query memory context, compute 0–100 confidence scores with memory boosts, and record findings to runs and memory.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
## Execution Steps
|
|
20
20
|
|
|
21
|
-
1. **
|
|
22
|
-
2. **
|
|
21
|
+
1. **Run Setup:** Initialize `.torusguard/runs/run-YYYYMMDD-HHMMSS-audit/` via `run_manager.py`.
|
|
22
|
+
2. **Context & Rules:** Load `.torusguard/memory/context.json` for patterns and false positives. Load rules from `.torusguard/rules/active/`.
|
|
23
23
|
3. **AST Scan Sinks:** Match files against active rules:
|
|
24
|
-
- `TG-SEC-*`:
|
|
25
|
-
- `TG-INPUT-*`:
|
|
26
|
-
- `TG-DB-*`: Unscoped
|
|
27
|
-
- `TG-AUTH-*`:
|
|
28
|
-
- `TG-CLIENT-*`:
|
|
29
|
-
4. **Stable Fingerprinting:** Compute SHA-256 hash of
|
|
30
|
-
5. **Root-Cause Clustering:** Group findings by
|
|
31
|
-
6. **
|
|
32
|
-
7. **Write
|
|
24
|
+
- `TG-SEC-*`: Secrets and API keys.
|
|
25
|
+
- `TG-INPUT-*`: SQL injection, unvalidated input.
|
|
26
|
+
- `TG-DB-*`: Unscoped tenant queries (`Model.get(id=id)`).
|
|
27
|
+
- `TG-AUTH-*`: Insecure cookies, open CORS.
|
|
28
|
+
- `TG-CLIENT-*`: Client bundle secret leaks.
|
|
29
|
+
4. **Stable Fingerprinting:** Compute SHA-256 hash of surrounding AST context.
|
|
30
|
+
5. **Root-Cause Clustering:** Group findings by causal sink (`cluster-tenant-isolation`).
|
|
31
|
+
6. **Scoring:** Calculate 0–100 score via `finding_scorer.py` (applies memory boost/suppression).
|
|
32
|
+
7. **Write Artifacts:** Save `findings.json` and sync findings to memory engine.
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
36
|
## Confidence Scoring Rubric
|
|
37
|
-
- **1. Evidence (35):** AST flow (35), regex
|
|
38
|
-
- **2. Reproduction (25):**
|
|
37
|
+
- **1. Evidence (35):** AST flow (35), regex sink (20), heuristic (10).
|
|
38
|
+
- **2. Reproduction (25):** Automated test (25), simulated (15), hypothesis (0).
|
|
39
39
|
- **3. Corroboration (15):** >=3 files (15), 2 files (10), single (5).
|
|
40
|
-
- **4. Environment (15):** Explicit route (15),
|
|
41
|
-
- **5. Review Status (10):** Human
|
|
40
|
+
- **4. Environment (15):** Explicit route (15), ambiguous (8), unknown (0).
|
|
41
|
+
- **5. Review Status (10):** Human confirmed (10), agent verified (5), auto (0).
|
|
42
|
+
- **Memory Modifier:** False positive (-30), regression (+15), recurring (+10).
|
|
42
43
|
- **Bands:** 90–100 (`Confirmed`), 70–89 (`High`), 50–69 (`Medium`), <50 (`Review`).
|
|
43
44
|
|
|
44
45
|
---
|
|
@@ -46,17 +47,16 @@ Execute static analysis across ASTs, generate line-shift invariant fingerprints,
|
|
|
46
47
|
## Finding Card Format
|
|
47
48
|
```markdown
|
|
48
49
|
### [TG-DB-004] Missing Tenant Scoping in /invoices/
|
|
49
|
-
- **Severity**: High | **Confidence**: 90/100 (Confirmed)
|
|
50
|
+
- **Severity**: High | **Confidence**: 90/100 (Confirmed) | **Memory Boost**: +10
|
|
50
51
|
- **File**: `views.py:42` | **Cluster**: `cluster-tenant-isolation`
|
|
51
|
-
- **
|
|
52
|
-
- **Remediation**: Scope by `tenant=request.user.tenant`.
|
|
52
|
+
- **Remediation**: Apply `.filter(tenant=request.user.tenant)`.
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
57
|
## Safety Constraints
|
|
58
|
-
- Read-only
|
|
59
|
-
- Exclude build
|
|
58
|
+
- Read-only analysis; zero code modifications during audit.
|
|
59
|
+
- Exclude build directories (`node_modules/`, `.venv/`, `dist/`).
|
|
60
60
|
- Redact secrets before saving to `findings.md`.
|
|
61
61
|
|
|
62
62
|
---
|
|
@@ -65,6 +65,6 @@ Execute static analysis across ASTs, generate line-shift invariant fingerprints,
|
|
|
65
65
|
```markdown
|
|
66
66
|
🛡️ [TorusGuard] Static Code Audit Completed
|
|
67
67
|
- Run ID: run-YYYYMMDD-HHMMSS-audit | Files: <Count> | Findings: <Count>
|
|
68
|
-
- Clusters: <Count> identified |
|
|
68
|
+
- Clusters: <Count> identified | Memory Patterns Applied: <Count>
|
|
69
69
|
Next: Run `/torusguard harden` to formulate surgical fixes.
|
|
70
70
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-harden
|
|
3
3
|
description: Package surgical remediation bundles conforming to the Ponytail Protocol (<= 35 additions, <= 25 deletions).
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
workflow: .torusguard/workflows/harden.md
|
|
6
6
|
tools: Read, Grep, Glob, Write
|
|
7
7
|
scripts-binding:
|
|
@@ -38,8 +38,8 @@ Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$
|
|
|
38
38
|
|
|
39
39
|
1. **Select Finding:** Choose prioritized verified flaw from active run's `findings.md`.
|
|
40
40
|
2. **Read AST Context:** View target file surrounding lines (±15) using `view_file`.
|
|
41
|
-
3. **Formulate Minimal Fix:**
|
|
42
|
-
4. **Validate Line Churn:** Assert additions $\le 35$ and deletions $\le 25
|
|
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
43
|
5. **Package Bundle:** Write 4 artifacts (`patch.diff`, `plan.md`, `verification.md`, `rollback.md`).
|
|
44
44
|
6. **Flag Sensitive Paths:** Mark changes touching auth or billing with `Requires Sensitive-Path Sign-Off`.
|
|
45
45
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-recheck
|
|
3
3
|
description: Execute targeted differential AST re-scan against modified files, verify fix closure, and assert zero regressions.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
workflow: .torusguard/workflows/recheck.md
|
|
6
6
|
tools: Read, Grep, Glob, Write
|
|
7
7
|
scripts-binding:
|
|
@@ -19,10 +19,10 @@ 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
|
|
22
|
+
2. **Execute Differential Scan:** Re-run active `TG-*` rules exclusively against modified files.
|
|
23
23
|
3. **Evaluate Finding Status:** Transition finding state according to transition rules below.
|
|
24
24
|
4. **Assert Regression-Free:** Ensure no new security warnings triggered on altered lines.
|
|
25
|
-
5. **Update State:** Record
|
|
25
|
+
5. **Update State & Memory:** Record status in `findings.json` and sync verified results to memory engine.
|
|
26
26
|
6. **Emit Recheck Report:** Save summary in `.torusguard/runs/<run_id>/recheck-report.md`.
|
|
27
27
|
|
|
28
28
|
---
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|