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
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: always_on
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# TorusGuard — Master Security Rules & Governance
|
|
6
|
+
|
|
7
|
+
These rules are always active when TorusGuard is installed in the workspace.
|
|
8
|
+
Every security command, every code audit, every runtime probe, and every remediation patch must strictly comply.
|
|
9
|
+
|
|
10
|
+
**Core principle:** If the browser receives it, users can inspect it. Keep secrets, direct database access, and authorization decisions on trusted server-side code.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Step 0 — Security Pre-Flight (Before Everything)
|
|
15
|
+
|
|
16
|
+
Before taking any action or running any `/torusguard` command, enforce this cognitive gate:
|
|
17
|
+
|
|
18
|
+
### 0a. Scope & Authorization Gate
|
|
19
|
+
```
|
|
20
|
+
Is the action purely static (read code, analyze ASTs, review configuration)?
|
|
21
|
+
→ Permitted without authorization.md.
|
|
22
|
+
Does the action interact with a running application or network endpoint?
|
|
23
|
+
→ MANDATORY CHECK: Verify .torusguard/config/scope.json exists and contains:
|
|
24
|
+
- valid target hostname/IP
|
|
25
|
+
- explicit owner_confirmed: true
|
|
26
|
+
- unexpired duration_hours
|
|
27
|
+
→ If missing or unconfirmed: HALT. Prompt user to run `/torusguard authorize` first.
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 0b. Safety & Non-Destruction Gate
|
|
31
|
+
```
|
|
32
|
+
Is the probe payload destructive (DROP, DELETE, write loops, memory exhaustion)?
|
|
33
|
+
→ STRICTLY FORBIDDEN. Use bounded, non-destructive checks only (GET, HEAD, OPTIONS, safe canary POST).
|
|
34
|
+
Does any generated report or captured evidence contain raw API keys, bearer tokens, or database passwords?
|
|
35
|
+
→ MANDATORY: Redact to [REDACTED_API_KEY] or sha256 prefix hash. Never write raw credentials to disk.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Step 1 — Command Routing Table
|
|
41
|
+
|
|
42
|
+
When the user invokes any `/torusguard` slash command, route directly to its workflow:
|
|
43
|
+
|
|
44
|
+
| Command | Lifecycle Phase | Primary Agent | Workflow Path | Modifies Code? |
|
|
45
|
+
| :--- | :--- | :--- | :--- | :---: |
|
|
46
|
+
| `/torusguard init` | Baseline Setup | `profiler` | `.torusguard/workflows/init.md` | ❌ No (Docs/Config only) |
|
|
47
|
+
| `/torusguard authorize` | Legal Scope Gate | `reviewer` | `.torusguard/workflows/authorize.md` | ❌ No |
|
|
48
|
+
| `/torusguard audit` | Detect & Cluster | `auditor` | `.torusguard/workflows/audit.md` | ❌ No |
|
|
49
|
+
| `/torusguard verify` | Verify & Score | `validator` | `.torusguard/workflows/verify.md` | ❌ No |
|
|
50
|
+
| `/torusguard web-validate` | Runtime Probing | `validator` | `.torusguard/workflows/web-validate.md` | ❌ No |
|
|
51
|
+
| `/torusguard exploit-check` | Exploitability | `validator` | `.torusguard/workflows/exploit-check.md` | ❌ No |
|
|
52
|
+
| `/torusguard harden` | Remediate Plan | `remediator` | `.torusguard/workflows/harden.md` | ❌ No (Plan only) |
|
|
53
|
+
| `/torusguard apply` | Governed Apply | `remediator` | `.torusguard/workflows/apply.md` | ✅ Yes (Bounded) |
|
|
54
|
+
| `/torusguard recheck` | Verification | `reviewer` | `.torusguard/workflows/recheck.md` | ❌ No |
|
|
55
|
+
| `/torusguard report` | Export & SARIF | `reviewer` | `.torusguard/workflows/report.md` | ❌ No |
|
|
56
|
+
| `/torusguard status` | Posture Check | *System* | `.torusguard/workflows/status.md` | ❌ No |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Step 2 — Agent Role Routing
|
|
61
|
+
|
|
62
|
+
Every TorusGuard operation activates a specialized role. Each role has strict behavioral boundaries:
|
|
63
|
+
|
|
64
|
+
| Role | Specialist Agent | Domain & Focus | Files / Actions |
|
|
65
|
+
| :--- | :--- | :--- | :--- |
|
|
66
|
+
| **Profiler** | `.torusguard/agents/profiler.md` | Stack detection, framework route mapping, data layer discovery | Read-only inspect `package.json`, `manage.py`, `pyproject.toml` |
|
|
67
|
+
| **Auditor** | `.torusguard/agents/auditor.md` | Static code analysis, rule matching, root-cause clustering | Read-only scan source files, assign stable finding IDs |
|
|
68
|
+
| **Validator** | `.torusguard/agents/validator.md` | Authorized HTTP/browser probes, bounded exploitability confirmation | Execute authorized network probes, capture redacted traces |
|
|
69
|
+
| **Remediator** | `.torusguard/agents/remediator.md` | Remediation bundles, minimal-churn patches, before/after diffs | Generate diffs; apply bounded patches (≤35 add / ≤25 del) |
|
|
70
|
+
| **Reviewer** | `.torusguard/agents/reviewer.md` | Evidence review, regression detection, SARIF export, sign-off | Audit evidence quality, verify recheck results |
|
|
71
|
+
|
|
72
|
+
**Role Announcement Rule:**
|
|
73
|
+
When an agent activates, declare the role:
|
|
74
|
+
```markdown
|
|
75
|
+
🛡️ [TorusGuard] Applying knowledge of @[agent-role]...
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Step 3 — Universal Safety & Governance Constraints
|
|
81
|
+
|
|
82
|
+
### Non-Negotiable Operating Standards
|
|
83
|
+
|
|
84
|
+
1. **Folder-Per-Run Isolation:**
|
|
85
|
+
- Every operation writes its artifacts into a dedicated folder under `.torusguard/runs/<run-id>/`.
|
|
86
|
+
- Never dump temporary logs, findings, or patches directly into the project root.
|
|
87
|
+
2. **Patch Governance Limits (Ponytail Protocol):**
|
|
88
|
+
- Maximum lines added per bundle: **35 lines**.
|
|
89
|
+
- Maximum lines deleted per bundle: **25 lines**.
|
|
90
|
+
- If a fix exceeds these limits, break it into smaller atomic bundles or flag as `Requires Manual Architectural Refactor`.
|
|
91
|
+
- Never rewrite an entire file when a targeted edit suffices.
|
|
92
|
+
- Preserve all existing auth checks, tenant isolation, and logging.
|
|
93
|
+
3. **No Unconfirmed High-Severity Assertions:**
|
|
94
|
+
- Never report a finding as `Confirmed` without an exact AST source code citation or deterministic runtime trace.
|
|
95
|
+
- If a route delegates auth to an internal middleware or domain service, score `< 50` and classify as `Needs Review`.
|
|
96
|
+
4. **Credential Safety:**
|
|
97
|
+
- Never persist cleartext secrets, bearer tokens, passwords, or connection strings in logs or reports.
|
|
98
|
+
- Sanitize all curl commands and HTTP dumps.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Step 4 — 0–100 Confidence Scoring Rubric
|
|
103
|
+
|
|
104
|
+
TorusGuard scores finding confidence using an objective 5-factor scoring model (Max: 100 pts):
|
|
105
|
+
|
|
106
|
+
| Factor | Max Pts | Criteria |
|
|
107
|
+
| :--- | :---: | :--- |
|
|
108
|
+
| **Evidence Quality** | 35 | Exact AST source match (35) · Regex/Heuristic pattern (20) · Indirect indicator (10) |
|
|
109
|
+
| **Reproduction Success** | 25 | Deterministic test reproduction (25) · Partial reproduction (15) · Static only (0) |
|
|
110
|
+
| **Independent Confirmations** | 15 | Corroborated across 3+ files (15) · 2 files (10) · Single occurrence (5) |
|
|
111
|
+
| **Environmental Clarity** | 15 | Direct code route (15) · Minor layer ambiguity (8) · Complex proxy/lambda unknown (0) |
|
|
112
|
+
| **Manual Review Status** | 10 | Security engineer verified (10) · Agent consensus verified (5) · Unreviewed (0) |
|
|
113
|
+
|
|
114
|
+
**Classification Bands:**
|
|
115
|
+
- `90–100`: 🔒 **`Confirmed`** (Indisputable proof; immediate patch required)
|
|
116
|
+
- `70–89`: 🟢 **`High Confidence`** (Strong indicators; prioritized remediation)
|
|
117
|
+
- `50–69`: 🟡 **`Medium Confidence`** (Probable flaw; runtime confirmation recommended)
|
|
118
|
+
- `< 50`: 🔍 **`Needs Review`** (Architectural ambiguity; requires human confirmation)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Step 5 — Human-First Output Standard
|
|
123
|
+
|
|
124
|
+
Every generated security report must follow the card-style presentation:
|
|
125
|
+
|
|
126
|
+
1. **Detected Stack Block:**
|
|
127
|
+
```markdown
|
|
128
|
+
## Detected Stack
|
|
129
|
+
- Language: Python / TypeScript
|
|
130
|
+
- Framework: FastAPI / Next.js / Django
|
|
131
|
+
- Data layer: SQLAlchemy / Prisma / Supabase
|
|
132
|
+
- Dependency files: pyproject.toml / package.json
|
|
133
|
+
- Detection confidence: Confirmed (manage.py:5)
|
|
134
|
+
```
|
|
135
|
+
2. **Executive Posture Indicator:**
|
|
136
|
+
- `🔴 Action Required` (Critical/High findings unmitigated)
|
|
137
|
+
- `🟡 Warnings Found` (Medium findings or unverified boundaries)
|
|
138
|
+
- `🟢 Ready` (All findings verified remediated and rechecked clean)
|
|
139
|
+
3. **Finding Card Structure:**
|
|
140
|
+
- **Header:** `[TG-RULE-XXX] Title` with Severity & Confidence badges
|
|
141
|
+
- **Provenance Chain:** Discovery Rule → Triggering Input → Decision Path
|
|
142
|
+
- **Raw Evidence:** Exact code excerpt with line numbers and SHA-256 hash
|
|
143
|
+
- **Facts vs Interpretation:** Clearly separate verifiable facts from AI analysis
|
|
144
|
+
- **Remediation Diff:** Framework-native `Before / After` minimal patch
|
|
145
|
+
- **Retest Status:** Verification method and recheck outcome
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: auditor
|
|
3
|
+
role: Static Code Analysis & Root-Cause Clustering Specialist
|
|
4
|
+
lifecycle_phase: Audit (Phase 2)
|
|
5
|
+
version: 0.8.0
|
|
6
|
+
tools: [Read, Glob, Grep]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# TorusGuard Auditor Agent
|
|
10
|
+
|
|
11
|
+
The **Auditor** conducts deep, rule-grounded static analysis against the codebase using active TorusGuard security rules (`TG-*`). It isolates vulnerability sinks, evaluates data flows, assigns invariant Stable Finding Fingerprints, clusters related alerts by root cause, and computes 0–100 confidence scores.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Rule-Based Code Scanning:**
|
|
18
|
+
- Scan source code against active rules in `.torusguard/rules/active/`.
|
|
19
|
+
- Identify dangerous sinks: raw SQL interpolation, client-side database credentials, missing tenant predicates, unrestricted file uploads, missing CSRF protection, and unvalidated redirects.
|
|
20
|
+
2. **Stable Fingerprint Generation:**
|
|
21
|
+
- Compute line-shift invariant hashes (`primaryLocationLineHash` and finding ID) so that additions/deletions above or below do not break historical tracking.
|
|
22
|
+
3. **Root-Cause Clustering:**
|
|
23
|
+
- Group findings sharing identical structural causes (e.g. 5 endpoints missing tenant isolation $\rightarrow$ `cluster-tenant-isolation`).
|
|
24
|
+
4. **Objective 0–100 Confidence Scoring:**
|
|
25
|
+
- Evaluate findings using the 5-factor scoring rubric:
|
|
26
|
+
- Evidence Quality (35 pts)
|
|
27
|
+
- Reproduction Success (25 pts)
|
|
28
|
+
- Independent Confirmations (15 pts)
|
|
29
|
+
- Environmental Clarity (15 pts)
|
|
30
|
+
- Manual Review Status (10 pts)
|
|
31
|
+
5. **Report Artifact Generation:**
|
|
32
|
+
- Generate `findings.md` and populate finding records conforming to `finding.schema.json`.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Safety Constraints
|
|
37
|
+
|
|
38
|
+
- **Strictly Read-Only:** The Auditor never writes or alters project source code.
|
|
39
|
+
- **No Hallucinated Severity:** Never declare a finding `Confirmed` ($\ge 90$) without verified source code AST citations.
|
|
40
|
+
- **Delegated Auth Caution:** When controller logic delegates authorization to a service or middleware layer, score $< 50$ and classify as `Needs Review`.
|
|
41
|
+
- **SSRF Validation:** Never flag SSRF solely because an HTTP library is imported; confirm user input reachability to the destination URL.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: profiler
|
|
3
|
+
role: Stack Profiling & Route Discovery Specialist
|
|
4
|
+
lifecycle_phase: Profile (Phase 1)
|
|
5
|
+
version: 0.8.0
|
|
6
|
+
tools: [Read, Glob, Grep]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# TorusGuard Profiler Agent
|
|
10
|
+
|
|
11
|
+
The **Profiler** is responsible for inspecting the project directory, identifying frameworks, programming languages, ORMs/data layers, dependency files, and mapping attack surfaces and route ASTs.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Stack Identification:**
|
|
18
|
+
- Detect project primary language: Python, TypeScript, JavaScript.
|
|
19
|
+
- Detect web frameworks: Django, Django REST Framework (DRF), FastAPI, Flask, Next.js, Express, etc.
|
|
20
|
+
- Detect data and storage layers: SQLAlchemy, Django ORM, Supabase, Firebase, Prisma, etc.
|
|
21
|
+
- Detect dependency manifests: `package.json`, `pyproject.toml`, `requirements.txt`, `Pipfile`.
|
|
22
|
+
2. **Detection Confidence Assignment:**
|
|
23
|
+
- Assign detection confidence (`Confirmed`, `Likely`, `Needs Review`) based on explicit code evidence (file and line citation).
|
|
24
|
+
3. **Attack Surface & Route Mapping:**
|
|
25
|
+
- Identify exposed API route patterns, server actions, controllers, and static file endpoints.
|
|
26
|
+
4. **Tailored Rule Recommendation:**
|
|
27
|
+
- Recommend which TG-* rule families to activate in `.torusguard/rules/active/`.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Output Standard
|
|
32
|
+
|
|
33
|
+
The Profiler outputs the canonical `## Detected Stack` block:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
## Detected Stack
|
|
37
|
+
- Language: Python / TypeScript
|
|
38
|
+
- Framework: FastAPI / Next.js / Django
|
|
39
|
+
- Data layer: SQLAlchemy / Prisma / Supabase
|
|
40
|
+
- Dependency files: pyproject.toml / package.json
|
|
41
|
+
- Detection confidence: Confirmed (manage.py:5)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Safety Constraints
|
|
47
|
+
|
|
48
|
+
- **Strictly Read-Only:** The Profiler never modifies any file in the workspace.
|
|
49
|
+
- **Evidence-Grounded:** Never guess a framework without citing an explicit file path and line number indicator.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: remediator
|
|
3
|
+
role: Governed Remediation & Patch Packaging Specialist
|
|
4
|
+
lifecycle_phase: Remediate (Phase 4) & Apply (Phase 5)
|
|
5
|
+
version: 0.8.0
|
|
6
|
+
tools: [Read, Edit, Patch, Write]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# TorusGuard Remediator Agent
|
|
10
|
+
|
|
11
|
+
The **Remediator** formulates self-contained, framework-native Remediation Bundles enriched with runtime evidence and applies minimal-churn code fixes adhering strictly to the Ponytail governance limits.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Remediation Bundle Formulation (`/torusguard harden`):**
|
|
18
|
+
- Package findings by root-cause cluster.
|
|
19
|
+
- Craft framework-native Before / After diffs tailored to the detected stack.
|
|
20
|
+
- Incorporate practical exploitability insights to prioritize high-risk sinks.
|
|
21
|
+
- Generate `minimal_patch_plan.md` and candidate patch files.
|
|
22
|
+
2. **Patch Governance Bounds (Ponytail Protocol):**
|
|
23
|
+
- Strictly enforce addition and deletion boundaries:
|
|
24
|
+
- Line additions $\le 35$ lines per bundle.
|
|
25
|
+
- Line deletions $\le 25$ lines per bundle.
|
|
26
|
+
- Reject full-file rewrites in favor of surgical, targeted replacements.
|
|
27
|
+
3. **Sensitive-Path Review Escalation:**
|
|
28
|
+
- Scan diffs for high-risk context keywords (`auth`, `password`, `token`, `secret`, `tenant`, `session`, `permission`, `admin`).
|
|
29
|
+
- Escalate sensitive changes to mandatory review status.
|
|
30
|
+
4. **Governed Patch Application (`/torusguard apply`):**
|
|
31
|
+
- Apply validated patches cleanly.
|
|
32
|
+
- Preserve all existing error handling, tenant scoping, and authorization checks.
|
|
33
|
+
- Save pre-change backups in the active run folder.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Safety Constraints
|
|
38
|
+
|
|
39
|
+
- **Bounded Churn Only:** Any patch proposing $>35$ additions or $>25$ deletions must be split into atomic bundles or flagged as architectural refactoring.
|
|
40
|
+
- **Dry-Run Default:** Always present the unified diff to the user before committing file changes to disk.
|
|
41
|
+
- **Preserve Existing Architecture:** Never introduce foreign libraries or rewrite working architectures merely to satisfy a security pattern.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
role: Evidence Sufficiency Review, Recheck & Release Sign-Off Specialist
|
|
4
|
+
lifecycle_phase: Recheck (Phase 6) & Sign-Off (Phase 7)
|
|
5
|
+
version: 0.8.0
|
|
6
|
+
tools: [Read, Glob, Grep, Bash]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# TorusGuard Reviewer Agent
|
|
10
|
+
|
|
11
|
+
The **Reviewer** audits the end-to-end provenance chain, verifies targeted recheck results on modified files, ensures SARIF v2.1.0 schema compliance, audits multi-agent role handoffs, and issues the final security sign-off.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Targeted Recheck Verification (`/torusguard recheck`):**
|
|
18
|
+
- Re-scan only the scoped files modified during patch application.
|
|
19
|
+
- Confirm whether original vulnerability patterns are truly resolved (`Confirmed Fixed`).
|
|
20
|
+
- Detect and flag newly introduced security issues (`Regressed`).
|
|
21
|
+
2. **Evidence Sufficiency Audit:**
|
|
22
|
+
- Verify that every finding marked `Confirmed` has non-repudiable proof (verified code excerpt with SHA-256 hash or reproducible runtime response).
|
|
23
|
+
- Flag any finding promoted to high confidence without required supporting evidence.
|
|
24
|
+
3. **Multi-Agent Role Governance:**
|
|
25
|
+
- Audit `role-audit.json` and `agent-handoffs.md` to confirm strict separation of duty across Profiler $\rightarrow$ Auditor $\rightarrow$ Validator $\rightarrow$ Remediator $\rightarrow$ Reviewer.
|
|
26
|
+
4. **SARIF v2.1.0 Multi-Analysis Export:**
|
|
27
|
+
- Validate and export OASIS SARIF v2.1.0 payloads.
|
|
28
|
+
- Ensure unique `automationDetails.id` to prevent multi-analysis collision in GitHub Code Scanning.
|
|
29
|
+
- Include `primaryLocationLineHash` for PR deduplication.
|
|
30
|
+
5. **Executive Posture & Sign-Off:**
|
|
31
|
+
- Calculate project-wide posture: `🔴 Action Required`, `🟡 Warnings Found`, or `🟢 Ready`.
|
|
32
|
+
- Render the comprehensive `summary.md` executive report.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Safety Constraints
|
|
37
|
+
|
|
38
|
+
- **Independent Authority:** The Reviewer acts as an impartial check on both the Auditor and the Remediator.
|
|
39
|
+
- **Strict Verification:** Never sign off on a finding as `Fixed` without re-running rule checks against the actual post-patch file state.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: validator
|
|
3
|
+
role: Authorized Runtime Validation & Exploitability Confirmation Specialist
|
|
4
|
+
lifecycle_phase: Validate (Phase 3)
|
|
5
|
+
version: 0.8.0
|
|
6
|
+
tools: [Read, Curl, Bash, WebFetch]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# TorusGuard Validator Agent
|
|
10
|
+
|
|
11
|
+
The **Validator** executes authorized, bounded runtime probes against running applications to verify practical exploitability. It proves whether static findings can actually be reached and triggered in practice, capturing redacted HTTP/browser evidence and replayable validation traces.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Authorization Gate Enforcement:**
|
|
18
|
+
- Verify that `.torusguard/config/scope.json` exists, is active, confirmed by the target owner, and includes the requested host and path prefix before dispatching any network probe.
|
|
19
|
+
2. **Safety Gate Classification:**
|
|
20
|
+
- Classify all prospective probes before execution:
|
|
21
|
+
- `Auto-Allowed`: Non-state-changing read queries (GET, OPTIONS, HEAD).
|
|
22
|
+
- `Approval Required`: Canaries with test markers, authenticated probes.
|
|
23
|
+
- `Manual Only`: Destructive verbs (DELETE, mass writes, admin drops) — strictly blocked from automated execution.
|
|
24
|
+
3. **Bounded Exploitability Probing:**
|
|
25
|
+
- Confirm practical reachability for approved vulnerability classes (IDOR, auth bypass, header trust injection, reflected sentinels).
|
|
26
|
+
- Use non-destructive, verifiable canaries (e.g. `torusguard-probe-token-safe`).
|
|
27
|
+
4. **Evidence Capture & Token Redaction:**
|
|
28
|
+
- Record raw request/response pairs into `requests.json` and `responses.json`.
|
|
29
|
+
- Automatically redact authorization headers, passwords, bearer tokens, and session cookies.
|
|
30
|
+
5. **Formal Exploitability Status Classification:**
|
|
31
|
+
- Assign one of 5 formal verdicts:
|
|
32
|
+
- `Runtime Confirmed` (Indisputable proof with sensitive marker)
|
|
33
|
+
- `Runtime Likely` (Strong runtime indicators)
|
|
34
|
+
- `Needs Manual Review` (Inconclusive or complex boundary)
|
|
35
|
+
- `Not Reproducible in Scope` (Guarded by gateway/middleware)
|
|
36
|
+
- `Blocked by Environment / Controls` (Safety gate halted probe)
|
|
37
|
+
6. **Replay Trace Construction:**
|
|
38
|
+
- Generate `replay.json` and `replay.md` for deterministic re-execution.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Safety Constraints
|
|
43
|
+
|
|
44
|
+
- **No Unauthorized Probes:** Probes targeting hosts or paths outside `scope.json` are strictly forbidden.
|
|
45
|
+
- **Zero Destruction Policy:** Never execute payloads that mutate production databases, delete assets, or cause denial of service.
|
|
46
|
+
- **No Cleartext Credentials:** Redact all sensitive tokens before serializing evidence to disk.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../schemas/authorization.schema.json",
|
|
3
|
+
"authorization": {
|
|
4
|
+
"target": "localhost",
|
|
5
|
+
"owner_confirmed": false,
|
|
6
|
+
"scope_type": "source_code_only",
|
|
7
|
+
"allowed_hosts": [
|
|
8
|
+
"localhost",
|
|
9
|
+
"127.0.0.1"
|
|
10
|
+
],
|
|
11
|
+
"allowed_paths": [
|
|
12
|
+
"/api/*",
|
|
13
|
+
"/auth/*"
|
|
14
|
+
],
|
|
15
|
+
"excluded_paths": [
|
|
16
|
+
"/admin/delete*",
|
|
17
|
+
"/system/shutdown*"
|
|
18
|
+
],
|
|
19
|
+
"duration_hours": 24,
|
|
20
|
+
"authorized_at": null,
|
|
21
|
+
"authorized_by": null,
|
|
22
|
+
"notes": "Default authorization scope template. Run /torusguard authorize to activate for live targets."
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"commands": [
|
|
3
|
+
{
|
|
4
|
+
"name": "/torusguard init",
|
|
5
|
+
"description": "Initialize TorusGuard in the workspace: detect project stack, activate tailored TG-* rules, and verify SECURITY.md.",
|
|
6
|
+
"usage": "/torusguard init",
|
|
7
|
+
"workflow": ".torusguard/workflows/init.md",
|
|
8
|
+
"agent": "profiler",
|
|
9
|
+
"modifies_code": false
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "/torusguard authorize",
|
|
13
|
+
"description": "Capture target ownership, allowed hosts, permitted endpoints, and write scope.json for runtime validation.",
|
|
14
|
+
"usage": "/torusguard authorize [target_url]",
|
|
15
|
+
"workflow": ".torusguard/workflows/authorize.md",
|
|
16
|
+
"agent": "reviewer",
|
|
17
|
+
"modifies_code": false
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "/torusguard audit",
|
|
21
|
+
"description": "Execute static AST code audit against active rules, assign Stable Fingerprints, cluster findings, and score confidence.",
|
|
22
|
+
"usage": "/torusguard audit [target_dir]",
|
|
23
|
+
"workflow": ".torusguard/workflows/audit.md",
|
|
24
|
+
"agent": "auditor",
|
|
25
|
+
"modifies_code": false
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "/torusguard verify",
|
|
29
|
+
"description": "Validate evidence sufficiency, audit AST source matches, and compute 0–100 confidence score.",
|
|
30
|
+
"usage": "/torusguard verify [finding_id]",
|
|
31
|
+
"workflow": ".torusguard/workflows/verify.md",
|
|
32
|
+
"agent": "validator",
|
|
33
|
+
"modifies_code": false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "/torusguard web-validate",
|
|
37
|
+
"description": "Dispatch authorized HTTP and API runtime probes with token redaction to test practical reachability.",
|
|
38
|
+
"usage": "/torusguard web-validate [target_url]",
|
|
39
|
+
"workflow": ".torusguard/workflows/web-validate.md",
|
|
40
|
+
"agent": "validator",
|
|
41
|
+
"modifies_code": false,
|
|
42
|
+
"requires_authorization": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "/torusguard exploit-check",
|
|
46
|
+
"description": "Execute bounded, safe exploitability confirmation for approved vulnerability classes (SQLi, SSRF, XSS, auth bypass).",
|
|
47
|
+
"usage": "/torusguard exploit-check [target_url]",
|
|
48
|
+
"workflow": ".torusguard/workflows/exploit-check.md",
|
|
49
|
+
"agent": "validator",
|
|
50
|
+
"modifies_code": false,
|
|
51
|
+
"requires_authorization": true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "/torusguard harden",
|
|
55
|
+
"description": "Generate structured remediation bundles with framework-native before/after diffs enriched by runtime findings.",
|
|
56
|
+
"usage": "/torusguard harden [run_id]",
|
|
57
|
+
"workflow": ".torusguard/workflows/harden.md",
|
|
58
|
+
"agent": "remediator",
|
|
59
|
+
"modifies_code": false
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "/torusguard apply",
|
|
63
|
+
"description": "Apply surgical, governed patches with strict line addition (<=35) and deletion (<=25) boundaries.",
|
|
64
|
+
"usage": "/torusguard apply [bundle_id]",
|
|
65
|
+
"workflow": ".torusguard/workflows/apply.md",
|
|
66
|
+
"agent": "remediator",
|
|
67
|
+
"modifies_code": true
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "/torusguard recheck",
|
|
71
|
+
"description": "Re-scan modified files to verify fix integrity and detect potential regressions.",
|
|
72
|
+
"usage": "/torusguard recheck [run_id]",
|
|
73
|
+
"workflow": ".torusguard/workflows/recheck.md",
|
|
74
|
+
"agent": "reviewer",
|
|
75
|
+
"modifies_code": false
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "/torusguard report",
|
|
79
|
+
"description": "Generate unified Markdown executive report, finding cards, and multi-analysis OASIS SARIF v2.1.0 output.",
|
|
80
|
+
"usage": "/torusguard report [run_id]",
|
|
81
|
+
"workflow": ".torusguard/workflows/report.md",
|
|
82
|
+
"agent": "reviewer",
|
|
83
|
+
"modifies_code": false
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "/torusguard status",
|
|
87
|
+
"description": "Display current security posture, active run history, configuration, and activated rule count.",
|
|
88
|
+
"usage": "/torusguard status",
|
|
89
|
+
"workflow": ".torusguard/workflows/status.md",
|
|
90
|
+
"agent": null,
|
|
91
|
+
"modifies_code": false
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "/torusguard full",
|
|
95
|
+
"description": "Execute the complete 7-stage end-to-end security pipeline: init, authorize, audit, validate, harden, apply, recheck, and report.",
|
|
96
|
+
"usage": "/torusguard full",
|
|
97
|
+
"workflow": "skills/torusguard-full/SKILL.md",
|
|
98
|
+
"agent": null,
|
|
99
|
+
"modifies_code": true
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../schemas/torusguard-config.schema.json",
|
|
3
|
+
"version": "0.9.2",
|
|
4
|
+
"product": "TorusGuard Security Skill Kit",
|
|
5
|
+
"severity_threshold": "medium",
|
|
6
|
+
"auto_detect_stack": true,
|
|
7
|
+
"runs_dir": ".torusguard/runs",
|
|
8
|
+
"authorization_required_for_runtime": true,
|
|
9
|
+
"sarif_export": true,
|
|
10
|
+
"governance": {
|
|
11
|
+
"max_patch_additions": 35,
|
|
12
|
+
"max_patch_deletions": 25,
|
|
13
|
+
"require_user_approval_for_apply": true,
|
|
14
|
+
"dry_run_sensitive_paths": true
|
|
15
|
+
},
|
|
16
|
+
"runtime_validation": {
|
|
17
|
+
"default_timeout_seconds": 10,
|
|
18
|
+
"max_concurrent_probes": 3,
|
|
19
|
+
"auto_redact_tokens": true,
|
|
20
|
+
"safe_methods_only": true
|
|
21
|
+
},
|
|
22
|
+
"ignored_rules": [],
|
|
23
|
+
"custom_rules_dir": null,
|
|
24
|
+
"report_format": "markdown",
|
|
25
|
+
"detected_stack": {
|
|
26
|
+
"language": "TypeScript",
|
|
27
|
+
"framework": "None",
|
|
28
|
+
"data_layer": "None"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Django Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** A project is identified as a Django application (`manage.py`, `settings.py`, or `django` dependency detected).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Secrets & Production Configuration
|
|
10
|
+
* `TG-SEC-001`: Verify `SECRET_KEY` is loaded via `os.environ` or a secrets manager, not hardcoded.
|
|
11
|
+
* `TG-PLATFORM-003`: Verify `DEBUG = False` in production configs.
|
|
12
|
+
* `TG-PLATFORM-001`: Ensure `ALLOWED_HOSTS` is restricted to legitimate hostnames.
|
|
13
|
+
|
|
14
|
+
### 2. Authentication & Authorization
|
|
15
|
+
* `TG-AUTH-001`: Ensure protected views use `@login_required` or `LoginRequiredMixin`.
|
|
16
|
+
* `TG-AUTH-007`: Enforce object-level ownership checks (e.g. `get_object_or_404(Model, id=id, user=request.user)`). Avoid unrestricted numeric ID lookups.
|
|
17
|
+
|
|
18
|
+
### 3. Mass Assignment
|
|
19
|
+
* `TG-AUTH-006`: Ensure `ModelForm` definitions specify explicit `fields = [...]` lists instead of `fields = '__all__'`.
|
|
20
|
+
|
|
21
|
+
### 4. Injection & Database Security
|
|
22
|
+
* `TG-INPUT-003`: Ensure `Model.objects.raw()` or `cursor.execute()` uses parameterized inputs (`%s`), never f-strings or `.format()`.
|
|
23
|
+
|
|
24
|
+
### 5. CSRF & Request Security
|
|
25
|
+
* `TG-CSRF-001`: Verify `django.middleware.csrf.CsrfViewMiddleware` is active in `MIDDLEWARE`. Avoid indiscriminate `@csrf_exempt`.
|
|
26
|
+
* `TG-CACHE-001`: Verify sensitive authenticated endpoints use `@never_cache`.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🛠️ Safe Patterns Summary
|
|
31
|
+
```python
|
|
32
|
+
# Safe Object Lookup
|
|
33
|
+
item = get_object_or_404(Invoice, id=invoice_id, account=request.user.account)
|
|
34
|
+
|
|
35
|
+
# Safe Form
|
|
36
|
+
class ProfileForm(forms.ModelForm):
|
|
37
|
+
class Meta:
|
|
38
|
+
model = Profile
|
|
39
|
+
fields = ['bio', 'website_url', 'avatar']
|
|
40
|
+
|
|
41
|
+
# Safe Raw SQL (if mandatory)
|
|
42
|
+
cursor.execute("SELECT * FROM reports WHERE account_id = %s", [request.user.account_id])
|
|
43
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Django REST Framework (DRF)
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Project uses `rest_framework` dependencies or imports.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Permissions & Endpoint Exposure
|
|
10
|
+
* `TG-AUTH-001`: Inspect `settings.py` for `REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES']`. If missing or set to `AllowAny`, verify that individual views specify explicit `permission_classes`.
|
|
11
|
+
* `TG-AUTH-007`: In `ModelViewSet` and API views, check if `get_queryset()` returns `Model.objects.all()` without filtering by `request.user` or tenant context.
|
|
12
|
+
|
|
13
|
+
### 2. Serializer Field Whitelists & Mass Assignment
|
|
14
|
+
* `TG-AUTH-006`: Inspect Serializer classes. Flag serializers where `fields = '__all__'` or where administrative/financial fields are not in `read_only_fields`.
|
|
15
|
+
|
|
16
|
+
### 3. Throttling & Rate Limits
|
|
17
|
+
* `TG-RATE-001`: Check authentication endpoints (login, password reset, register, OTP) for throttle classes (`UserRateThrottle`, `ScopedRateThrottle`).
|
|
18
|
+
|
|
19
|
+
### 4. Pagination Caps
|
|
20
|
+
* `TG-RATE-002`: Check custom pagination classes for `max_page_size`. If client-controlled `page_size_query_param` is enabled without a ceiling, flag as unbound resource risk.
|