torusguard 0.9.2
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 +95 -0
- package/.torusguard/ARCHITECTURE.md +168 -0
- package/.torusguard/TORUSGUARD.md +145 -0
- package/.torusguard/agents/auditor.md +41 -0
- package/.torusguard/agents/profiler.md +49 -0
- package/.torusguard/agents/remediator.md +41 -0
- package/.torusguard/agents/reviewer.md +39 -0
- package/.torusguard/agents/validator.md +46 -0
- package/.torusguard/config/scope.json +24 -0
- package/.torusguard/config/slash-commands.json +102 -0
- package/.torusguard/config/torusguard.json +30 -0
- package/.torusguard/references/django-security.md +43 -0
- package/.torusguard/references/drf-security.md +20 -0
- package/.torusguard/references/express-security.md +103 -0
- package/.torusguard/references/fastapi-security.md +20 -0
- package/.torusguard/references/firebase-security.md +78 -0
- package/.torusguard/references/flask-security.md +20 -0
- package/.torusguard/references/nextjs-security.md +96 -0
- package/.torusguard/references/react-vite-security.md +97 -0
- package/.torusguard/references/sqlalchemy-security.md +16 -0
- package/.torusguard/references/supabase-security.md +84 -0
- package/.torusguard/rules/README.md +62 -0
- package/.torusguard/rules/TORUSGUARD.md +145 -0
- package/.torusguard/rules/active/.gitkeep +0 -0
- package/.torusguard/rules/active/TG-DIFF-001.md +20 -0
- package/.torusguard/rules/active/TG-DIFF-002.md +20 -0
- package/.torusguard/rules/active/TG-DIFF-003.md +19 -0
- package/.torusguard/runs/.gitkeep +0 -0
- package/.torusguard/schemas/authorization.schema.json +81 -0
- package/.torusguard/schemas/confidence.schema.json +72 -0
- package/.torusguard/schemas/evidence.schema.json +66 -0
- package/.torusguard/schemas/finding.schema.json +164 -0
- package/.torusguard/schemas/provenance.schema.json +46 -0
- package/.torusguard/schemas/remediation.schema.json +59 -0
- package/.torusguard/schemas/retest.schema.json +53 -0
- package/.torusguard/schemas/runtime-evidence.schema.json +72 -0
- package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
- package/.torusguard/scripts/diff_guard.py +171 -0
- package/.torusguard/scripts/finding_scorer.py +86 -0
- package/.torusguard/scripts/manifest_builder.py +130 -0
- package/.torusguard/scripts/monorepo_detector.py +164 -0
- package/.torusguard/scripts/run_manager.py +89 -0
- package/.torusguard/scripts/safety_gate.py +64 -0
- package/.torusguard/scripts/sarif_exporter.py +116 -0
- package/.torusguard/scripts/stack_detect.py +152 -0
- package/.torusguard/skills/torusguard/SKILL.md +37 -0
- package/.torusguard/skills/torusguard/bootstrap.py +158 -0
- package/.torusguard/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/.torusguard/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/.torusguard/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/.torusguard/skills/torusguard/references/client-code-exposure.md +55 -0
- package/.torusguard/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/.torusguard/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/.torusguard/skills/torusguard/references/django-security.md +43 -0
- package/.torusguard/skills/torusguard/references/drf-security.md +20 -0
- package/.torusguard/skills/torusguard/references/fastapi-security.md +20 -0
- package/.torusguard/skills/torusguard/references/flask-security.md +20 -0
- package/.torusguard/skills/torusguard/references/frontend-no-db.md +53 -0
- package/.torusguard/skills/torusguard/references/graphql-security.md +12 -0
- package/.torusguard/skills/torusguard/references/input-and-injection.md +51 -0
- package/.torusguard/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/.torusguard/skills/torusguard/references/platform-hardening.md +56 -0
- package/.torusguard/skills/torusguard/references/python-dependencies.md +16 -0
- package/.torusguard/skills/torusguard/references/python-security-overview.md +12 -0
- package/.torusguard/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/.torusguard/skills/torusguard/references/secrets-and-config.md +64 -0
- package/.torusguard/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/.torusguard/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/.torusguard/skills/torusguard/references/webhook-security.md +15 -0
- package/.torusguard/skills/torusguard/references/websocket-security.md +12 -0
- package/.torusguard/skills/torusguard-apply/SKILL.md +46 -0
- package/.torusguard/skills/torusguard-audit/SKILL.md +70 -0
- package/.torusguard/skills/torusguard-authorize/SKILL.md +47 -0
- package/.torusguard/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/.torusguard/skills/torusguard-full/SKILL.md +70 -0
- package/.torusguard/skills/torusguard-harden/SKILL.md +63 -0
- package/.torusguard/skills/torusguard-init/SKILL.md +52 -0
- package/.torusguard/skills/torusguard-recheck/SKILL.md +53 -0
- package/.torusguard/skills/torusguard-report/SKILL.md +54 -0
- package/.torusguard/skills/torusguard-status/SKILL.md +42 -0
- package/.torusguard/skills/torusguard-verify/SKILL.md +55 -0
- package/.torusguard/skills/torusguard-web-validate/SKILL.md +64 -0
- package/.torusguard/templates/audit-report.template.md +54 -0
- package/.torusguard/templates/authorization.template.md +34 -0
- package/.torusguard/templates/finding-card.template.md +32 -0
- package/.torusguard/templates/remediation-bundle.template.md +35 -0
- package/.torusguard/workflows/apply.md +95 -0
- package/.torusguard/workflows/audit.md +93 -0
- package/.torusguard/workflows/authorize.md +95 -0
- package/.torusguard/workflows/exploit-check.md +97 -0
- package/.torusguard/workflows/harden.md +93 -0
- package/.torusguard/workflows/init.md +95 -0
- package/.torusguard/workflows/recheck.md +95 -0
- package/.torusguard/workflows/report.md +95 -0
- package/.torusguard/workflows/status.md +95 -0
- package/.torusguard/workflows/verify.md +95 -0
- package/.torusguard/workflows/web-validate.md +95 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/bin/torusguard.js +110 -0
- package/install.py +98 -0
- package/package.json +48 -0
- package/skills/torusguard/SKILL.md +41 -0
- package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
- package/skills/torusguard/bootstrap.py +256 -0
- package/skills/torusguard/payload/.manifest.json +95 -0
- package/skills/torusguard/payload/ARCHITECTURE.md +168 -0
- package/skills/torusguard/payload/TORUSGUARD.md +145 -0
- package/skills/torusguard/payload/agents/auditor.md +41 -0
- package/skills/torusguard/payload/agents/profiler.md +49 -0
- package/skills/torusguard/payload/agents/remediator.md +41 -0
- package/skills/torusguard/payload/agents/reviewer.md +39 -0
- package/skills/torusguard/payload/agents/validator.md +46 -0
- package/skills/torusguard/payload/config/scope.json +24 -0
- package/skills/torusguard/payload/config/slash-commands.json +102 -0
- package/skills/torusguard/payload/config/torusguard.json +30 -0
- package/skills/torusguard/payload/references/django-security.md +43 -0
- package/skills/torusguard/payload/references/drf-security.md +20 -0
- package/skills/torusguard/payload/references/express-security.md +103 -0
- package/skills/torusguard/payload/references/fastapi-security.md +20 -0
- package/skills/torusguard/payload/references/firebase-security.md +78 -0
- package/skills/torusguard/payload/references/flask-security.md +20 -0
- package/skills/torusguard/payload/references/nextjs-security.md +96 -0
- package/skills/torusguard/payload/references/react-vite-security.md +97 -0
- package/skills/torusguard/payload/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/payload/references/supabase-security.md +84 -0
- package/skills/torusguard/payload/rules/README.md +62 -0
- package/skills/torusguard/payload/rules/TORUSGUARD.md +145 -0
- package/skills/torusguard/payload/rules/active/.gitkeep +0 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-001.md +20 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-002.md +20 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-003.md +19 -0
- package/skills/torusguard/payload/schemas/authorization.schema.json +81 -0
- package/skills/torusguard/payload/schemas/confidence.schema.json +72 -0
- package/skills/torusguard/payload/schemas/evidence.schema.json +66 -0
- package/skills/torusguard/payload/schemas/finding.schema.json +164 -0
- package/skills/torusguard/payload/schemas/provenance.schema.json +46 -0
- package/skills/torusguard/payload/schemas/remediation.schema.json +59 -0
- package/skills/torusguard/payload/schemas/retest.schema.json +53 -0
- package/skills/torusguard/payload/schemas/runtime-evidence.schema.json +72 -0
- package/skills/torusguard/payload/scripts/diff_guard.py +171 -0
- package/skills/torusguard/payload/scripts/finding_scorer.py +86 -0
- package/skills/torusguard/payload/scripts/manifest_builder.py +130 -0
- package/skills/torusguard/payload/scripts/monorepo_detector.py +164 -0
- package/skills/torusguard/payload/scripts/run_manager.py +89 -0
- package/skills/torusguard/payload/scripts/safety_gate.py +64 -0
- package/skills/torusguard/payload/scripts/sarif_exporter.py +116 -0
- package/skills/torusguard/payload/scripts/stack_detect.py +152 -0
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +37 -0
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +158 -0
- package/skills/torusguard/payload/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/skills/torusguard/payload/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/skills/torusguard/payload/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/skills/torusguard/payload/skills/torusguard/references/client-code-exposure.md +55 -0
- package/skills/torusguard/payload/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/skills/torusguard/payload/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/skills/torusguard/payload/skills/torusguard/references/django-security.md +43 -0
- package/skills/torusguard/payload/skills/torusguard/references/drf-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/fastapi-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/flask-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/frontend-no-db.md +53 -0
- package/skills/torusguard/payload/skills/torusguard/references/graphql-security.md +12 -0
- package/skills/torusguard/payload/skills/torusguard/references/input-and-injection.md +51 -0
- package/skills/torusguard/payload/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/skills/torusguard/payload/skills/torusguard/references/platform-hardening.md +56 -0
- package/skills/torusguard/payload/skills/torusguard/references/python-dependencies.md +16 -0
- package/skills/torusguard/payload/skills/torusguard/references/python-security-overview.md +12 -0
- package/skills/torusguard/payload/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/skills/torusguard/payload/skills/torusguard/references/secrets-and-config.md +64 -0
- package/skills/torusguard/payload/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/payload/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/skills/torusguard/payload/skills/torusguard/references/webhook-security.md +15 -0
- package/skills/torusguard/payload/skills/torusguard/references/websocket-security.md +12 -0
- package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +46 -0
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +70 -0
- package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +47 -0
- package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +70 -0
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +63 -0
- package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +52 -0
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +53 -0
- package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +54 -0
- package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +42 -0
- package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +55 -0
- package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +64 -0
- package/skills/torusguard/payload/templates/audit-report.template.md +54 -0
- package/skills/torusguard/payload/templates/authorization.template.md +34 -0
- package/skills/torusguard/payload/templates/finding-card.template.md +32 -0
- package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -0
- package/skills/torusguard/payload/workflows/apply.md +95 -0
- package/skills/torusguard/payload/workflows/audit.md +93 -0
- package/skills/torusguard/payload/workflows/authorize.md +95 -0
- package/skills/torusguard/payload/workflows/exploit-check.md +97 -0
- package/skills/torusguard/payload/workflows/harden.md +93 -0
- package/skills/torusguard/payload/workflows/init.md +95 -0
- package/skills/torusguard/payload/workflows/recheck.md +95 -0
- package/skills/torusguard/payload/workflows/report.md +95 -0
- package/skills/torusguard/payload/workflows/status.md +95 -0
- package/skills/torusguard/payload/workflows/verify.md +95 -0
- package/skills/torusguard/payload/workflows/web-validate.md +95 -0
- package/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/skills/torusguard/references/client-code-exposure.md +55 -0
- package/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/skills/torusguard/references/django-security.md +43 -0
- package/skills/torusguard/references/drf-security.md +20 -0
- package/skills/torusguard/references/fastapi-security.md +20 -0
- package/skills/torusguard/references/flask-security.md +20 -0
- package/skills/torusguard/references/frontend-no-db.md +53 -0
- package/skills/torusguard/references/graphql-security.md +12 -0
- package/skills/torusguard/references/input-and-injection.md +51 -0
- package/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/skills/torusguard/references/platform-hardening.md +56 -0
- package/skills/torusguard/references/python-dependencies.md +16 -0
- package/skills/torusguard/references/python-security-overview.md +12 -0
- package/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/skills/torusguard/references/secrets-and-config.md +64 -0
- package/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/skills/torusguard/references/webhook-security.md +15 -0
- package/skills/torusguard/references/websocket-security.md +12 -0
- package/skills/torusguard-apply/SKILL.md +46 -0
- package/skills/torusguard-audit/SKILL.md +70 -0
- package/skills/torusguard-authorize/SKILL.md +47 -0
- package/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/skills/torusguard-full/SKILL.md +70 -0
- package/skills/torusguard-harden/SKILL.md +63 -0
- package/skills/torusguard-init/SKILL.md +52 -0
- package/skills/torusguard-recheck/SKILL.md +53 -0
- package/skills/torusguard-report/SKILL.md +54 -0
- package/skills/torusguard-status/SKILL.md +42 -0
- package/skills/torusguard-verify/SKILL.md +55 -0
- package/skills/torusguard-web-validate/SKILL.md +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="TorusGuard.png" alt="TorusGuard Security Banner" width="480" style="max-width: 100%; height: auto; border-radius: 8px;">
|
|
3
|
+
|
|
4
|
+
# TorusGuard
|
|
5
|
+
|
|
6
|
+
**Security guardrails, governed remediation, and authorized runtime validation for AI-built web applications.**
|
|
7
|
+
|
|
8
|
+
[](https://github.com/githubmofo/TorusGuard/releases/latest)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://python.org)
|
|
11
|
+
[](schemas/)
|
|
12
|
+
[](.torusguard/.manifest.json)
|
|
13
|
+
[](docs/architecture/SECURITY_ARCHITECTURE.md)
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 💡 Executive Summary
|
|
19
|
+
|
|
20
|
+
AI coding assistants write code fast, but they often make dangerous security mistakes—like putting database keys in frontend code, skipping permission checks, or trusting raw input headers.
|
|
21
|
+
|
|
22
|
+
**TorusGuard** is an automated security co-pilot for AI-built applications. It runs directly inside your IDE (Cursor, Claude Code, Antigravity, VS Code) to:
|
|
23
|
+
- **Find real vulnerabilities:** Scan your codebase against 71 security rules across Python, TypeScript, and modern frameworks.
|
|
24
|
+
- **Confirm exploitability:** Verify whether weaknesses are truly reachable before creating noise.
|
|
25
|
+
- **Patch safely:** Generate and apply minimal, surgical fixes that resolve flaws without breaking existing functionality.
|
|
26
|
+
|
|
27
|
+
### 🌐 The Core Principle: The Browser-Code Truth
|
|
28
|
+
> **"If the browser receives it, users can inspect it."**
|
|
29
|
+
> DevTools, Inspect Element, and network breakpoints cannot be blocked. TorusGuard enforces that database credentials, sensitive business logic, and authorization checks must always live safely on the server.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🔄 The 7-Stage Closed-Loop Finding Lifecycle
|
|
34
|
+
|
|
35
|
+
Every candidate vulnerability transitions through an auditable, deterministic state machine:
|
|
36
|
+
|
|
37
|
+
```mermaid
|
|
38
|
+
flowchart LR
|
|
39
|
+
A["1. Detect<br><code>/torusguard audit</code>"] --> B["2. Classify<br>AST Line Hashing"]
|
|
40
|
+
B --> C["3. Verify<br><code>verify / web-validate</code>"]
|
|
41
|
+
C --> D["4. Remediate<br><code>/torusguard harden</code>"]
|
|
42
|
+
D --> E["5. Apply<br><code>/torusguard apply</code>"]
|
|
43
|
+
E --> F["6. Recheck<br><code>/torusguard recheck</code>"]
|
|
44
|
+
F --> G["7. Report<br><code>/torusguard report</code>"]
|
|
45
|
+
|
|
46
|
+
style A fill:#1e293b,stroke:#3b82f6,stroke-width:2px,color:#fff
|
|
47
|
+
style B fill:#1e293b,stroke:#6366f1,stroke-width:2px,color:#fff
|
|
48
|
+
style C fill:#1e293b,stroke:#8b5cf6,stroke-width:2px,color:#fff
|
|
49
|
+
style D fill:#1e293b,stroke:#ec4899,stroke-width:2px,color:#fff
|
|
50
|
+
style E fill:#1e293b,stroke:#f59e0b,stroke-width:2px,color:#fff
|
|
51
|
+
style F fill:#1e293b,stroke:#10b981,stroke-width:2px,color:#fff
|
|
52
|
+
style G fill:#1e293b,stroke:#06b6d4,stroke-width:2px,color:#fff
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
1. **Detect (`/torusguard audit`):** Scans source code, manifests, and configurations against 64 canonical security rules.
|
|
56
|
+
2. **Classify:** Computes line-shift invariant `primaryLocationLineHash` fingerprints and collapses repeated alerts into systemic root-cause clusters.
|
|
57
|
+
3. **Verify (`/torusguard verify` / `web-validate` / `exploit-check`):** Validates evidence quality across a 5-factor rubric and executes bounded HTTP/browser probes.
|
|
58
|
+
4. **Remediate (`/torusguard harden`):** Generates self-contained 4-artifact Remediation Bundles with framework-idiomatic Before/After fixes.
|
|
59
|
+
5. **Apply (`/torusguard apply`):** Employs the **Ponytail engine** to apply surgical, minimal patches governed by strict line churn limits ($\le 35$ additions, $\le 25$ deletions).
|
|
60
|
+
6. **Recheck (`/torusguard recheck`):** Scopes differential re-audits strictly to modified files, asserting `Confirmed Fixed` or detecting regressions.
|
|
61
|
+
7. **Report & Archive (`/torusguard report`):** Emits signed executive markdown reports and exports OASIS-compliant SARIF v2.1.0 logs for CI/CD.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## ⚡ The TorusGuard Command Engine
|
|
66
|
+
|
|
67
|
+
TorusGuard operates on a high-performance **Two-Tier Command Engine** designed for AI-assisted development environments. It unifies interactive slash commands with specialized domain knowledge while preserving maximum context window capacity:
|
|
68
|
+
|
|
69
|
+
1. **Interactive Workflows (`.torusguard/workflows/<cmd>.md`):**
|
|
70
|
+
Structured execution playbooks triggered by slash commands (e.g., `/torusguard audit`). Each workflow enforces pre-flight context validation, provides situational decision matrices, executes deterministic CLI commands, and enforces strict failure recovery rules.
|
|
71
|
+
2. **Specialist Skills (`.torusguard/skills/torusguard-<cmd>/SKILL.md`):**
|
|
72
|
+
Focused domain manuals that are lazy-loaded on demand. Instead of polluting the AI's context with a monolithic security handbook, only the exact AST sinks, non-destructive canaries, and confidence scoring formulas relevant to the active command are loaded into memory.
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
User / AI types Slash Command (e.g. /torusguard audit)
|
|
76
|
+
│
|
|
77
|
+
▼
|
|
78
|
+
[.torusguard/workflows/audit.md] ← Interactive Execution Playbook
|
|
79
|
+
├── 1. Formal Metadata & Role Contract (agent, required-skills, bound scripts)
|
|
80
|
+
├── 2. Mandatory Pre-Flight Context Inspection (disk state, authorization TTL)
|
|
81
|
+
├── 3. "When to Use" Decision Table (situational triggers)
|
|
82
|
+
├── 4. Deterministic Phase-by-Phase CLI Invocations
|
|
83
|
+
├── 5. Failure Recovery & Cascade Rules (3-retry limit, HALT vs CONTINUE)
|
|
84
|
+
├── 6. Strict Safety & Hallucination Boundaries
|
|
85
|
+
└── 7. Standardized Output Cards & Next Step Routing
|
|
86
|
+
│
|
|
87
|
+
▼ Lazy-Loads Matching Specialist Skill
|
|
88
|
+
[.torusguard/skills/torusguard-audit/SKILL.md] ← Focused Domain Manual
|
|
89
|
+
├── 1. Framework AST Sinks & Regex Indicators (Python & TypeScript)
|
|
90
|
+
├── 2. Root-Cause Clustering Algorithms
|
|
91
|
+
├── 3. 5-Factor 0–100 Confidence Scoring Rubric
|
|
92
|
+
└── 4. Non-Destructive Probe Safety Boundaries
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🚀 Quick Start
|
|
98
|
+
|
|
99
|
+
### 1. Installation into Your Project
|
|
100
|
+
|
|
101
|
+
TorusGuard offers two clean, decoupled adoption tracks designed for different developer workflows:
|
|
102
|
+
|
|
103
|
+
#### ⚡ Track 1: Universal AI Agent Skill (Zero Local Footprint)
|
|
104
|
+
Install directly into any AI coding assistant (Kimi, Antigravity, VS Code Copilot, Cursor, Claude Code, Windsurf, Cline):
|
|
105
|
+
```bash
|
|
106
|
+
npx skills add https://github.com/githubmofo/TorusGuard --skill "torusguard"
|
|
107
|
+
```
|
|
108
|
+
* **Footprint:** Pure in-memory AI reasoning. Zero local `.torusguard/` directory required.
|
|
109
|
+
* **Commands:** Adds a single, unified `/torusguard` slash command.
|
|
110
|
+
* **Use Case:** Instant security reviews, OWASP AST guidance, and Ponytail Protocol patch boundaries in any chat.
|
|
111
|
+
|
|
112
|
+
#### 🛡️ Track 2: Production NPM Package (Full Workspace Governance)
|
|
113
|
+
Scaffold the complete `.torusguard/` directory and unlock all individual slash commands:
|
|
114
|
+
```bash
|
|
115
|
+
# Direct runner:
|
|
116
|
+
npx torusguard init
|
|
117
|
+
|
|
118
|
+
# Or install locally in your project:
|
|
119
|
+
npm install -D torusguard
|
|
120
|
+
```
|
|
121
|
+
* **Footprint:** Full `.torusguard/` workspace (configuration, rules, schemas, offline Python scripts, runs history).
|
|
122
|
+
* **Commands:** Unlocks the entire suite of 11 individual slash commands (`/torusguard-audit`, `/torusguard-harden`, `/torusguard-apply`, `/torusguard-verify`, etc.) in Antigravity, Cursor, and Claude Code.
|
|
123
|
+
* **Use Case:** Deep automated audits, SARIF exports for GitHub Code Scanning, and deterministic local patch governance.
|
|
124
|
+
|
|
125
|
+
#### 🐍 Standalone Python Installer (Alternative)
|
|
126
|
+
```bash
|
|
127
|
+
python install.py
|
|
128
|
+
# Or remote one-liner:
|
|
129
|
+
curl -sSL https://raw.githubusercontent.com/githubmofo/TorusGuard/main/install.py | python
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### 2. Core Commands
|
|
135
|
+
|
|
136
|
+
| Command | What It Does | When to Use | Changes Code? |
|
|
137
|
+
|---|---|---|:---:|
|
|
138
|
+
| `/torusguard init` | Sets up TorusGuard, detects your framework, and enables matching rules. | First-time setup on any project | No |
|
|
139
|
+
| `/torusguard authorize` | Sets approved target domains, allowed URLs, and scan limits for safe testing. | Before testing live web/API routes | No |
|
|
140
|
+
| `/torusguard audit` | Scans source code for security flaws and groups repeated issues by root cause. | Regular development & PR reviews | No |
|
|
141
|
+
| `/torusguard verify` | Validates code paths and scores findings from 0–100 to eliminate false alarms. | Triaging & prioritizing audit findings | No |
|
|
142
|
+
| `/torusguard web-validate` | Sends safe, non-destructive HTTP requests to test if endpoints leak sensitive data. | Checking a local or staging server | No |
|
|
143
|
+
| `/torusguard exploit-check` | Tests if high-risk vulnerabilities (like CSRF or IDOR) are actually exploitable. | Confirming flaws before writing fixes | No |
|
|
144
|
+
| `/torusguard harden` | Prepares a step-by-step fix plan and surgical diff within safe line-change limits. | Planning a fix for an identified issue | No |
|
|
145
|
+
| `/torusguard apply` | Applies the minimal patch to your code with an automatic rollback backup. | Applying an approved code fix | Yes |
|
|
146
|
+
| `/torusguard recheck` | Re-scans only the modified lines to verify the fix works with zero regressions. | Right after applying any fix | No |
|
|
147
|
+
| `/torusguard report` | Generates an executive summary and exports SARIF data for GitHub security tabs. | CI/CD builds and release audits | No |
|
|
148
|
+
| `/torusguard status` | Shows current security posture, active rules, and recent run history. | Checking project security health | No |
|
|
149
|
+
| `/torusguard full` | Runs the full end-to-end security cycle (audit → verify → fix → recheck). | Complete repository security pass | Yes |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 🎯 Specialist Agents & Authority Separation
|
|
154
|
+
|
|
155
|
+
To eliminate AI confirmation bias, security responsibilities are divided across 5 formal roles:
|
|
156
|
+
|
|
157
|
+
```mermaid
|
|
158
|
+
flowchart TD
|
|
159
|
+
subgraph Discovery
|
|
160
|
+
P["🔍 Profiler Agent<br><code>profiler.md</code>"]
|
|
161
|
+
end
|
|
162
|
+
subgraph Detection
|
|
163
|
+
A["🔎 Auditor Agent<br><code>auditor.md</code>"]
|
|
164
|
+
end
|
|
165
|
+
subgraph Validation
|
|
166
|
+
V["🧪 Validator Agent<br><code>validator.md</code>"]
|
|
167
|
+
end
|
|
168
|
+
subgraph Remediation
|
|
169
|
+
R["🛠️ Remediator Agent<br><code>remediator.md</code>"]
|
|
170
|
+
end
|
|
171
|
+
subgraph Governance
|
|
172
|
+
Rev["📋 Reviewer Agent<br><code>reviewer.md</code>"]
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
P -->|Framework Stack & Rules| A
|
|
176
|
+
A -->|Unscoped AST Sinks & Clusters| V
|
|
177
|
+
V -->|Confirmed Exploit Evidence| R
|
|
178
|
+
R -->|Pre-Apply Snapshot & Diff| Rev
|
|
179
|
+
Rev -->|Regression Audit & SARIF Sign-Off| Complete["🏆 Signed Release Report"]
|
|
180
|
+
|
|
181
|
+
style P fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff
|
|
182
|
+
style A fill:#0f172a,stroke:#818cf8,stroke-width:2px,color:#fff
|
|
183
|
+
style V fill:#0f172a,stroke:#c084fc,stroke-width:2px,color:#fff
|
|
184
|
+
style R fill:#0f172a,stroke:#f472b6,stroke-width:2px,color:#fff
|
|
185
|
+
style Rev fill:#0f172a,stroke:#34d399,stroke-width:2px,color:#fff
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
1. **Profiler (`profiler.md`)**: Inspects repository manifests, maps route structures, and activates tailored rules. *Authority: Read-only.*
|
|
189
|
+
2. **Auditor (`auditor.md`)**: Analyzes ASTs, calculates invariant line hashes, and groups systemic clusters. *Authority: Read-only.*
|
|
190
|
+
3. **Validator (`validator.md`)**: Evaluates evidence sufficiency, probes live routes within `scope.json`, and confirms exploitability. *Authority: Bounded network read-only.*
|
|
191
|
+
4. **Remediator (`remediator.md`)**: Formulates minimal unified diffs under Ponytail Protocol limits. *Authority: Requires Human Gate approval for disk writes.*
|
|
192
|
+
5. **Reviewer (`reviewer.md`)**: Differentially re-scans modified lines, asserts closure, detects regressions, and exports SARIF logs. *Authority: Independent audit verification.*
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 📊 Objective 0–100 Confidence Scoring Rubric
|
|
197
|
+
|
|
198
|
+
TorusGuard scores finding confidence using an objective 5-factor mathematical model (Max: 100 points):
|
|
199
|
+
|
|
200
|
+
| Dimension | Max Pts | Evaluation Criteria |
|
|
201
|
+
| :--- | :---: | :--- |
|
|
202
|
+
| **1. Evidence Quality** | **35** | **35 pts**: Exact AST source match with untrusted data flow into sensitive sink.<br>**20 pts**: Regex/pattern heuristic match with confirmed code presence.<br>**10 pts**: Indirect indicator (outdated package or suspicious import). |
|
|
203
|
+
| **2. Reproduction Success** | **25** | **25 pts**: Deterministic unit test or runtime trace reproduces the flaw.<br>**15 pts**: Partial trace or simulated execution path confirmed.<br>**0 pts**: Purely static hypothesis without reproduction. |
|
|
204
|
+
| **3. Independent Confirmations** | **15** | **15 pts**: Flaw pattern corroborated across 3+ independent source files.<br>**10 pts**: Flaw pattern corroborated across 2 independent files.<br>**5 pts**: Single isolated occurrence. |
|
|
205
|
+
| **4. Environmental Clarity** | **15** | **15 pts**: Direct, clearly mapped framework route with explicit controller.<br>**8 pts**: Minor middleware indirection; deployment context partially clear.<br>**0 pts**: Dynamic routing, custom lambdas, or unknown gateway filters. |
|
|
206
|
+
| **5. Manual Review Status** | **10** | **10 pts**: Security engineer has explicitly reviewed and verified finding.<br>**5 pts**: Agent consensus / secondary review completed.<br>**0 pts**: Automated first-pass check only. |
|
|
207
|
+
|
|
208
|
+
### Confidence Classification Bands
|
|
209
|
+
- **`90–100` (`Confirmed`)**: Indisputable proof with code citation or deterministic trace.
|
|
210
|
+
- **`70–89` (`High Confidence`)**: Strong direct indicators; prioritized remediation.
|
|
211
|
+
- **`50–69` (`Medium Confidence`)**: Probable flaw; runtime confirmation recommended.
|
|
212
|
+
- **`< 50` (`Needs Review`)**: Architectural ambiguity or potential delegated control.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## ✂️ The Ponytail Protocol (Governed Patch Limits)
|
|
217
|
+
|
|
218
|
+
To prevent code bloat, hallucinated rewrites, and accidental regressions, TorusGuard enforces strict line churn limits:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
┌────────────────────────────────────────────────────────┐
|
|
222
|
+
│ PONYTAIL PROTOCOL BOUNDS │
|
|
223
|
+
├────────────────────────────────────────────────────────┤
|
|
224
|
+
│ • Additions: <= 35 lines per bundle │
|
|
225
|
+
│ • Deletions: <= 25 lines per bundle │
|
|
226
|
+
│ • Zero full-file rewrites │
|
|
227
|
+
│ • Mandatory pre-apply rollback backup in pre_apply/ │
|
|
228
|
+
│ • Preserve existing error handling and public APIs │
|
|
229
|
+
└────────────────────────────────────────────────────────┘
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Any fix exceeding these bounds is partitioned into sequential sub-bundles or flagged as `Requires Manual Architectural Refactor`.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 🧪 Comprehensive Automated Validation Suite
|
|
237
|
+
|
|
238
|
+
TorusGuard is hardened by **9 automated test suites** executing **381 automated test assertions with a 100% pass rate**:
|
|
239
|
+
|
|
240
|
+
| Suite Name | File | Checks | Status |
|
|
241
|
+
| :--- | :--- | :---: | :---: |
|
|
242
|
+
| **Workflows & Skills Suite** | `harness/validate_v0_9_2_workflows_and_skills.py` | 35 | **PASS (100%)** |
|
|
243
|
+
| **Manifest Integrity Verifier** | `.torusguard/scripts/manifest_builder.py --check` | 88 | **PASS (100%)** |
|
|
244
|
+
| **Installer Simulation Suite** | `harness/validate_v0_9_1_installer.py` | 14 | **PASS (100%)** |
|
|
245
|
+
| **Granular Skills Suite** | `harness/validate_v0_9_0_skills.py` | 53 | **PASS (100%)** |
|
|
246
|
+
| **Core Validation Harness** | `harness/runner.py` | 75 | **PASS (100%)** |
|
|
247
|
+
| **Senior QA Runtime Suite** | `harness/validate_v0_7_0_runtime.py` | 67 | **PASS (100%)** |
|
|
248
|
+
| **v0.8.0 Part 1 Foundation** | `harness/validate_v0_8_0_part1.py` | 11 | **PASS (100%)** |
|
|
249
|
+
| **v0.8.0 Part 2 Workflows & Agents** | `harness/validate_v0_8_0_part2.py` | 20 | **PASS (100%)** |
|
|
250
|
+
| **v0.8.0 Part 3 Scripts & References** | `harness/validate_v0_8_0_part3.py` | 18 | **PASS (100%)** |
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 🛡️ Supported Stacks & Frameworks
|
|
255
|
+
|
|
256
|
+
### 🐍 Python Ecosystem
|
|
257
|
+
- **[Django Guide](.torusguard/references/django-security.md):** Settings, CSRF, ORM queries, ModelForms, object ownership, and async coroutines (`aget()`).
|
|
258
|
+
- **[Django REST Framework Guide](.torusguard/references/drf-security.md):** Default permissions, ViewSets, serializers, throttles, and pagination.
|
|
259
|
+
- **[FastAPI Guide](.torusguard/references/fastapi-security.md):** Pydantic v2 schemas, `Annotated` dependency injection, SSRF boundaries, and HMAC webhooks.
|
|
260
|
+
- **[Flask Guide](.torusguard/references/flask-security.md):** Factory patterns, secure session cookies, `CSRFProtect`, and path traversal storage limits.
|
|
261
|
+
- **[SQLAlchemy Guide](.torusguard/references/sqlalchemy-security.md):** Bound query parameters, 2.0 `select()` statements, and multi-tenant isolation.
|
|
262
|
+
|
|
263
|
+
### 🌐 JavaScript & TypeScript Ecosystem
|
|
264
|
+
- **[React + Vite Guide](.torusguard/references/react-vite-security.md):** Frontend env variable boundaries, build artifact leakage, and source maps.
|
|
265
|
+
- **[Next.js Guide](.torusguard/references/nextjs-security.md):** App Router / Pages Router security, Server Components, and Server Action authorization (`"use server"`).
|
|
266
|
+
- **[Express Guide](.torusguard/references/express-security.md):** Helmet middleware, parameter validation, rate limiting, and CORS headers.
|
|
267
|
+
- **[Supabase Guide](.torusguard/references/supabase-security.md):** Row-Level Security (RLS), service-role key isolation, and secure client queries.
|
|
268
|
+
- **[Firebase Guide](.torusguard/references/firebase-security.md):** Firestore Security Rules, client SDK boundaries, and privileged admin tasks.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## 📂 Run Folder System (`RunManager`)
|
|
273
|
+
|
|
274
|
+
Every execution is completely self-contained within an isolated directory (`.torusguard/runs/<run-id>/`):
|
|
275
|
+
|
|
276
|
+
```text
|
|
277
|
+
.torusguard/runs/run-20260902-120000-audit/
|
|
278
|
+
├── manifest.json # Execution metadata, git commit hash, and summary counts
|
|
279
|
+
├── summary.md # Executive summary and root-cause cluster matrix
|
|
280
|
+
├── findings.md # Detailed finding cards with code excerpts and remediation
|
|
281
|
+
├── web-validation.md # HTTP interaction log and endpoint status codes
|
|
282
|
+
├── requests.json # Redacted request payloads (tokens/passwords masked)
|
|
283
|
+
├── responses.json # Redacted response payloads
|
|
284
|
+
├── session-notes.md # Active session cookies and tenant context
|
|
285
|
+
├── replay.json # Deterministic replay trace for regression verification
|
|
286
|
+
├── results.sarif # OASIS SARIF v2.1.0 export for CI/CD & GitHub Code Scanning
|
|
287
|
+
└── patches/ # Formulated remediation bundles (diffs & pre-apply snapshots)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 📋 Project Documentation & Governance
|
|
293
|
+
|
|
294
|
+
| Document | Purpose |
|
|
295
|
+
|---|---|
|
|
296
|
+
| 🛡️ **[Security Policy](SECURITY.md)** | Responsible disclosure guidelines, supported versions, and release gate criteria |
|
|
297
|
+
| 👥 **[Maintainer Guide](MAINTAINERS.md)** | Account security, branch protections, supply-chain hygiene, and cryptographic release signing |
|
|
298
|
+
| 🏗️ **[System Architecture](.torusguard/ARCHITECTURE.md)** | Lifecycle flowcharts, authority separation, scoring rubric, and directory topology |
|
|
299
|
+
| 🗺️ **[Development Roadmap](docs/roadmap.md)** | Past releases, active milestones, and future horizons |
|
|
300
|
+
| 📝 **[Changelog](CHANGELOG.md)** | Complete release history following Keep a Changelog |
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## 🚫 What TorusGuard Deliberately Is Not
|
|
305
|
+
|
|
306
|
+
To maintain technical honesty and safety:
|
|
307
|
+
- **Not a weaponized offensive pentest tool:** TorusGuard strictly avoids brute-forcing, denial-of-service, memory corruption, and autonomous lateral movement.
|
|
308
|
+
- **Not an unbounded vulnerability scanner:** Probes are bounded, single-step assertions against authorized endpoints with strict request budgets.
|
|
309
|
+
- **Not client-side DRM:** Browser-delivered JavaScript cannot be hidden from DevTools; security must reside on the backend.
|
|
310
|
+
- **Not an "unhackable" guarantee:** Security is continuous; TorusGuard provides structured guardrails, not absolute immunity.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 👥 Author & Community
|
|
315
|
+
|
|
316
|
+
- **Creator & Lead Maintainer:** **Jenish Lad** ([@githubmofo](https://github.com/githubmofo))
|
|
317
|
+
- **Contributing:** Please review [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before opening a pull request.
|
|
318
|
+
- **Security Inquiries:** Please follow our [Security Policy](SECURITY.md) for private vulnerability reporting.
|
|
319
|
+
- **License:** Open source under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TorusGuard CLI Runner (NPM Distribution)
|
|
5
|
+
* Provides zero-dependency command orchestration for TorusGuard governance.
|
|
6
|
+
* Adheres to Ponytail principles: concise, surgical, zero fluff.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { spawnSync } = require('child_process');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const command = args[0] || 'init';
|
|
15
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
|
|
18
|
+
// Detect available Python binary (python or python3)
|
|
19
|
+
let pythonCmd = 'python';
|
|
20
|
+
try {
|
|
21
|
+
const check = spawnSync('python', ['--version'], { encoding: 'utf-8' });
|
|
22
|
+
if (check.status !== 0) {
|
|
23
|
+
const check3 = spawnSync('python3', ['--version'], { encoding: 'utf-8' });
|
|
24
|
+
if (check3.status === 0) {
|
|
25
|
+
pythonCmd = 'python3';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
try {
|
|
30
|
+
const check3 = spawnSync('python3', ['--version'], { encoding: 'utf-8' });
|
|
31
|
+
if (check3.status === 0) {
|
|
32
|
+
pythonCmd = 'python3';
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function printHelp() {
|
|
38
|
+
console.log(`
|
|
39
|
+
================================================================================
|
|
40
|
+
TORUSGUARD NPM PACKAGE — CLI COMMANDS (v0.9.2)
|
|
41
|
+
================================================================================
|
|
42
|
+
Usage:
|
|
43
|
+
npx torusguard [command] [options]
|
|
44
|
+
|
|
45
|
+
Commands:
|
|
46
|
+
init Scaffold .torusguard/ and register all 11 individual slash commands
|
|
47
|
+
audit Run security audit against target workspace
|
|
48
|
+
status Display active security posture and configuration
|
|
49
|
+
report Export SARIF security report
|
|
50
|
+
help Display this help message
|
|
51
|
+
|
|
52
|
+
Options:
|
|
53
|
+
--force Overwrite existing configuration and re-scaffold templates
|
|
54
|
+
--target <d> Target project directory (default: current working directory)
|
|
55
|
+
================================================================================
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (command === 'help' || command === '--help' || command === '-h') {
|
|
60
|
+
printHelp();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (command === 'status') {
|
|
65
|
+
const cfgPath = path.join(cwd, '.torusguard', 'config', 'torusguard.json');
|
|
66
|
+
if (fs.existsSync(cfgPath)) {
|
|
67
|
+
try {
|
|
68
|
+
const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf-8'));
|
|
69
|
+
console.log('================================================================================');
|
|
70
|
+
console.log('TORUSGUARD ACTIVE POSTURE STATUS');
|
|
71
|
+
console.log('================================================================================');
|
|
72
|
+
console.log(`Version: ${cfg.version || '0.9.2'}`);
|
|
73
|
+
console.log(`Product: ${cfg.product || 'TorusGuard'}`);
|
|
74
|
+
console.log(`Severity Threshold: ${cfg.severity_threshold || 'medium'}`);
|
|
75
|
+
console.log(`Runs Directory: ${cfg.runs_dir || '.torusguard/runs'}`);
|
|
76
|
+
console.log(`Detected Language: ${cfg.detected_stack?.language || 'auto'}`);
|
|
77
|
+
console.log(`Detected Framework: ${cfg.detected_stack?.framework || 'auto'}`);
|
|
78
|
+
console.log('================================================================================');
|
|
79
|
+
process.exit(0);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
// Fallback to python runner
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
console.log('[INFO] .torusguard workspace not found in current directory.');
|
|
85
|
+
console.log('Run "npx torusguard init" to scaffold the workspace.');
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Locate bootstrap / runner scripts
|
|
91
|
+
const localBootstrap = path.join(rootDir, 'skills', 'torusguard', 'bootstrap.py');
|
|
92
|
+
const localInstall = path.join(rootDir, 'install.py');
|
|
93
|
+
const scriptToRun = fs.existsSync(localBootstrap) ? localBootstrap : localInstall;
|
|
94
|
+
|
|
95
|
+
// Pass flags: when init is executed, include --full-commands to unlock all slash commands
|
|
96
|
+
let scriptArgs = [scriptToRun];
|
|
97
|
+
if (command === 'init') {
|
|
98
|
+
scriptArgs.push('--full-commands');
|
|
99
|
+
// Forward remaining arguments
|
|
100
|
+
scriptArgs.push(...args.slice(1));
|
|
101
|
+
} else {
|
|
102
|
+
scriptArgs.push(...args);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const proc = spawnSync(pythonCmd, scriptArgs, {
|
|
106
|
+
stdio: 'inherit',
|
|
107
|
+
cwd: cwd,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
process.exit(proc.status !== null ? proc.status : 0);
|
package/install.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TorusGuard Standalone Zero-Dependency Installer
|
|
4
|
+
Allows direct terminal setup via:
|
|
5
|
+
python install.py [--target /path/to/project]
|
|
6
|
+
or:
|
|
7
|
+
curl -sSL https://raw.githubusercontent.com/githubmofo/TorusGuard/main/install.py | python
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import shutil
|
|
13
|
+
import json
|
|
14
|
+
import argparse
|
|
15
|
+
import urllib.request
|
|
16
|
+
import tempfile
|
|
17
|
+
import zipfile
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
REPO_URL = "https://github.com/githubmofo/TorusGuard"
|
|
21
|
+
ARCHIVE_URL = "https://github.com/githubmofo/TorusGuard/archive/refs/heads/main.zip"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def install_torusguard(target_dir=None, force=False):
|
|
25
|
+
target_root = Path(target_dir or os.getcwd()).resolve()
|
|
26
|
+
torusguard_target = target_root / ".torusguard"
|
|
27
|
+
here = Path(__file__).resolve().parent
|
|
28
|
+
|
|
29
|
+
print("================================================================================")
|
|
30
|
+
print("TORUSGUARD ZERO-DEPENDENCY INSTALLER")
|
|
31
|
+
print("================================================================================")
|
|
32
|
+
print(f"Target Directory: {target_root}")
|
|
33
|
+
print(f"Destination: {torusguard_target}")
|
|
34
|
+
|
|
35
|
+
if torusguard_target.exists() and not force:
|
|
36
|
+
print(f"\n[INFO] .torusguard workspace already exists at {torusguard_target}")
|
|
37
|
+
print("Use --force to re-scaffold.")
|
|
38
|
+
return True
|
|
39
|
+
|
|
40
|
+
# Check if we are running inside the TorusGuard repository clone
|
|
41
|
+
local_source = here / ".torusguard"
|
|
42
|
+
bundled_payload = here / "skills" / "torusguard" / "payload"
|
|
43
|
+
bootstrap_script = here / "skills" / "torusguard" / "bootstrap.py"
|
|
44
|
+
|
|
45
|
+
if bootstrap_script.exists():
|
|
46
|
+
import importlib.util
|
|
47
|
+
spec = importlib.util.spec_from_file_location("bootstrap", str(bootstrap_script))
|
|
48
|
+
bootstrap_mod = importlib.util.module_from_spec(spec)
|
|
49
|
+
spec.loader.exec_module(bootstrap_mod)
|
|
50
|
+
return bootstrap_mod.scaffold_workspace(target_root=target_root, force=force)
|
|
51
|
+
|
|
52
|
+
# Standalone execution (download archive from GitHub)
|
|
53
|
+
print("\nDownloading TorusGuard workspace archive from GitHub...")
|
|
54
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
55
|
+
tmp_zip = Path(tmpdir) / "torusguard.zip"
|
|
56
|
+
try:
|
|
57
|
+
req = urllib.request.Request(ARCHIVE_URL, headers={"User-Agent": "TorusGuard-Installer/0.9.1"})
|
|
58
|
+
with urllib.request.urlopen(req) as resp, open(tmp_zip, "wb") as out_f:
|
|
59
|
+
shutil.copyfileobj(resp, out_f)
|
|
60
|
+
print(" [SUCCESS] Archive downloaded successfully.")
|
|
61
|
+
|
|
62
|
+
with zipfile.ZipFile(tmp_zip, "r") as zip_ref:
|
|
63
|
+
zip_ref.extractall(tmpdir)
|
|
64
|
+
|
|
65
|
+
extracted_root = Path(tmpdir) / "TorusGuard-main"
|
|
66
|
+
remote_source = extracted_root / ".torusguard"
|
|
67
|
+
|
|
68
|
+
if remote_source.is_dir():
|
|
69
|
+
if torusguard_target.exists() and force:
|
|
70
|
+
shutil.rmtree(torusguard_target)
|
|
71
|
+
shutil.copytree(remote_source, torusguard_target, ignore=shutil.ignore_patterns("runs", "*.pyc", "__pycache__"))
|
|
72
|
+
print(f" [SUCCESS] Scaffolding copied into {torusguard_target}")
|
|
73
|
+
else:
|
|
74
|
+
print(" [ERROR] .torusguard folder not found in extracted archive.")
|
|
75
|
+
return False
|
|
76
|
+
|
|
77
|
+
except Exception as e:
|
|
78
|
+
print(f" [ERROR] Installation failed: {e}")
|
|
79
|
+
return False
|
|
80
|
+
|
|
81
|
+
print("\n================================================================================")
|
|
82
|
+
print("[SUCCESS] TORUSGUARD INSTALLED SUCCESSFULLY!")
|
|
83
|
+
print("================================================================================")
|
|
84
|
+
print("Next steps:")
|
|
85
|
+
print(" 1. Open your AI IDE (Antigravity, Cursor, Claude Code, Cline).")
|
|
86
|
+
print(" 2. Run `/torusguard audit` to scan your project.")
|
|
87
|
+
print("================================================================================")
|
|
88
|
+
return True
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
parser = argparse.ArgumentParser(description="TorusGuard Standalone Installer")
|
|
93
|
+
parser.add_argument("--target", type=str, help="Target project root directory")
|
|
94
|
+
parser.add_argument("--force", action="store_true", help="Force overwrite existing workspace")
|
|
95
|
+
args = parser.parse_args()
|
|
96
|
+
|
|
97
|
+
success = install_torusguard(target_dir=args.target, force=args.force)
|
|
98
|
+
sys.exit(0 if success else 1)
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "torusguard",
|
|
3
|
+
"version": "0.9.2",
|
|
4
|
+
"description": "Security guardrails, governed remediation, and authorized runtime validation for AI-built web applications.",
|
|
5
|
+
"main": "bin/torusguard.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"torusguard": "./bin/torusguard.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
".torusguard/",
|
|
12
|
+
"skills/",
|
|
13
|
+
"install.py",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "python harness/runner.py",
|
|
19
|
+
"init": "node bin/torusguard.js init",
|
|
20
|
+
"audit": "node bin/torusguard.js audit",
|
|
21
|
+
"status": "node bin/torusguard.js status"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"security",
|
|
25
|
+
"agentic-workflows",
|
|
26
|
+
"sarif",
|
|
27
|
+
"owasp",
|
|
28
|
+
"ast-analysis",
|
|
29
|
+
"devsecops",
|
|
30
|
+
"ai-safety",
|
|
31
|
+
"antigravity",
|
|
32
|
+
"cursor",
|
|
33
|
+
"claude-code"
|
|
34
|
+
],
|
|
35
|
+
"author": "Jenish Lad <githubmofo>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/githubmofo/TorusGuard.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/githubmofo/TorusGuard/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/githubmofo/TorusGuard#readme",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard
|
|
3
|
+
description: Security guardrails, governed remediation, and authorized runtime validation for AI-built web applications across Python and TypeScript.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TorusGuard Master Security Router
|
|
8
|
+
|
|
9
|
+
**Principle:** If the browser receives it, users can inspect it. Keep secrets, database queries, and authorization strictly on trusted server-side code.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ⚡ Workspace Bootstrap Check
|
|
14
|
+
1. **If `.torusguard/` exists on disk:** Full governance active. Route slash commands to local specialist workflows below.
|
|
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
|
+
- Server-side auth & tenant scoping (`.filter(tenant=...)`).
|
|
17
|
+
- Zero client-side secrets (`SUPABASE_SERVICE_ROLE_KEY`, live API keys).
|
|
18
|
+
- Ponytail Protocol patch limits ($\le 35$ additions, $\le 25$ deletions).
|
|
19
|
+
- *Upgrade:* Run `npx torusguard init` to unlock local `.torusguard/` run tracking & individual commands.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Specialist Skill Routing (Lazy Loading)
|
|
24
|
+
Load **only** the designated sub-skill on demand to preserve the 1,000–1,500 token budget:
|
|
25
|
+
|
|
26
|
+
| Command | Specialist Skill | Agent |
|
|
27
|
+
| :--- | :--- | :--- |
|
|
28
|
+
| `/torusguard init` | `skills/torusguard-init/SKILL.md` | `profiler` |
|
|
29
|
+
| `/torusguard authorize` | `skills/torusguard-authorize/SKILL.md` | `reviewer` |
|
|
30
|
+
| `/torusguard audit` | `skills/torusguard-audit/SKILL.md` | `auditor` |
|
|
31
|
+
| `/torusguard verify` | `skills/torusguard-verify/SKILL.md` | `validator` |
|
|
32
|
+
| `/torusguard web-validate` | `skills/torusguard-web-validate/SKILL.md` | `validator` |
|
|
33
|
+
| `/torusguard exploit-check` | `skills/torusguard-exploit-check/SKILL.md` | `validator` |
|
|
34
|
+
| `/torusguard harden` | `skills/torusguard-harden/SKILL.md` | `remediator` |
|
|
35
|
+
| `/torusguard apply` | `skills/torusguard-apply/SKILL.md` | `remediator` |
|
|
36
|
+
| `/torusguard recheck` | `skills/torusguard-recheck/SKILL.md` | `reviewer` |
|
|
37
|
+
| `/torusguard report` | `skills/torusguard-report/SKILL.md` | `reviewer` |
|
|
38
|
+
| `/torusguard status` | `skills/torusguard-status/SKILL.md` | `reviewer` |
|
|
39
|
+
| `/torusguard full` | `skills/torusguard-full/SKILL.md` | *All* |
|
|
40
|
+
|
|
41
|
+
*Note: Never load all skills simultaneously. Lazy-load strictly on demand.*
|
|
Binary file
|