torusguard 0.9.4 → 1.0.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 +15 -10
- package/.torusguard/config/torusguard.json +1 -1
- 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/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/finding_scorer.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/memory_engine.cpython-311.pyc +0 -0
- package/.torusguard/scripts/diff_guard.py +71 -11
- package/.torusguard/scripts/finding_scorer.py +171 -86
- package/.torusguard/scripts/manifest_builder.py +2 -0
- package/.torusguard/scripts/memory_engine.py +912 -0
- package/.torusguard/scripts/run_manager.py +171 -89
- package/.torusguard/skills/torusguard/SKILL.md +12 -7
- package/.torusguard/skills/torusguard/bootstrap.py +344 -56
- 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 +12 -2
- package/bin/torusguard.js +173 -43
- package/package.json +1 -1
- package/skills/torusguard/SKILL.md +4 -3
- package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
- package/skills/torusguard/bootstrap.py +244 -80
- package/skills/torusguard/payload/.manifest.json +15 -10
- package/skills/torusguard/payload/config/torusguard.json +1 -1
- 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 +71 -11
- package/skills/torusguard/payload/scripts/finding_scorer.py +171 -86
- package/skills/torusguard/payload/scripts/manifest_builder.py +2 -0
- package/skills/torusguard/payload/scripts/memory_engine.py +912 -0
- package/skills/torusguard/payload/scripts/run_manager.py +171 -89
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +12 -7
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +344 -56
- 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
|
@@ -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.
|
package/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="TorusGuard.png" alt="TorusGuard Security Banner" width="480" style="max-width: 100%; height: auto; border-radius: 8px;">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/githubmofo/TorusGuard/main/TorusGuard.png" alt="TorusGuard Security Banner" width="480" style="max-width: 100%; height: auto; border-radius: 8px;">
|
|
3
3
|
|
|
4
4
|
# TorusGuard
|
|
5
5
|
|
|
6
6
|
**Autonomous Security Guardrails, Governed Remediation, and Authorized Runtime Validation for AI-Built Web Applications.**
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/torusguard)
|
|
9
|
-
[](https://github.com/githubmofo/TorusGuard/pkgs/npm/torusguard)
|
|
10
|
+
[](https://github.com/githubmofo/TorusGuard/releases/latest)
|
|
10
11
|
[](LICENSE)
|
|
11
12
|
[](https://python.org)
|
|
12
13
|
[](https://nodejs.org)
|
|
@@ -142,6 +143,7 @@ When Track 2 is initialized, the complete 11-command palette becomes available i
|
|
|
142
143
|
| `/torusguard recheck`<br>*(or `/torusguard-recheck`)* | `skills/torusguard-recheck` | Phase 6 | Executes differential re-audit strictly on modified files to verify fix closure. | No |
|
|
143
144
|
| `/torusguard report`<br>*(or `/torusguard-report`)* | `skills/torusguard-report` | Phase 7 | Emits executive summary markdown and OASIS SARIF v2.1.0 CI artifacts. | No |
|
|
144
145
|
| `/torusguard status`<br>*(or `/torusguard-status`)* | `skills/torusguard-status` | Diagnostic | Inspects active security posture, thresholds, and recent run history. | No |
|
|
146
|
+
| `/torusguard memory` | `skills/torusguard` | Intelligence | Inspects, exports, imports, or compacts persistent security memory context. | Yes (`.torusguard/memory/`) |
|
|
145
147
|
| `/torusguard full` | `skills/torusguard-full` | End-to-End | Orchestrates the entire 7-stage security cycle in one coordinated sequence. | **Yes (Governed)** |
|
|
146
148
|
|
|
147
149
|
---
|
|
@@ -258,6 +260,14 @@ $$\text{Score} = (w_d \cdot D) + (w_e \cdot E) + (w_c \cdot C_{ast}) - P_{fp} -
|
|
|
258
260
|
### 3. Stable Line-Shift Invariant Fingerprinting (`primaryLocationLineHash`)
|
|
259
261
|
Traditional static tools break finding identity when a developer inserts 2 lines at the top of a file. TorusGuard computes a stable SHA-256 hash across the AST node content, enclosing function scope, and syntactic tokens. Findings maintain permanent tracking identity across Git commits and branch renames.
|
|
260
262
|
|
|
263
|
+
### 4. Adaptive Security Memory Engine (`.torusguard/memory/`)
|
|
264
|
+
Traditional scanners are stateless — they scan, report, and forget. TorusGuard v1.0.0 introduces persistent, local-first intelligence that learns from every audit, fix, and verification:
|
|
265
|
+
* **4-Tier Intelligence Architecture:** Raw event append-log (`events/`) ──► Distilled pattern store (`patterns.json`) ──► Pre-computed context window (`context.json`) ──► Project security profile (`profile.json`).
|
|
266
|
+
* **Structured JSON Cards:** Pre-computes context cards within a strict $\le 2,000$ token budget for instant, hallucination-free injection into AI coding agent prompts.
|
|
267
|
+
* **Confidence Amplification & TTL Decay:** Multi-file fix verifications boost pattern confidence up to 98%, while unconfirmed patterns decay gracefully over 90 days.
|
|
268
|
+
* **Zero-Leakage Guarantee:** Memory is strictly gitignored (`*`), excluded from npm distribution tarballs, and stored only in the user's project.
|
|
269
|
+
* **CLI Memory Management:** Inspect, export, import, or compact memory via `npx torusguard memory`.
|
|
270
|
+
|
|
261
271
|
---
|
|
262
272
|
|
|
263
273
|
## 🛡️ Rule Catalog & Detection Families (71 Canonical Rules)
|
package/bin/torusguard.js
CHANGED
|
@@ -15,14 +15,16 @@ const command = args[0] || 'init';
|
|
|
15
15
|
const rootDir = path.resolve(__dirname, '..');
|
|
16
16
|
const cwd = process.cwd();
|
|
17
17
|
|
|
18
|
-
// ANSI Color Helpers
|
|
18
|
+
// ─── ANSI Color Helpers ───────────────────────────────────────────────────────
|
|
19
19
|
const BOLD = '\x1b[1m';
|
|
20
|
+
const DIM = '\x1b[2m';
|
|
20
21
|
const RESET = '\x1b[0m';
|
|
21
22
|
const CYAN = '\x1b[36m';
|
|
22
23
|
const GREEN = '\x1b[32m';
|
|
23
24
|
const YELLOW = '\x1b[33m';
|
|
25
|
+
const WHITE = '\x1b[97m';
|
|
24
26
|
const GRAY = '\x1b[90m';
|
|
25
|
-
const
|
|
27
|
+
const RED = '\x1b[31m';
|
|
26
28
|
|
|
27
29
|
// Detect available Python binary (python or python3)
|
|
28
30
|
let pythonCmd = 'python';
|
|
@@ -45,24 +47,42 @@ try {
|
|
|
45
47
|
|
|
46
48
|
function printHelp() {
|
|
47
49
|
console.log(`
|
|
48
|
-
${CYAN}
|
|
49
|
-
${CYAN}│${RESET}
|
|
50
|
-
${CYAN}│${RESET}
|
|
51
|
-
${CYAN}
|
|
52
|
-
|
|
53
|
-
${
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
${
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
${CYAN}╭─────────────────────────────────────────────────────────────────────────╮${RESET}
|
|
51
|
+
${CYAN}│${RESET} ${CYAN}│${RESET}
|
|
52
|
+
${CYAN}│${RESET} ${BOLD}${WHITE}🛡️ T O R U S G U A R D C L I${RESET} ${GRAY}v1.0.0${RESET} ${CYAN}│${RESET}
|
|
53
|
+
${CYAN}│${RESET} ${DIM}Autonomous Security Engine for AI-Built Applications${RESET} ${CYAN}│${RESET}
|
|
54
|
+
${CYAN}│${RESET} ${CYAN}│${RESET}
|
|
55
|
+
${CYAN}╰─────────────────────────────────────────────────────────────────────────╯${RESET}
|
|
56
|
+
|
|
57
|
+
${BOLD}Usage:${RESET} ${GREEN}npx torusguard${RESET} ${WHITE}[command]${RESET} ${GRAY}[options]${RESET}
|
|
58
|
+
|
|
59
|
+
${CYAN}┌─────────────────────────────────────────────────────────────────────────┐${RESET}
|
|
60
|
+
${CYAN}│${RESET} ${BOLD}Commands${RESET} ${CYAN}│${RESET}
|
|
61
|
+
${CYAN}├─────────────────────────────────────────────────────────────────────────┤${RESET}
|
|
62
|
+
${CYAN}│${RESET} ${GREEN}init${RESET} Scaffold ${BOLD}.torusguard/${RESET} workspace + unlock 12 slash commands ${CYAN}│${RESET}
|
|
63
|
+
${CYAN}│${RESET} ${GREEN}status${RESET} Display active security posture, memory, rules, and stack ${CYAN}│${RESET}
|
|
64
|
+
${CYAN}│${RESET} ${GREEN}memory${RESET} Manage persistent security memory (export, import, decay) ${CYAN}│${RESET}
|
|
65
|
+
${CYAN}│${RESET} ${GREEN}audit${RESET} Run static AST security scan on the target project ${CYAN}│${RESET}
|
|
66
|
+
${CYAN}│${RESET} ${GREEN}report${RESET} Export OASIS SARIF v2.1.0 structured telemetry ${CYAN}│${RESET}
|
|
67
|
+
${CYAN}│${RESET} ${GREEN}help${RESET} Show this interactive command guide ${CYAN}│${RESET}
|
|
68
|
+
${CYAN}├─────────────────────────────────────────────────────────────────────────┤${RESET}
|
|
69
|
+
${CYAN}│${RESET} ${BOLD}Options${RESET} ${CYAN}│${RESET}
|
|
70
|
+
${CYAN}├─────────────────────────────────────────────────────────────────────────┤${RESET}
|
|
71
|
+
${CYAN}│${RESET} ${GRAY}--target <dir>${RESET} Target directory to analyze or scaffold ${DIM}(default: .)${RESET} ${CYAN}│${RESET}
|
|
72
|
+
${CYAN}│${RESET} ${GRAY}--force${RESET} Overwrite existing workspace and re-scaffold ${CYAN}│${RESET}
|
|
73
|
+
${CYAN}└─────────────────────────────────────────────────────────────────────────┘${RESET}
|
|
74
|
+
|
|
75
|
+
${BOLD}AI Chat Commands:${RESET}
|
|
76
|
+
${DIM}In your AI IDE chat, use any of these slash commands:${RESET}
|
|
77
|
+
${CYAN}/torusguard${RESET} Main orchestrator (status, audit, harden, memory)
|
|
78
|
+
${CYAN}/torusguard-audit${RESET} Static AST security scan
|
|
79
|
+
${CYAN}/torusguard-harden${RESET} Generate governed fix patches
|
|
80
|
+
${CYAN}/torusguard-apply${RESET} Apply patches with rollback snapshots
|
|
81
|
+
${CYAN}/torusguard-report${RESET} Executive security posture report
|
|
82
|
+
${CYAN}/torusguard-status${RESET} Read-only workspace diagnostic
|
|
83
|
+
|
|
84
|
+
${DIM}Documentation:${RESET} ${CYAN}https://github.com/githubmofo/TorusGuard${RESET}
|
|
85
|
+
${DIM}NPM Package:${RESET} ${CYAN}https://npmjs.com/package/torusguard${RESET}
|
|
66
86
|
`);
|
|
67
87
|
}
|
|
68
88
|
|
|
@@ -76,28 +96,74 @@ if (command === 'status') {
|
|
|
76
96
|
if (fs.existsSync(cfgPath)) {
|
|
77
97
|
try {
|
|
78
98
|
const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf-8'));
|
|
99
|
+
const stackLang = cfg.detected_stack?.language || 'Not yet detected';
|
|
100
|
+
const stackFw = cfg.detected_stack?.framework || 'Not yet detected';
|
|
101
|
+
const stackDb = cfg.detected_stack?.data_layer || 'Not yet detected';
|
|
102
|
+
const stackStatus = cfg.detected_stack ? `${GREEN}Detected${RESET}` : `${YELLOW}Pending first audit${RESET}`;
|
|
103
|
+
|
|
104
|
+
// Memory telemetry
|
|
105
|
+
const memProfilePath = path.join(cwd, '.torusguard', 'memory', 'profile.json');
|
|
106
|
+
const memContextPath = path.join(cwd, '.torusguard', 'memory', 'context.json');
|
|
107
|
+
let memPatterns = 0;
|
|
108
|
+
let memEvents = 0;
|
|
109
|
+
let memTokens = 0;
|
|
110
|
+
let memFixRate = 'N/A';
|
|
111
|
+
if (fs.existsSync(memProfilePath)) {
|
|
112
|
+
try {
|
|
113
|
+
const prof = JSON.parse(fs.readFileSync(memProfilePath, 'utf-8'));
|
|
114
|
+
memPatterns = prof.active_patterns_count || 0;
|
|
115
|
+
memEvents = prof.total_events || 0;
|
|
116
|
+
memFixRate = prof.fix_rate_percentage !== null && prof.fix_rate_percentage !== undefined ? `${prof.fix_rate_percentage}%` : 'N/A';
|
|
117
|
+
} catch (e) {}
|
|
118
|
+
}
|
|
119
|
+
if (fs.existsSync(memContextPath)) {
|
|
120
|
+
try {
|
|
121
|
+
const ctx = JSON.parse(fs.readFileSync(memContextPath, 'utf-8'));
|
|
122
|
+
memTokens = ctx.token_estimate || 0;
|
|
123
|
+
} catch (e) {}
|
|
124
|
+
}
|
|
125
|
+
|
|
79
126
|
console.log(`
|
|
80
|
-
${CYAN}
|
|
81
|
-
${CYAN}│${RESET}
|
|
82
|
-
${CYAN}
|
|
83
|
-
|
|
84
|
-
${
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
${BOLD}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
${
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
${CYAN}
|
|
99
|
-
${CYAN}│${RESET} ${
|
|
100
|
-
${CYAN}
|
|
127
|
+
${CYAN}╭─────────────────────────────────────────────────────────────────────────╮${RESET}
|
|
128
|
+
${CYAN}│${RESET} ${CYAN}│${RESET}
|
|
129
|
+
${CYAN}│${RESET} ${BOLD}${WHITE}🛡️ TORUSGUARD SECURITY POSTURE${RESET} ${GRAY}v1.0.0${RESET} ${CYAN}│${RESET}
|
|
130
|
+
${CYAN}│${RESET} ${CYAN}│${RESET}
|
|
131
|
+
${CYAN}╰─────────────────────────────────────────────────────────────────────────╯${RESET}
|
|
132
|
+
|
|
133
|
+
${BOLD}▸ Workspace:${RESET} ${GREEN}${cwd}${RESET}
|
|
134
|
+
${BOLD}▸ Governance:${RESET} ${GREEN}Full Local Governance (.torusguard/)${RESET}
|
|
135
|
+
|
|
136
|
+
${CYAN}┌── Environment & Stack ──────────────────────────────────────────────────┐${RESET}
|
|
137
|
+
${CYAN}│${RESET} Language: ${BOLD}${stackLang}${RESET}
|
|
138
|
+
${CYAN}│${RESET} Framework: ${BOLD}${stackFw}${RESET}
|
|
139
|
+
${CYAN}│${RESET} Data Layer: ${BOLD}${stackDb}${RESET}
|
|
140
|
+
${CYAN}│${RESET} Stack Detection: ${stackStatus}
|
|
141
|
+
${CYAN}└─────────────────────────────────────────────────────────────────────────┘${RESET}
|
|
142
|
+
|
|
143
|
+
${CYAN}┌── Security Memory Engine ───────────────────────────────────────────────┐${RESET}
|
|
144
|
+
${CYAN}│${RESET} Patterns Learned: ${GREEN}${memPatterns} active patterns${RESET}
|
|
145
|
+
${CYAN}│${RESET} Events Recorded: ${WHITE}${memEvents} events (local-first log)${RESET}
|
|
146
|
+
${CYAN}│${RESET} Context Window: ${CYAN}${memTokens} / 2,000 tokens${RESET} (${Math.round((memTokens / 2000) * 100)}% utilized)
|
|
147
|
+
${CYAN}│${RESET} Fix Velocity Rate: ${YELLOW}${memFixRate}${RESET}
|
|
148
|
+
${CYAN}└─────────────────────────────────────────────────────────────────────────┘${RESET}
|
|
149
|
+
|
|
150
|
+
${CYAN}┌── Governance Telemetry ─────────────────────────────────────────────────┐${RESET}
|
|
151
|
+
${CYAN}│${RESET} Rules Catalog: ${GREEN}71 Canonical Security Rules${RESET} (11 families)
|
|
152
|
+
${CYAN}│${RESET} Severity Floor: ${YELLOW}${cfg.severity_threshold || 'medium'}${RESET}
|
|
153
|
+
${CYAN}│${RESET} Runs Directory: ${DIM}${cfg.runs_dir || '.torusguard/runs'}${RESET}
|
|
154
|
+
${CYAN}│${RESET} Ponytail Bounds: ${GREEN}<= 35 additions, <= 25 deletions${RESET}
|
|
155
|
+
${CYAN}└─────────────────────────────────────────────────────────────────────────┘${RESET}
|
|
156
|
+
|
|
157
|
+
${CYAN}┌── Rule Families ────────────────────────────────────────────────────────┐${RESET}
|
|
158
|
+
${CYAN}│${RESET} ${YELLOW}TG-SEC${RESET} Secrets & Credentials ${YELLOW}TG-DB${RESET} Database Safety
|
|
159
|
+
${CYAN}│${RESET} ${YELLOW}TG-INPUT${RESET} Input Validation ${YELLOW}TG-AUTH${RESET} Authentication
|
|
160
|
+
${CYAN}│${RESET} ${YELLOW}TG-CLIENT${RESET} Client Bundle Leaks ${YELLOW}TG-DIFF${RESET} Diff Inspection
|
|
161
|
+
${CYAN}│${RESET} ${YELLOW}TG-AGENT${RESET} AI Agent Security ${YELLOW}TG-EDGE${RESET} Serverless
|
|
162
|
+
${CYAN}│${RESET} ${YELLOW}TG-SUPPLY${RESET} Supply Chain & CI/CD ${YELLOW}TG-SSRF${RESET} Outbound Net
|
|
163
|
+
${CYAN}│${RESET} ${YELLOW}TG-BIZ${RESET} Business Logic
|
|
164
|
+
${CYAN}└─────────────────────────────────────────────────────────────────────────┘${RESET}
|
|
165
|
+
|
|
166
|
+
${DIM}Quick Action:${RESET} In your AI chat, run ${CYAN}/torusguard-audit${RESET} to scan.
|
|
101
167
|
`);
|
|
102
168
|
process.exit(0);
|
|
103
169
|
} catch (e) {
|
|
@@ -105,13 +171,77 @@ if (command === 'status') {
|
|
|
105
171
|
}
|
|
106
172
|
} else {
|
|
107
173
|
console.log(`
|
|
108
|
-
${YELLOW}
|
|
109
|
-
|
|
174
|
+
${YELLOW}⚠${RESET} No .torusguard workspace found in current directory.
|
|
175
|
+
Run ${GREEN}npx torusguard init${RESET} to scaffold full workspace governance.
|
|
110
176
|
`);
|
|
111
177
|
process.exit(0);
|
|
112
178
|
}
|
|
113
179
|
}
|
|
114
180
|
|
|
181
|
+
// Subcommand: memory
|
|
182
|
+
if (command === 'memory') {
|
|
183
|
+
const sub = args[1] || 'status';
|
|
184
|
+
const memScript = path.join(cwd, '.torusguard', 'scripts', 'memory_engine.py');
|
|
185
|
+
const fallbackMemScript = path.join(rootDir, '.torusguard', 'scripts', 'memory_engine.py');
|
|
186
|
+
const actualMemScript = fs.existsSync(memScript) ? memScript : fallbackMemScript;
|
|
187
|
+
|
|
188
|
+
let pyArgs = [actualMemScript];
|
|
189
|
+
if (sub === 'status') {
|
|
190
|
+
pyArgs.push('--action', 'status');
|
|
191
|
+
} else if (sub === 'context') {
|
|
192
|
+
pyArgs.push('--action', 'context');
|
|
193
|
+
} else if (sub === 'distill') {
|
|
194
|
+
pyArgs.push('--action', 'distill');
|
|
195
|
+
} else if (sub === 'decay') {
|
|
196
|
+
pyArgs.push('--action', 'decay');
|
|
197
|
+
const ttlIdx = args.indexOf('--ttl');
|
|
198
|
+
if (ttlIdx !== -1 && args[ttlIdx + 1]) {
|
|
199
|
+
pyArgs.push('--ttl', args[ttlIdx + 1]);
|
|
200
|
+
}
|
|
201
|
+
} else if (sub === 'compact') {
|
|
202
|
+
pyArgs.push('--action', 'compact');
|
|
203
|
+
const ageIdx = args.indexOf('--older-than');
|
|
204
|
+
if (ageIdx !== -1 && args[ageIdx + 1]) {
|
|
205
|
+
pyArgs.push('--older-than', args[ageIdx + 1]);
|
|
206
|
+
}
|
|
207
|
+
} else if (sub === 'export') {
|
|
208
|
+
pyArgs.push('--action', 'export');
|
|
209
|
+
const pathIdx = args.indexOf('--path') !== -1 ? args.indexOf('--path') : args.indexOf('-p');
|
|
210
|
+
if (pathIdx !== -1 && args[pathIdx + 1]) {
|
|
211
|
+
pyArgs.push('--target', args[pathIdx + 1]);
|
|
212
|
+
} else {
|
|
213
|
+
pyArgs.push('--target', 'torusguard-memory-export.json');
|
|
214
|
+
}
|
|
215
|
+
} else if (sub === 'import') {
|
|
216
|
+
pyArgs.push('--action', 'import');
|
|
217
|
+
const pathIdx = args.indexOf('--path') !== -1 ? args.indexOf('--path') : args.indexOf('-p');
|
|
218
|
+
if (pathIdx !== -1 && args[pathIdx + 1]) {
|
|
219
|
+
pyArgs.push('--source', args[pathIdx + 1]);
|
|
220
|
+
} else {
|
|
221
|
+
console.error(`${RED}Error: --path <file> is required for memory import${RESET}`);
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
} else if (sub === 'fp') {
|
|
225
|
+
pyArgs.push('--action', 'fp');
|
|
226
|
+
const ruleIdx = args.indexOf('--rule') !== -1 ? args.indexOf('--rule') : args.indexOf('-r');
|
|
227
|
+
if (ruleIdx !== -1 && args[ruleIdx + 1]) {
|
|
228
|
+
pyArgs.push('--rule-id', args[ruleIdx + 1]);
|
|
229
|
+
} else {
|
|
230
|
+
console.error(`${RED}Error: --rule <rule_id> is required for fp suppression${RESET}`);
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
const reasonIdx = args.indexOf('--reason');
|
|
234
|
+
if (reasonIdx !== -1 && args[reasonIdx + 1]) {
|
|
235
|
+
pyArgs.push('--reason', args[reasonIdx + 1]);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
pyArgs.push('--action', sub, ...args.slice(2));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const proc = spawnSync(pythonCmd, pyArgs, { stdio: 'inherit', cwd });
|
|
242
|
+
process.exit(proc.status !== null ? proc.status : 0);
|
|
243
|
+
}
|
|
244
|
+
|
|
115
245
|
// Locate bootstrap / runner scripts
|
|
116
246
|
const localBootstrap = path.join(rootDir, 'skills', 'torusguard', 'bootstrap.py');
|
|
117
247
|
const localInstall = path.join(rootDir, 'install.py');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard
|
|
3
|
-
description:
|
|
4
|
-
version: 0.
|
|
3
|
+
description: "Autonomous security engine: 71 rules across 11 families, governed remediation (Ponytail Protocol), SARIF v2.1.0 exports, and persistent security memory context for Python & TypeScript web applications."
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# TorusGuard Master Security Router
|
|
@@ -11,7 +11,7 @@ version: 0.9.4
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
## ⚡ Workspace Bootstrap Check
|
|
14
|
-
1. **If `.torusguard/` exists on disk:** Full governance active. Route
|
|
14
|
+
1. **If `.torusguard/` exists on disk:** Full governance active. Load `.torusguard/memory/context.json` into prompt context for local-first intelligence. Route commands to specialist workflows below.
|
|
15
15
|
2. **If `.torusguard/` is absent (Autonomous AI Mode):** Operates standalone in any AI agent (Kimi, Antigravity, VS Code, Cursor). Apply in-memory security invariants:
|
|
16
16
|
- Server-side auth & tenant scoping (`.filter(tenant=...)`).
|
|
17
17
|
- Zero client-side secrets (`SUPABASE_SERVICE_ROLE_KEY`, live API keys).
|
|
@@ -36,6 +36,7 @@ Load **only** the designated sub-skill on demand to preserve the 1,000–1,500 t
|
|
|
36
36
|
| `/torusguard recheck` | `skills/torusguard-recheck/SKILL.md` | `reviewer` |
|
|
37
37
|
| `/torusguard report` | `skills/torusguard-report/SKILL.md` | `reviewer` |
|
|
38
38
|
| `/torusguard status` | `skills/torusguard-status/SKILL.md` | `reviewer` |
|
|
39
|
+
| `/torusguard memory` | `skills/torusguard/SKILL.md` | `reviewer` |
|
|
39
40
|
| `/torusguard full` | `skills/torusguard-full/SKILL.md` | *All* |
|
|
40
41
|
|
|
41
42
|
*Note: Never load all skills simultaneously. Lazy-load strictly on demand.*
|
|
Binary file
|