torusguard 2.1.1 → 2.1.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.
- package/.torusguard/.manifest.json +11 -3
- package/.torusguard/config/torusguard.json +1 -1
- package/.torusguard/custom_rules/README.md +24 -0
- package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
- package/.torusguard/scripts/deliberation_tournament.py +136 -0
- package/.torusguard/scripts/reachability_analyzer.py +165 -0
- package/.torusguard/scripts/status_runner.py +3 -3
- package/.torusguard/scripts/stride_generator.py +198 -0
- package/.torusguard/scripts/term_ui.py +1 -1
- package/.torusguard/skills/torusguard-review/SKILL.md +27 -0
- package/.torusguard/skills/torusguard-threatmodel/SKILL.md +27 -0
- package/.torusguard/workflows/review.md +11 -0
- package/.torusguard/workflows/threatmodel.md +9 -0
- package/README.md +194 -45
- package/bin/torusguard.js +26 -26
- package/package.json +5 -1
- package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/skills/torusguard/bootstrap.py +32 -65
- package/skills/torusguard/payload/.manifest.json +12 -4
- package/skills/torusguard/payload/config/torusguard.json +1 -1
- package/skills/torusguard/payload/custom_rules/README.md +15 -0
- package/skills/torusguard/payload/scripts/deliberation_tournament.py +127 -0
- package/skills/torusguard/payload/scripts/reachability_analyzer.py +164 -0
- package/skills/torusguard/payload/scripts/status_runner.py +3 -3
- package/skills/torusguard/payload/scripts/stride_generator.py +196 -0
- package/skills/torusguard/payload/scripts/term_ui.py +1 -1
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +32 -65
- package/skills/torusguard/payload/skills/torusguard-review/SKILL.md +27 -0
- package/skills/torusguard/payload/skills/torusguard-threatmodel/SKILL.md +27 -0
- package/skills/torusguard/payload/workflows/review.md +11 -0
- package/skills/torusguard/payload/workflows/threatmodel.md +9 -0
- package/skills/torusguard-review/SKILL.md +27 -0
- package/skills/torusguard-threatmodel/SKILL.md +27 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-review
|
|
3
|
+
description: Differential PR and Git diff incremental security review — detects newly introduced vulnerabilities between Git branches or commits with net security score deltas.
|
|
4
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
5
|
+
version: 2.1.2
|
|
6
|
+
last-updated: 2026-09-30
|
|
7
|
+
skills:
|
|
8
|
+
- torusguard
|
|
9
|
+
- torusguard-audit
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Review — Differential Incremental PR Review
|
|
13
|
+
|
|
14
|
+
TorusGuard Review performs rapid, surgical security review on Git changes (e.g. against `HEAD~1`, `main`, or PR target branch), analyzing only modified lines to prevent introducing security regressions.
|
|
15
|
+
|
|
16
|
+
## Invocation
|
|
17
|
+
|
|
18
|
+
- **Mode A (Terminal CLI):** `torusguard review [--diff <ref>]`
|
|
19
|
+
- **Mode B (AI Chat Slash Command):** `/torusguard review` or `/torusguard-review`
|
|
20
|
+
- **Mode C (Native MCP Tool):** `torusguard_review(target=".", diff_ref="HEAD~1")`
|
|
21
|
+
|
|
22
|
+
## Core Capabilities
|
|
23
|
+
|
|
24
|
+
1. **Sub-300ms Turnaround:** Only parses and checks modified/added lines in Git diffs.
|
|
25
|
+
2. **Net Security Score Delta:** Tracks introduced vs. resolved vulnerabilities (`+0 Introduced, -2 Resolved`).
|
|
26
|
+
3. **PR Gate Decision:** Blocks CI/CD pipelines if Critical or High severity flaws are introduced.
|
|
27
|
+
4. **Alibaba OpenCodeReview Parity:** Outputs ready-to-post pull request inline review comments.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-threatmodel
|
|
3
|
+
description: Synthesizes an architectural STRIDE threat model, interactive Mermaid Data Flow Diagram (DFD), and trust boundary register into SECURITY_THREAT_MODEL.md.
|
|
4
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
5
|
+
version: 2.1.2
|
|
6
|
+
last-updated: 2026-09-30
|
|
7
|
+
skills:
|
|
8
|
+
- torusguard
|
|
9
|
+
- torusguard-audit
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Threat Model — STRIDE & DFD Synthesizer
|
|
13
|
+
|
|
14
|
+
TorusGuard Threat Model automatically maps routes, trust boundaries, datastores, and egress sinks to construct an architectural Data Flow Diagram and formal STRIDE threat model.
|
|
15
|
+
|
|
16
|
+
## Invocation
|
|
17
|
+
|
|
18
|
+
- **Mode A (Terminal CLI):** `torusguard threatmodel`
|
|
19
|
+
- **Mode B (AI Chat Slash Command):** `/torusguard threatmodel` or `/torusguard-threatmodel`
|
|
20
|
+
- **Mode C (Native MCP Tool):** `torusguard_threatmodel(target=".")`
|
|
21
|
+
|
|
22
|
+
## Core Capabilities
|
|
23
|
+
|
|
24
|
+
1. **Automated DFD Generation:** Renders interactive Mermaid diagram showing Zones 1–4 (Clients, Gateways, Core Services, Datastores).
|
|
25
|
+
2. **STRIDE Risk Ledger:** Evaluates threats across Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, and Elevation of Privilege.
|
|
26
|
+
3. **Multi-Modal Vision Integration:** Discovers architectural diagrams and verifies that visual trust boundaries match code execution paths.
|
|
27
|
+
4. **Living Compliance Artifact:** Emits `SECURITY_THREAT_MODEL.md` at workspace root.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# TorusGuard Review Workflow (`/torusguard review`)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Executes differential incremental Git diff security review against a reference branch or commit (default: `HEAD~1`).
|
|
5
|
+
Inspects changed lines for new security regressions, evaluates net security score deltas, and outputs pull request review comments.
|
|
6
|
+
|
|
7
|
+
## Steps
|
|
8
|
+
1. Determine reference branch or commit (e.g. `HEAD~1` or `origin/main`).
|
|
9
|
+
2. Run differential scan via `torusguard review [--diff <ref>]` or native MCP tool `torusguard_review`.
|
|
10
|
+
3. Check PR Gate Decision (`PASSED` or `BLOCKED`).
|
|
11
|
+
4. If blocked, review newly introduced violations and formulate surgical Ponytail fixes via `/torusguard harden`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# TorusGuard Threat Model Workflow (`/torusguard threatmodel`)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Synthesizes architectural STRIDE threat models, interactive Mermaid Data Flow Diagrams (DFDs), and trust boundary registers directly into `SECURITY_THREAT_MODEL.md`.
|
|
5
|
+
|
|
6
|
+
## Steps
|
|
7
|
+
1. Execute `torusguard threatmodel` or native MCP tool `torusguard_threatmodel`.
|
|
8
|
+
2. Inspect `SECURITY_THREAT_MODEL.md` to verify identified entrypoints, data stores, and trust boundaries.
|
|
9
|
+
3. Align STRIDE risk controls against corresponding TorusGuard security invariants (`TG-AUTH`, `TG-DB`, `TG-RATE`, `TG-SSRF`).
|
package/README.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
|
|
14
|
-
<a href="https://github.com/githubmofo/TorusGuard/releases"><img src="https://img.shields.io/badge/version-v2.1.
|
|
15
|
-
<a href="https://www.npmjs.com/package/torusguard"><img src="https://img.shields.io/badge/npm-v2.1.
|
|
14
|
+
<a href="https://github.com/githubmofo/TorusGuard/releases"><img src="https://img.shields.io/badge/version-v2.1.3-orange.svg" alt="Version"></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/torusguard"><img src="https://img.shields.io/badge/npm-v2.1.3-CB3837?logo=npm&logoColor=white" alt="npm: v2.1.3"></a>
|
|
16
16
|
<img src="https://img.shields.io/badge/Privacy-Local_First-success" alt="Privacy: Local First">
|
|
17
17
|
<img src="https://img.shields.io/badge/Dependencies-Zero-brightgreen" alt="Dependencies: Zero">
|
|
18
18
|
<img src="https://img.shields.io/badge/SARIF-v2.1.0-6C3483" alt="SARIF">
|
|
@@ -118,52 +118,139 @@ TorusGuard uses a **tri-track architecture** where intelligence, deterministic e
|
|
|
118
118
|
|
|
119
119
|
```mermaid
|
|
120
120
|
flowchart TD
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
%% =========================================================================
|
|
122
|
+
%% STAGE 1: TRI-MODE INGRESS GATEWAY
|
|
123
|
+
%% =========================================================================
|
|
124
|
+
subgraph IngressGateway["1. Unified Tri-Mode Ingress Gateway"]
|
|
125
|
+
direction LR
|
|
126
|
+
CLI["<b>Mode A: Terminal CLI</b><br/><code>torusguard <cmd></code><br/>25 Deterministic Commands"]
|
|
127
|
+
Chat["<b>Mode B: AI Chat Commands</b><br/><code>/torusguard <cmd></code><br/>Cursor • Claude • Windsurf"]
|
|
128
|
+
MCP["<b>Mode C: Native MCP Server</b><br/><code>torusguard_*</code> (13 Tools • 2 Resources)<br/>Stdio JSON-RPC 2.0 Protocol"]
|
|
125
129
|
end
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
%% =========================================================================
|
|
132
|
+
%% STAGE 2: CORE DISPATCHER & RUNTIME KERNEL
|
|
133
|
+
%% =========================================================================
|
|
134
|
+
Kernel["<b>TorusGuard Core Dispatcher & Runtime Kernel</b><br/><code>cmd/torusguard</code> (Single Standalone Go Binary)<br/>Command Parsing • Flag Evaluation (<code>--yes</code>, <code>--html</code>, <code>--rules</code>) • Sandbox Isolation"]
|
|
128
135
|
|
|
129
|
-
|
|
136
|
+
CLI -->|"Terminal Exec"| Kernel
|
|
137
|
+
Chat -->|"Slash Bridge"| Kernel
|
|
138
|
+
MCP -->|"Agent Tool Call"| Kernel
|
|
139
|
+
|
|
140
|
+
%% =========================================================================
|
|
141
|
+
%% STAGE 3: DETECTION & MULTI-MODAL SUITE
|
|
142
|
+
%% =========================================================================
|
|
143
|
+
subgraph DetectionSuite["2. Polyglot Static AST & Multi-Modal Detection Suite"]
|
|
130
144
|
direction TB
|
|
131
|
-
subgraph
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
subgraph StaticGroup["Static Code & Dependency Analysis"]
|
|
146
|
+
direction LR
|
|
147
|
+
AST["<b>Polyglot AST & Taint Engine</b><br/>Tree-sitter • 88 Rules across 22 Families<br/>Go • TS/JS • Python • Java • C# • Rust"]
|
|
148
|
+
TGQL["<b>TG-QL Declarative AST DSL</b><br/>Custom YAML Pattern Queries<br/>Syntax Trees • Taint Sinks • Constraints"]
|
|
149
|
+
Reach["<b>Reachability & OpenVEX</b><br/>Callgraph Traversal • Reachable CVEs<br/>Zero Ineffective Dependency Alerts"]
|
|
150
|
+
end
|
|
151
|
+
subgraph DeepGroup["Forensics, RegEx & Vision OCR"]
|
|
152
|
+
direction LR
|
|
153
|
+
OCR["<b>Multi-Modal Vision OCR Engine</b><br/>Tesseract v5.4.0 • Leaked Secrets<br/>Architecture Diagrams • Screenshots"]
|
|
154
|
+
ReDoS["<b>Thompson NFA ReDoS Engine</b><br/>Polynomial & Exponential Exploder<br/>Catastrophic Backtracking Loops"]
|
|
155
|
+
GitMine["<b>Git History & Container Audit</b><br/>Commit Packfile Secret Mining<br/>Dockerfile Non-Root Enforcement"]
|
|
138
156
|
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
Kernel -->|"Scan Code & Dependencies"| StaticGroup
|
|
160
|
+
Kernel -->|"Analyze Visuals & Commits"| DeepGroup
|
|
161
|
+
|
|
162
|
+
%% =========================================================================
|
|
163
|
+
%% STAGE 4: CONSENSUS DELIBERATION & TRIAGE
|
|
164
|
+
%% =========================================================================
|
|
165
|
+
subgraph DeliberationTriage["3. Deliberation Tournament & Evidence Triage"]
|
|
166
|
+
direction TB
|
|
167
|
+
Tournament["<b>3-Perspective Deliberation Tournament</b><br/>Vulnerability Hunter vs. Devil's Advocate / Sanitizer Verifier vs. Ponytail Remediator<br/>Eliminates False Positives • Calibrated Confidence Scoring (0-100%)"]
|
|
168
|
+
PRGate{"<b>Differential PR Diff Gate</b><br/><code>torusguard review</code><br/>Incremental Git Diff Changes?"}
|
|
169
|
+
Tournament --> PRGate
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
StaticGroup -->|"Raw AST Findings"| Tournament
|
|
173
|
+
DeepGroup -->|"Extracted Secrets & Complexities"| Tournament
|
|
174
|
+
|
|
175
|
+
%% =========================================================================
|
|
176
|
+
%% STAGE 5: GOVERNED REMEDIATION & PONYTAIL LOOP
|
|
177
|
+
%% =========================================================================
|
|
178
|
+
subgraph GovernedRemediation["4. Governed Remediation Loop & Safety Guardrails (Ponytail Protocol)"]
|
|
179
|
+
direction TB
|
|
180
|
+
|
|
181
|
+
Harden["<b>Surgical Patch Formulation</b><br/>Semantic Line Snippet Replacement<br/>Strict Line Budget: ≤35 Additions • ≤25 Deletions"]
|
|
182
|
+
|
|
183
|
+
BoundsCheck{"<b>Ponytail Bounds Check</b><br/>Exceeds 35 Add / 25 Del?"}
|
|
184
|
+
RejectDiff["<b>Diff Rejected</b><br/>Excess Churn Detected<br/>Prompt AI for Minimal Snippet"]
|
|
185
|
+
|
|
186
|
+
SnapshotStore[("<b>Pre-Apply Snapshot Store</b><br/><code>.torusguard/snapshots/<run_id>/</code><br/>Byte-for-Byte Rollback Backup")]
|
|
187
|
+
|
|
188
|
+
HumanGate{"<b>Human Gate Authorization</b><br/>Explicit <code>--yes</code> or Interactive Confirmation"}
|
|
189
|
+
UserAbort["<b>Operation Aborted</b><br/>Zero Files Touched • Safe Exit"]
|
|
190
|
+
|
|
191
|
+
ApplyPatch["<b>Atomic Patch Application</b><br/>Apply Unified Surgical Diff to Disk"]
|
|
192
|
+
|
|
193
|
+
RecheckGate{"<b>Differential Recheck Engine</b><br/><code>torusguard recheck</code><br/>Fix Closed with Zero Regressions?"}
|
|
194
|
+
RollbackExec["<b>Auto-Rollback Triggered!</b><br/>Instant Restoration from Snapshot<br/>Quarantine Candidate Patch"]
|
|
195
|
+
|
|
196
|
+
Harden --> BoundsCheck
|
|
197
|
+
BoundsCheck -->|"Violation"| RejectDiff
|
|
198
|
+
RejectDiff -.->|"Re-prompt AI"| Harden
|
|
199
|
+
BoundsCheck -->|"Pass (Within Bounds)"| SnapshotStore
|
|
200
|
+
SnapshotStore --> HumanGate
|
|
201
|
+
HumanGate -->|"Denied"| UserAbort
|
|
202
|
+
HumanGate -->|"Approved"| ApplyPatch
|
|
203
|
+
ApplyPatch --> RecheckGate
|
|
204
|
+
RecheckGate -->|"Regressions"| RollbackExec
|
|
205
|
+
RollbackExec -.->|"Restore Clean State"| SnapshotStore
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
PRGate -->|"Target Findings"| Harden
|
|
139
209
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
210
|
+
%% =========================================================================
|
|
211
|
+
%% STAGE 6: LIVING SECURITY LEDGER & ENTERPRISE OUTPUTS
|
|
212
|
+
%% =========================================================================
|
|
213
|
+
subgraph EnterpriseDeliverables["5. Living Security Ledger & Enterprise Deliverables"]
|
|
214
|
+
direction TB
|
|
215
|
+
Ledger[("<b>Living Security Ledger</b><br/><code>security_report.md</code><br/>Synchronized Single Source of Truth • Status: RESOLVED 🟢")]
|
|
216
|
+
|
|
217
|
+
subgraph DeliverableOutputs["Executive Reports & Verified Memory"]
|
|
218
|
+
direction LR
|
|
219
|
+
ThreatModel["<b>STRIDE Threat Model</b><br/><code>SECURITY_THREAT_MODEL.md</code><br/>DFD Architecture Diagrams"]
|
|
220
|
+
SARIF["<b>OASIS SARIF v2.1.0</b><br/>GitHub Advanced Security<br/>CI/CD Security Center"]
|
|
221
|
+
HTMLReport["<b>Executive Dashboard</b><br/>Single-File HTML Report<br/>Interactive Posture Heatmap"]
|
|
222
|
+
GoldenRecipes[("<b>Golden Fix Memory</b><br/><code>.torusguard/recipes/</code><br/>Verified Distilled Fixes")]
|
|
145
223
|
end
|
|
224
|
+
|
|
225
|
+
Ledger --> DeliverableOutputs
|
|
146
226
|
end
|
|
147
227
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
classDef
|
|
157
|
-
classDef
|
|
158
|
-
classDef
|
|
159
|
-
classDef
|
|
160
|
-
classDef
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
class
|
|
228
|
+
RecheckGate -->|"Fix Confirmed (Clean Closure)"| Ledger
|
|
229
|
+
|
|
230
|
+
%% =========================================================================
|
|
231
|
+
%% STYLING AND THEME (Modern Dark Cyber Palette)
|
|
232
|
+
%% =========================================================================
|
|
233
|
+
classDef ingressStyle fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#f8fafc;
|
|
234
|
+
classDef routerStyle fill:#1e1b4b,stroke:#6366f1,stroke-width:2px,color:#f8fafc;
|
|
235
|
+
classDef scannerStyle fill:#022c22,stroke:#10b981,stroke-width:2px,color:#f8fafc;
|
|
236
|
+
classDef tourneyStyle fill:#2e1065,stroke:#a855f7,stroke-width:2px,color:#f8fafc;
|
|
237
|
+
classDef gateStyle fill:#451a03,stroke:#f59e0b,stroke-width:2px,color:#fef3c7;
|
|
238
|
+
classDef rejectStyle fill:#450a0a,stroke:#ef4444,stroke-width:2px,color:#fee2e2;
|
|
239
|
+
classDef actionStyle fill:#064e3b,stroke:#34d399,stroke-width:2px,color:#f8fafc;
|
|
240
|
+
classDef dbStyle fill:#1e293b,stroke:#94a3b8,stroke-width:2px,color:#f8fafc;
|
|
241
|
+
classDef ledgerStyle fill:#172554,stroke:#3b82f6,stroke-width:2px,color:#eff6ff;
|
|
242
|
+
classDef outputStyle fill:#042f2e,stroke:#14b8a6,stroke-width:2px,color:#f0fdfa;
|
|
243
|
+
|
|
244
|
+
class CLI,Chat,MCP ingressStyle;
|
|
245
|
+
class Kernel routerStyle;
|
|
246
|
+
class AST,TGQL,Reach,OCR,ReDoS,GitMine scannerStyle;
|
|
247
|
+
class Tournament tourneyStyle;
|
|
248
|
+
class PRGate,BoundsCheck,HumanGate,RecheckGate gateStyle;
|
|
249
|
+
class RejectDiff,UserAbort,RollbackExec rejectStyle;
|
|
250
|
+
class Harden,ApplyPatch actionStyle;
|
|
251
|
+
class SnapshotStore,GoldenRecipes dbStyle;
|
|
165
252
|
class Ledger ledgerStyle;
|
|
166
|
-
class
|
|
253
|
+
class ThreatModel,SARIF,HTMLReport outputStyle;
|
|
167
254
|
```
|
|
168
255
|
|
|
169
256
|
> 🌐 **Interactive Architecture Visualizations:**
|
|
@@ -189,24 +276,55 @@ flowchart TD
|
|
|
189
276
|
|
|
190
277
|
---
|
|
191
278
|
|
|
192
|
-
## 🚀 Installation
|
|
279
|
+
## 🚀 Installation & How to Use (3 Options)
|
|
280
|
+
|
|
281
|
+
TorusGuard can be run without installation via `npx`, installed globally or locally via `npm`, compiled from source with `go build`, or installed via `go install`.
|
|
282
|
+
|
|
283
|
+
| Option | Method | Best For | Dedicated Guide |
|
|
284
|
+
| :--- | :--- | :--- | :--- |
|
|
285
|
+
| **Option 1** | **npm & npx** | Node.js developers, zero-install CLI, CI/CD | 📖 [Option 1 Guide](docs/usage/option-1-npm.md) |
|
|
286
|
+
| **Option 2** | **Build from Source** | Contributors, custom rules, Go development | 📖 [Option 2 Guide](docs/usage/option-2-source.md) |
|
|
287
|
+
| **Option 3** | **Go Install** | Go projects, single-binary, zero Node.js/npm | 📖 [Option 3 Guide](docs/usage/option-3-go-install.md) |
|
|
288
|
+
|
|
289
|
+
---
|
|
193
290
|
|
|
194
291
|
### Option 1: npm (Primary)
|
|
195
292
|
|
|
293
|
+
#### Method A: Direct NPX Zero-Install (Recommended)
|
|
294
|
+
Run directly without installing any packages globally or locally:
|
|
295
|
+
|
|
196
296
|
```bash
|
|
197
|
-
|
|
297
|
+
npx torusguard init
|
|
198
298
|
```
|
|
199
299
|
|
|
200
|
-
|
|
300
|
+
*Tip: Use `npx torusguard@latest init` to guarantee the freshest release.*
|
|
201
301
|
|
|
302
|
+
#### Method B: Global Installation
|
|
202
303
|
```bash
|
|
203
|
-
|
|
304
|
+
npm install -g torusguard
|
|
305
|
+
torusguard init
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### Method C: Local Project Installation
|
|
309
|
+
```bash
|
|
310
|
+
npm install -D torusguard
|
|
204
311
|
```
|
|
205
312
|
|
|
313
|
+
> 💡 **Using TorusGuard after `npm install torusguard`:**
|
|
314
|
+
> TorusGuard is a CLI security engine, not an importable JavaScript library. When installed locally, the binary resides in `node_modules/.bin/torusguard`.
|
|
315
|
+
> You can run it via:
|
|
316
|
+
> - `npx torusguard init` *(npx automatically uses your local `node_modules` binary)*
|
|
317
|
+
> - Adding `"security:audit": "torusguard audit"` to your `package.json` scripts (`npm run security:audit`)
|
|
318
|
+
> - Direct path: `./node_modules/.bin/torusguard audit`
|
|
319
|
+
|
|
206
320
|
<a href="https://www.npmjs.com/package/torusguard">
|
|
207
|
-
<img src="https://img.shields.io/badge/npm-v2.1.
|
|
321
|
+
<img src="https://img.shields.io/badge/npm-v2.1.3-CB3837?logo=npm&logoColor=white" alt="npm package">
|
|
208
322
|
</a>
|
|
209
323
|
|
|
324
|
+
👉 **[Read the Full Option 1 (npm & npx) Dedicated Guide →](docs/usage/option-1-npm.md)**
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
210
328
|
### Option 2: Build from Source (Recommended for Contributors)
|
|
211
329
|
|
|
212
330
|
```bash
|
|
@@ -215,12 +333,37 @@ cd TorusGuard
|
|
|
215
333
|
go build -o torusguard ./cmd/torusguard
|
|
216
334
|
```
|
|
217
335
|
|
|
336
|
+
On Windows:
|
|
337
|
+
```powershell
|
|
338
|
+
go build -o torusguard.exe ./cmd/torusguard
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Run directly:
|
|
342
|
+
```bash
|
|
343
|
+
./torusguard init
|
|
344
|
+
./torusguard audit
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
👉 **[Read the Full Option 2 (Build from Source) Dedicated Guide →](docs/usage/option-2-source.md)**
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
218
351
|
### Option 3: Go Install
|
|
219
352
|
|
|
353
|
+
Install directly into `$GOPATH/bin`:
|
|
354
|
+
|
|
220
355
|
```bash
|
|
221
|
-
go install github.com/
|
|
356
|
+
go install github.com/githubmofo/TorusGuard/cmd/torusguard@latest
|
|
222
357
|
```
|
|
223
358
|
|
|
359
|
+
Verify and run:
|
|
360
|
+
```bash
|
|
361
|
+
torusguard --version
|
|
362
|
+
torusguard init
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
👉 **[Read the Full Option 3 (Go Install) Dedicated Guide →](docs/usage/option-3-go-install.md)**
|
|
366
|
+
|
|
224
367
|
---
|
|
225
368
|
|
|
226
369
|
## 💻 Usage
|
|
@@ -282,6 +425,9 @@ torusguard exploit-check
|
|
|
282
425
|
| `init` | Scaffold `.torusguard/` workspace, detect stack, activate rules |
|
|
283
426
|
| `status` | Diagnostic overview of posture, stack, and active rules |
|
|
284
427
|
| `audit` | Static heuristic security scan against active TG-* rules |
|
|
428
|
+
| `review` | Differential PR and Git diff incremental security review |
|
|
429
|
+
| `threatmodel` | Synthesize architectural STRIDE threat model & Mermaid DFDs |
|
|
430
|
+
| `benchmark` | Run SecurityReviewBench precision & recall evaluation suite |
|
|
285
431
|
| `verify` | Live disk line match audit and evidence sufficiency check |
|
|
286
432
|
| `harden` | Validate patches against Ponytail Protocol bounds |
|
|
287
433
|
| `apply` | Apply patches with pre-apply `.bak` rollback snapshots |
|
|
@@ -380,7 +526,7 @@ TorusGuard works natively inside AI coding assistants. Add the configuration fil
|
|
|
380
526
|
|
|
381
527
|
### Native MCP Tools (Agent Toolkit Mode)
|
|
382
528
|
|
|
383
|
-
When configured with `.agents/mcp_config.json` or `mcp_config.json`, AI coding agents gain native tool calling:
|
|
529
|
+
When configured with `.agents/mcp_config.json` or `mcp_config.json`, AI coding agents gain native tool calling (13 Tools & 2 Resources):
|
|
384
530
|
|
|
385
531
|
- `torusguard_audit`: Deep static AST scan + Vision OCR; writes `security_report.md`
|
|
386
532
|
- `torusguard_ocr_scan`: Dedicated image credential analysis via Tesseract (5-10MB bounds)
|
|
@@ -391,6 +537,9 @@ When configured with `.agents/mcp_config.json` or `mcp_config.json`, AI coding a
|
|
|
391
537
|
- `torusguard_verify`: Asserts evidence sufficiency & line-shift invariant fingerprint matches
|
|
392
538
|
- `torusguard_harden`: Validates remediation diff against Ponytail Protocol bounds
|
|
393
539
|
- `torusguard_recheck`: Differential re-scan confirming fix closure
|
|
540
|
+
- `torusguard_review`: Differential PR and Git diff incremental review; gate decisions
|
|
541
|
+
- `torusguard_threatmodel`: Synthesizes STRIDE threat model & Mermaid DFDs (`SECURITY_THREAT_MODEL.md`)
|
|
542
|
+
- `torusguard_benchmark`: Runs SecurityReviewBench self-evaluating precision & recall suite
|
|
394
543
|
- `torusguard_status`: Workspace posture and tech stack inspection
|
|
395
544
|
- `torusguard://security_report`: MCP Resource reading the living security report
|
|
396
545
|
- `torusguard://rules_catalog`: MCP Resource exploring verified rules catalog & Golden Fix patterns
|
package/bin/torusguard.js
CHANGED
|
@@ -15,14 +15,15 @@ const command = args[0] || 'init';
|
|
|
15
15
|
const rootDir = path.resolve(__dirname, '..');
|
|
16
16
|
const cwd = process.cwd();
|
|
17
17
|
|
|
18
|
+
let PKG_VERSION = '2.1.3';
|
|
19
|
+
try {
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf-8'));
|
|
21
|
+
PKG_VERSION = pkg.version || PKG_VERSION;
|
|
22
|
+
} catch (e) {}
|
|
23
|
+
|
|
18
24
|
// Parse version flag immediately
|
|
19
25
|
if (command === '--version' || command === '-v' || command === 'version') {
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf-8'));
|
|
23
|
-
ver = pkg.version || ver;
|
|
24
|
-
} catch (e) {}
|
|
25
|
-
console.log(`torusguard v${ver}`);
|
|
26
|
+
console.log(`torusguard v${PKG_VERSION}`);
|
|
26
27
|
process.exit(0);
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -196,7 +197,7 @@ function cardDivider(title = '', borderColor = CYAN, double = false) {
|
|
|
196
197
|
return ` ${borderColor}${left}${h.repeat(71)}${right}${RESET}`;
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
function cardHeader(title, subtitle = '', version =
|
|
200
|
+
function cardHeader(title, subtitle = '', version = `v${PKG_VERSION}`, borderColor = CYAN) {
|
|
200
201
|
const top = ` ${borderColor}╭${'─'.repeat(71)}╮${RESET}`;
|
|
201
202
|
const bottom = ` ${borderColor}╰${'─'.repeat(71)}╯${RESET}`;
|
|
202
203
|
const empty = ` ${borderColor}│${' '.repeat(71)}│${RESET}`;
|
|
@@ -214,7 +215,7 @@ function cardHeader(title, subtitle = '', version = 'v1.3.6', borderColor = CYAN
|
|
|
214
215
|
|
|
215
216
|
function printHelp() {
|
|
216
217
|
console.log();
|
|
217
|
-
console.log(cardHeader('🛡️ T O R U S G U A R D C L I', 'Autonomous Security Engine for AI-Built Applications',
|
|
218
|
+
console.log(cardHeader('🛡️ T O R U S G U A R D C L I', 'Autonomous Security Engine for AI-Built Applications', `v${PKG_VERSION}`));
|
|
218
219
|
console.log(`\n ${BOLD}Usage:${RESET} ${GREEN}npx torusguard${RESET} ${WHITE}[command]${RESET} ${GRAY}[options]${RESET}\n`);
|
|
219
220
|
|
|
220
221
|
console.log(cardBorderTop('Commands'));
|
|
@@ -309,7 +310,7 @@ if (command === 'status') {
|
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
console.log();
|
|
312
|
-
console.log(cardHeader('🛡️ TORUSGUARD SECURITY POSTURE', '',
|
|
313
|
+
console.log(cardHeader('🛡️ TORUSGUARD SECURITY POSTURE', '', `v${PKG_VERSION}`));
|
|
313
314
|
console.log(`\n ${BOLD}▸ Workspace:${RESET} ${GREEN}${cwd}${RESET}`);
|
|
314
315
|
console.log(` ${BOLD}▸ Governance:${RESET} ${GREEN}Full Local Governance (.torusguard/)${RESET}`);
|
|
315
316
|
console.log(` ${BOLD}▸ Living Report:${RESET} ${CYAN}security_report.md${RESET}\n`);
|
|
@@ -331,7 +332,7 @@ if (command === 'status') {
|
|
|
331
332
|
console.log();
|
|
332
333
|
|
|
333
334
|
console.log(cardBorderTop('Governance Telemetry'));
|
|
334
|
-
console.log(formatBoxLine(`Rules Catalog: ${GREEN}
|
|
335
|
+
console.log(formatBoxLine(`Rules Catalog: ${GREEN}88 Canonical Security Rules${RESET} (22 families)`));
|
|
335
336
|
console.log(formatBoxLine(`Severity Floor: ${YELLOW}${cfg.severity_threshold || 'medium'}${RESET}`));
|
|
336
337
|
console.log(formatBoxLine(`Runs Directory: ${DIM}${cfg.runs_dir || '.torusguard/runs'}${RESET}`));
|
|
337
338
|
console.log(formatBoxLine(`Ponytail Bounds: ${GREEN}<= 35 additions, <= 25 deletions${RESET}`));
|
|
@@ -339,16 +340,18 @@ if (command === 'status') {
|
|
|
339
340
|
console.log(cardBorderBottom());
|
|
340
341
|
console.log();
|
|
341
342
|
|
|
342
|
-
console.log(cardBorderTop('Rule Families (
|
|
343
|
-
console.log(formatBoxLine(`${YELLOW}TG-SEC${RESET} Secrets (7)
|
|
344
|
-
console.log(formatBoxLine(`${YELLOW}TG-
|
|
343
|
+
console.log(cardBorderTop('Rule Families (22 Families / 88 Rules)'));
|
|
344
|
+
console.log(formatBoxLine(`${YELLOW}TG-SEC${RESET} Secrets & Tokens (7) ${YELLOW}TG-AUTH${RESET} Authentication (8)`));
|
|
345
|
+
console.log(formatBoxLine(`${YELLOW}TG-DB${RESET} Database Isolation (4) ${YELLOW}TG-INPUT${RESET} Input & Traversal (8)`));
|
|
345
346
|
console.log(formatBoxLine(`${YELLOW}TG-RATE${RESET} Rate Limiting (3) ${YELLOW}TG-AGENT${RESET} AI Agent Security (4)`));
|
|
346
|
-
console.log(formatBoxLine(`${YELLOW}TG-SSRF${RESET} Server Request (4)
|
|
347
|
-
console.log(formatBoxLine(`${YELLOW}TG-WS${RESET} WebSocket (4)
|
|
348
|
-
console.log(formatBoxLine(`${YELLOW}TG-GQL${RESET} GraphQL
|
|
349
|
-
console.log(formatBoxLine(`${YELLOW}TG-BIZ${RESET} Business Logic (4) ${YELLOW}TG-CACHE${RESET} Cache
|
|
350
|
-
console.log(formatBoxLine(`${YELLOW}TG-CLIENT${RESET} Client
|
|
351
|
-
console.log(formatBoxLine(`${YELLOW}TG-DIFF${RESET}
|
|
347
|
+
console.log(formatBoxLine(`${YELLOW}TG-SSRF${RESET} Server-Side Request (4) ${YELLOW}TG-WEBHOOK${RESET} Webhook Signature (4)`));
|
|
348
|
+
console.log(formatBoxLine(`${YELLOW}TG-WS${RESET} WebSocket Safety (4) ${YELLOW}TG-CSRF${RESET} Cross-Site Request (2)`));
|
|
349
|
+
console.log(formatBoxLine(`${YELLOW}TG-GQL${RESET} GraphQL Introspection (4)${YELLOW}TG-SUPPLY${RESET} Supply Chain Health (6)`));
|
|
350
|
+
console.log(formatBoxLine(`${YELLOW}TG-BIZ${RESET} Business Logic (4) ${YELLOW}TG-CACHE${RESET} Cache Poisoning (3)`));
|
|
351
|
+
console.log(formatBoxLine(`${YELLOW}TG-CLIENT${RESET} Client Bundle Secrets (2)${YELLOW}TG-PLATFORM${RESET}Platform Hardening (4)`));
|
|
352
|
+
console.log(formatBoxLine(`${YELLOW}TG-DIFF${RESET} Polyglot Bypass Guard (3)${YELLOW}TG-EDGE${RESET} Edge & Serverless (2)`));
|
|
353
|
+
console.log(formatBoxLine(`${YELLOW}TG-CONT${RESET} Container Hardening (4) ${YELLOW}TG-GIT${RESET} Git Secret Mining (3)`));
|
|
354
|
+
console.log(formatBoxLine(`${YELLOW}TG-REDOS${RESET} ReDoS Complexity Guard (2)${YELLOW}TG-RAG${RESET} RAG & Vector Scoping (3)`));
|
|
352
355
|
console.log(cardBorderBottom());
|
|
353
356
|
|
|
354
357
|
console.log(`\n ${DIM}Quick Action:${RESET} In your AI chat, run ${CYAN}/torusguard-audit${RESET} to scan.\n`);
|
|
@@ -640,6 +643,9 @@ if (command === 'recipes') {
|
|
|
640
643
|
if (command === 'init') {
|
|
641
644
|
const { target, remaining } = parseTargetAndArgs(args);
|
|
642
645
|
const targetDir = path.resolve(cwd, target);
|
|
646
|
+
if (!fs.existsSync(targetDir)) {
|
|
647
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
648
|
+
}
|
|
643
649
|
const localBootstrap = path.join(rootDir, 'skills', 'torusguard', 'bootstrap.py');
|
|
644
650
|
const localInstall = path.join(rootDir, 'install.py');
|
|
645
651
|
const scriptToRun = fs.existsSync(localBootstrap) ? localBootstrap : localInstall;
|
|
@@ -655,13 +661,7 @@ if (command === 'init') {
|
|
|
655
661
|
// Subcommand: update
|
|
656
662
|
if (command === 'update') {
|
|
657
663
|
const https = require('https');
|
|
658
|
-
const
|
|
659
|
-
let currentVersion = '1.4.0';
|
|
660
|
-
try {
|
|
661
|
-
if (fs.existsSync(pkgJsonPath)) {
|
|
662
|
-
currentVersion = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')).version || currentVersion;
|
|
663
|
-
}
|
|
664
|
-
} catch (e) {}
|
|
664
|
+
const currentVersion = PKG_VERSION;
|
|
665
665
|
|
|
666
666
|
console.log();
|
|
667
667
|
console.log(cardHeader('🛡️ TORUSGUARD UPDATE CHECK', 'Package Distribution & Registry Verifier', `v${currentVersion}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torusguard",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Security guardrails, governed remediation, and authorized runtime validation for AI-built web applications.",
|
|
5
5
|
"main": "bin/torusguard.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,10 +15,14 @@
|
|
|
15
15
|
"LICENSE"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
+
"postinstall": "node -e \"console.log('\\n🛡️ TorusGuard v2.1.3 installed! Run: npx torusguard init\\n')\"",
|
|
18
19
|
"test": "python harness/runner.py",
|
|
19
20
|
"init": "node bin/torusguard.js init",
|
|
20
21
|
"status": "node bin/torusguard.js status",
|
|
21
22
|
"audit": "node bin/torusguard.js audit",
|
|
23
|
+
"review": "node bin/torusguard.js review",
|
|
24
|
+
"threatmodel": "node bin/torusguard.js threatmodel",
|
|
25
|
+
"benchmark": "node bin/torusguard.js benchmark",
|
|
22
26
|
"harden": "node bin/torusguard.js harden",
|
|
23
27
|
"apply": "node bin/torusguard.js apply",
|
|
24
28
|
"recipes": "node bin/torusguard.js recipes",
|
|
Binary file
|