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,158 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TorusGuard Autonomous Workspace Bootstrapper
|
|
4
|
+
Scaffolds the complete .torusguard/ directory into any user project when
|
|
5
|
+
/torusguard init is executed or when npx skills add installs the skill kit.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
import shutil
|
|
11
|
+
import json
|
|
12
|
+
import argparse
|
|
13
|
+
import subprocess
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def find_project_root(start_dir=None):
|
|
18
|
+
"""Detect project root directory by searching for standard repo root markers."""
|
|
19
|
+
current = Path(start_dir or os.getcwd()).resolve()
|
|
20
|
+
markers = [".git", "package.json", "pyproject.toml", "manage.py", "Pipfile", "requirements.txt"]
|
|
21
|
+
|
|
22
|
+
# First check current directory
|
|
23
|
+
for m in markers:
|
|
24
|
+
if (current / m).exists():
|
|
25
|
+
return current
|
|
26
|
+
|
|
27
|
+
# Search upwards
|
|
28
|
+
for parent in current.parents:
|
|
29
|
+
for m in markers:
|
|
30
|
+
if (parent / m).exists():
|
|
31
|
+
return parent
|
|
32
|
+
|
|
33
|
+
return current
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def scaffold_workspace(target_root=None, force=False):
|
|
37
|
+
"""Scaffold the .torusguard workspace into the target project root."""
|
|
38
|
+
target_root = Path(target_root or find_project_root()).resolve()
|
|
39
|
+
torusguard_target = target_root / ".torusguard"
|
|
40
|
+
script_dir = Path(__file__).resolve().parent
|
|
41
|
+
payload_dir = script_dir / "payload"
|
|
42
|
+
|
|
43
|
+
print("================================================================================")
|
|
44
|
+
print("TORUSGUARD WORKSPACE BOOTSTRAPPER")
|
|
45
|
+
print("================================================================================")
|
|
46
|
+
print(f"Target Directory: {target_root}")
|
|
47
|
+
print(f"Destination: {torusguard_target}")
|
|
48
|
+
|
|
49
|
+
if torusguard_target.exists() and not force:
|
|
50
|
+
print(f"\n[INFO] Workspace already exists at {torusguard_target}")
|
|
51
|
+
config_file = torusguard_target / "config" / "torusguard.json"
|
|
52
|
+
if config_file.exists():
|
|
53
|
+
try:
|
|
54
|
+
with open(config_file, "r", encoding="utf-8") as f:
|
|
55
|
+
cfg = json.load(f)
|
|
56
|
+
print(f"Current Version: {cfg.get('version', 'unknown')}")
|
|
57
|
+
print(f"Severity Minimum: {cfg.get('severity_threshold', 'medium')}")
|
|
58
|
+
except Exception:
|
|
59
|
+
pass
|
|
60
|
+
print("\nUse --force to re-scaffold or refresh templates.")
|
|
61
|
+
return True
|
|
62
|
+
|
|
63
|
+
# 1. Unpack Payload Template
|
|
64
|
+
if payload_dir.is_dir():
|
|
65
|
+
print("\n1. Unpacking bundled offline workspace payload...")
|
|
66
|
+
try:
|
|
67
|
+
if torusguard_target.exists() and force:
|
|
68
|
+
shutil.rmtree(torusguard_target)
|
|
69
|
+
shutil.copytree(
|
|
70
|
+
payload_dir,
|
|
71
|
+
torusguard_target,
|
|
72
|
+
ignore=shutil.ignore_patterns("runs", "*.pyc", "__pycache__", ".git*")
|
|
73
|
+
)
|
|
74
|
+
print(" [SUCCESS] Copied template tree from local skill payload.")
|
|
75
|
+
except Exception as e:
|
|
76
|
+
print(f" [ERROR] Failed to unpack payload: {e}")
|
|
77
|
+
return False
|
|
78
|
+
else:
|
|
79
|
+
# Fallback: create base structure
|
|
80
|
+
print("\n1. Bundled payload not found. Creating core skeleton...")
|
|
81
|
+
subdirs = [
|
|
82
|
+
"config", "agents", "workflows", "scripts", "templates",
|
|
83
|
+
"schemas", "references", "rules/active", "runs"
|
|
84
|
+
]
|
|
85
|
+
for s in subdirs:
|
|
86
|
+
(torusguard_target / s).mkdir(parents=True, exist_ok=True)
|
|
87
|
+
print(" [WARN] Bare skeleton created; full assets should be pulled from repository.")
|
|
88
|
+
|
|
89
|
+
# 2. Ensure runs and rules/active directories exist
|
|
90
|
+
runs_dir = torusguard_target / "runs"
|
|
91
|
+
runs_dir.mkdir(parents=True, exist_ok=True)
|
|
92
|
+
gitkeep_runs = runs_dir / ".gitkeep"
|
|
93
|
+
if not gitkeep_runs.exists():
|
|
94
|
+
gitkeep_runs.write_text("", encoding="utf-8")
|
|
95
|
+
|
|
96
|
+
active_rules_dir = torusguard_target / "rules" / "active"
|
|
97
|
+
active_rules_dir.mkdir(parents=True, exist_ok=True)
|
|
98
|
+
gitkeep_rules = active_rules_dir / ".gitkeep"
|
|
99
|
+
if not gitkeep_rules.exists():
|
|
100
|
+
gitkeep_rules.write_text("", encoding="utf-8")
|
|
101
|
+
|
|
102
|
+
# 3. Stack Detection & Tailoring
|
|
103
|
+
print("\n2. Executing stack detection on target project...")
|
|
104
|
+
stack_detect_script = torusguard_target / "scripts" / "stack_detect.py"
|
|
105
|
+
detected_stack = {"language": "Unknown", "framework": "None", "data_layer": "None", "confidence": "Uncertain"}
|
|
106
|
+
|
|
107
|
+
if stack_detect_script.exists():
|
|
108
|
+
try:
|
|
109
|
+
res = subprocess.run(
|
|
110
|
+
[sys.executable, str(stack_detect_script), str(target_root), "--json"],
|
|
111
|
+
capture_output=True,
|
|
112
|
+
text=True,
|
|
113
|
+
timeout=10
|
|
114
|
+
)
|
|
115
|
+
if res.returncode == 0 and res.stdout.strip():
|
|
116
|
+
detected_stack = json.loads(res.stdout)
|
|
117
|
+
print(f" [DETECTED] Language: {detected_stack.get('language')}")
|
|
118
|
+
print(f" [DETECTED] Framework: {detected_stack.get('framework')}")
|
|
119
|
+
print(f" [DETECTED] Data Layer: {detected_stack.get('data_layer')}")
|
|
120
|
+
except Exception as e:
|
|
121
|
+
print(f" [WARN] Stack detection encountered error: {e}")
|
|
122
|
+
|
|
123
|
+
# 4. Update torusguard.json configuration
|
|
124
|
+
config_file = torusguard_target / "config" / "torusguard.json"
|
|
125
|
+
if config_file.exists():
|
|
126
|
+
try:
|
|
127
|
+
with open(config_file, "r", encoding="utf-8") as f:
|
|
128
|
+
cfg = json.load(f)
|
|
129
|
+
cfg["detected_stack"] = {
|
|
130
|
+
"language": detected_stack.get("language"),
|
|
131
|
+
"framework": detected_stack.get("framework"),
|
|
132
|
+
"data_layer": detected_stack.get("data_layer")
|
|
133
|
+
}
|
|
134
|
+
with open(config_file, "w", encoding="utf-8") as f:
|
|
135
|
+
json.dump(cfg, f, indent=2)
|
|
136
|
+
print(" [SUCCESS] Configured .torusguard/config/torusguard.json")
|
|
137
|
+
except Exception as e:
|
|
138
|
+
print(f" [WARN] Failed to write stack details to config: {e}")
|
|
139
|
+
|
|
140
|
+
print("\n================================================================================")
|
|
141
|
+
print("[SUCCESS] TORUSGUARD WORKSPACE SCAFFOLDED SUCCESSFULLY!")
|
|
142
|
+
print("================================================================================")
|
|
143
|
+
print(f"Workspace Path: {torusguard_target}")
|
|
144
|
+
print("\nNext Steps:")
|
|
145
|
+
print(" 1. Run `/torusguard audit` in your AI IDE to scan the project.")
|
|
146
|
+
print(" 2. Run `/torusguard status` to verify active security posture.")
|
|
147
|
+
print("================================================================================")
|
|
148
|
+
return True
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == "__main__":
|
|
152
|
+
parser = argparse.ArgumentParser(description="TorusGuard Autonomous Workspace Bootstrapper")
|
|
153
|
+
parser.add_argument("--target", type=str, help="Target project root directory")
|
|
154
|
+
parser.add_argument("--force", action="store_true", help="Force overwrite existing workspace")
|
|
155
|
+
args = parser.parse_args()
|
|
156
|
+
|
|
157
|
+
success = scaffold_workspace(target_root=args.target, force=args.force)
|
|
158
|
+
sys.exit(0 if success else 1)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Authentication, Sessions, and Authorization
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check auth`, login/signup/reset implementation, or resource route reviews.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-AUTH-001](../../rules/TG-AUTH-001-weak-password-storage.md) — Weak Password Storage (Critical)
|
|
10
|
+
- [TG-AUTH-002](../../rules/TG-AUTH-002-client-only-authorization.md) — Client-Only Authorization (High)
|
|
11
|
+
- [TG-AUTH-003](../../rules/TG-AUTH-003-missing-object-authorization.md) — IDOR/BOLA (High)
|
|
12
|
+
- [TG-AUTH-004](../../rules/TG-AUTH-004-insecure-session-cookie.md) — Insecure Session Cookie (High)
|
|
13
|
+
- [TG-AUTH-005](../../rules/TG-AUTH-005-unsafe-password-reset.md) — Unsafe Password Reset (High)
|
|
14
|
+
|
|
15
|
+
## Hard bans
|
|
16
|
+
|
|
17
|
+
- No plaintext, MD5, or SHA1 password storage
|
|
18
|
+
- No authorization enforced only in frontend routing
|
|
19
|
+
- No trust in client-supplied user IDs or roles
|
|
20
|
+
- No session cookies missing httpOnly/Secure/SameSite in production
|
|
21
|
+
- No predictable or reusable password reset tokens
|
|
22
|
+
|
|
23
|
+
## Safe defaults
|
|
24
|
+
|
|
25
|
+
- Argon2id or bcrypt (cost ≥ 12) for passwords
|
|
26
|
+
- httpOnly, Secure, SameSite cookies for browser sessions
|
|
27
|
+
- Server-side role and ownership checks on every sensitive route
|
|
28
|
+
- Neutral login/reset responses (no account enumeration)
|
|
29
|
+
- CSRF protection for cookie-authenticated state changes
|
|
30
|
+
- Reset tokens: random, single-use, expiring
|
|
31
|
+
|
|
32
|
+
## IDOR test procedure
|
|
33
|
+
|
|
34
|
+
For each route with a resource ID (`/api/users/:id`, `/api/orders/:orderId`):
|
|
35
|
+
|
|
36
|
+
> Can User A change the ID and access User B's resource?
|
|
37
|
+
|
|
38
|
+
If yes → fails TG-AUTH-003.
|
|
39
|
+
|
|
40
|
+
## Audit checklist
|
|
41
|
+
|
|
42
|
+
- [ ] Strong password hashing (TG-AUTH-001)
|
|
43
|
+
- [ ] Server enforces authZ (TG-AUTH-002)
|
|
44
|
+
- [ ] Object ownership verified (TG-AUTH-003)
|
|
45
|
+
- [ ] Secure cookie flags (TG-AUTH-004)
|
|
46
|
+
- [ ] Safe reset flow + rate limits (TG-AUTH-005)
|
|
47
|
+
|
|
48
|
+
## Manual review
|
|
49
|
+
|
|
50
|
+
- Organization/tenant-scoped authorization
|
|
51
|
+
- Privilege escalation via mass assignment
|
|
52
|
+
- Session fixation and logout invalidation
|
|
53
|
+
|
|
54
|
+
## Related rules
|
|
55
|
+
|
|
56
|
+
TG-RATE-001, TG-SEC-004, TG-INPUT-001
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Business Logic and Abuse
|
|
2
|
+
|
|
3
|
+
## Topics
|
|
4
|
+
- Coupon and discount abuse.
|
|
5
|
+
- Trial and referral abuse.
|
|
6
|
+
- Payment amount tampering.
|
|
7
|
+
- Inventory manipulation.
|
|
8
|
+
- OTP and verification workflow bypass.
|
|
9
|
+
- Vote and rating manipulation.
|
|
10
|
+
- Repeated one-time operations.
|
|
11
|
+
- AI or third-party API cost abuse.
|
|
12
|
+
- Replay and idempotency.
|
|
13
|
+
- Per-user and per-account velocity.
|
|
14
|
+
- Server-side state transitions.
|
|
15
|
+
|
|
16
|
+
## Review Table
|
|
17
|
+
| Flow | Value protected | Abuse action | Existing control | Missing control |
|
|
18
|
+
|---|---|---|---|---|
|
|
19
|
+
| Apply coupon | Discount amount | Reuse coupon | Database flag | Atomic update |
|
|
20
|
+
| Send OTP | SMS cost | Repeated requests | IP limiter | Account limiter |
|
|
21
|
+
| Create order | Inventory/payment | Modify quantity/price | Auth only | Server-side pricing |
|
|
22
|
+
|
|
23
|
+
The agent must ask whether a user can execute a technically valid operation too many times. OWASP identifies sensitive business-flow abuse separately from ordinary authentication and resource-exhaustion concerns.
|
package/skills/torusguard/payload/skills/torusguard/references/cache-and-sensitive-responses.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Cache and Sensitive Responses
|
|
2
|
+
|
|
3
|
+
- Cache-Control: private, no-store for sensitive responses where appropriate.
|
|
4
|
+
- CDN cache-key isolation.
|
|
5
|
+
- User-specific response separation.
|
|
6
|
+
- Sensitive query parameters and tokens.
|
|
7
|
+
- Referrer leakage.
|
|
8
|
+
- Authenticated API responses.
|
|
9
|
+
- Export/download URLs.
|
|
10
|
+
- Signed URL expiry.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Client Code Exposure and Source Maps
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check client`, production build review, or frontend bundle audits.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-CLIENT-001](../../rules/TG-CLIENT-001-public-production-source-maps.md) — Public Production Source Maps (Medium)
|
|
10
|
+
- [TG-CLIENT-002](../../rules/TG-CLIENT-002-sensitive-client-bundle-content.md) — Sensitive Bundle Content (High)
|
|
11
|
+
|
|
12
|
+
## Important truth
|
|
13
|
+
|
|
14
|
+
**Inspect Element and DevTools cannot be prevented.** Browser-delivered JavaScript is public. TorusGuard must never claim client code can be hidden. Security comes from server-side enforcement, not obfuscation.
|
|
15
|
+
|
|
16
|
+
Obfuscation is a minor deterrent only — never a security control.
|
|
17
|
+
|
|
18
|
+
## Hard bans
|
|
19
|
+
|
|
20
|
+
- No secrets, privileged routes, or auth decisions only in client code
|
|
21
|
+
- No production `console.log` of tokens, users, or config
|
|
22
|
+
- No public `.map` files unless explicitly required
|
|
23
|
+
|
|
24
|
+
## Safe defaults
|
|
25
|
+
|
|
26
|
+
| Framework | Production setting |
|
|
27
|
+
|-----------|-------------------|
|
|
28
|
+
| Vite | `build.sourcemap: false` |
|
|
29
|
+
| Next.js | `productionBrowserSourceMaps: false` |
|
|
30
|
+
| CRA | `GENERATE_SOURCEMAP=false` |
|
|
31
|
+
|
|
32
|
+
- Upload source maps privately to Sentry/monitoring — do not serve publicly
|
|
33
|
+
- Verify public `.map` URLs return 404 when disabled
|
|
34
|
+
- Add CSP where practical
|
|
35
|
+
- Move authorization and secrets server-side
|
|
36
|
+
|
|
37
|
+
## Audit checklist
|
|
38
|
+
|
|
39
|
+
- [ ] Production source maps disabled or private (TG-CLIENT-001)
|
|
40
|
+
- [ ] No secrets or privileged logic in bundle (TG-CLIENT-002)
|
|
41
|
+
- [ ] No sensitive console logging
|
|
42
|
+
- [ ] CSP configured appropriately
|
|
43
|
+
|
|
44
|
+
## Manual review
|
|
45
|
+
|
|
46
|
+
- Third-party script dependencies
|
|
47
|
+
- Comments revealing internal routes or admin endpoints
|
|
48
|
+
|
|
49
|
+
## Related rules
|
|
50
|
+
|
|
51
|
+
TG-SEC-002, TG-AUTH-002, TG-PLATFORM-002
|
|
52
|
+
|
|
53
|
+
## Framework guide
|
|
54
|
+
|
|
55
|
+
[React/Vite Security](../../guides/react-vite-security.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# CSRF and Cross-Origin
|
|
2
|
+
|
|
3
|
+
- Cookie-authenticated state changes.
|
|
4
|
+
- Synchronizer tokens.
|
|
5
|
+
- Double-submit cookies.
|
|
6
|
+
- SameSite behavior and limitations.
|
|
7
|
+
- CORS and credentials.
|
|
8
|
+
- Origin and Referer validation where appropriate.
|
|
9
|
+
- JSON content-type restrictions.
|
|
10
|
+
- Framework-native CSRF protections.
|
|
11
|
+
- SPA/API architecture differences.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Dependency and Supply Chain
|
|
2
|
+
|
|
3
|
+
- Lockfiles.
|
|
4
|
+
- Dependency update policy.
|
|
5
|
+
- Vulnerability audit commands by ecosystem.
|
|
6
|
+
- Dependabot/Renovate.
|
|
7
|
+
- GitHub Actions pinning.
|
|
8
|
+
- CI secret exposure.
|
|
9
|
+
- Pull-request workflow trust.
|
|
10
|
+
- Install scripts.
|
|
11
|
+
- Dependency provenance.
|
|
12
|
+
- Review of new packages.
|
|
13
|
+
|
|
14
|
+
## Audit Commands
|
|
15
|
+
```bash
|
|
16
|
+
npm audit
|
|
17
|
+
pip-audit
|
|
18
|
+
osv-scanner --lockfile=package-lock.json
|
|
19
|
+
dotnet list package --vulnerable
|
|
20
|
+
bundle audit
|
|
21
|
+
govulncheck ./...
|
|
22
|
+
```
|
|
@@ -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.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: FastAPI Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Project uses `fastapi` dependencies or imports.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Route Authorization & Dependencies
|
|
10
|
+
* `TG-AUTH-001` / `TG-AUTH-003`: Verify protected routes include security dependencies (`Depends(get_current_user)`).
|
|
11
|
+
* `TG-AUTH-007`: In route handlers taking numeric/UUID path parameters (e.g. `profile_id`, `invoice_id`), verify that database queries filter by the authenticated user's ID.
|
|
12
|
+
|
|
13
|
+
### 2. Request Models & Mass Assignment
|
|
14
|
+
* `TG-AUTH-006`: Check that endpoints accept structured Pydantic `BaseModel` classes rather than raw `dict`, `Body(...)`, or unpacking `**payload` directly into ORM entities.
|
|
15
|
+
|
|
16
|
+
### 3. Outbound Requests & SSRF
|
|
17
|
+
* `TG-SSRF-001`: Inspect endpoints that fetch external URLs via `httpx` or `requests`. Verify scheme validation and private IP address filtering.
|
|
18
|
+
|
|
19
|
+
### 4. Webhook Integrity
|
|
20
|
+
* `TG-WEBHOOK-001`: In webhook endpoints, verify HMAC signature validation using `await request.body()` (raw bytes) before JSON parsing.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Flask Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Project uses `flask` dependencies or imports.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Secret Key & Cookie Configuration
|
|
10
|
+
* `TG-SEC-001`: Inspect `app.config['SECRET_KEY']`. Flag hardcoded string literals.
|
|
11
|
+
* `TG-PLATFORM-003`: Verify `app.debug = False` in production configs.
|
|
12
|
+
|
|
13
|
+
### 2. Authorization & Ownership (IDOR)
|
|
14
|
+
* `TG-AUTH-007`: In route handlers querying database models by route variables (e.g. `<int:id>`), verify that the query filters by `current_user.id`.
|
|
15
|
+
|
|
16
|
+
### 3. CSRF Protection
|
|
17
|
+
* `TG-CSRF-001`: Verify that cookie-authenticated web forms initialize `flask_wtf.CSRFProtect`.
|
|
18
|
+
|
|
19
|
+
### 4. File Uploads
|
|
20
|
+
* `TG-INPUT-004`: Ensure uploaded filenames are filtered using `secure_filename()` and validate against an extension whitelist.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Frontend Database Protection
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check database`, full-stack audits, or when frontend code connects to data stores.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-DB-001](../../rules/TG-DB-001-frontend-database-query.md) — Database Query in Frontend (High)
|
|
10
|
+
- [TG-DB-002](../../rules/TG-DB-002-privileged-database-credential.md) — Privileged Credential in Browser (Critical)
|
|
11
|
+
- [TG-DB-003](../../rules/TG-DB-003-frontend-admin-sdk.md) — Frontend Admin SDK (Critical)
|
|
12
|
+
|
|
13
|
+
## Hard bans
|
|
14
|
+
|
|
15
|
+
- No SQL in frontend directories (`src/`, `app/`, `pages/`, `components/`, `client/`, `public/`)
|
|
16
|
+
- No imports of `pg`, `mysql`, `mongoose`, `@prisma/client`, Sequelize, TypeORM, Drizzle server client
|
|
17
|
+
- No Supabase service-role key or Firebase Admin SDK in browser code
|
|
18
|
+
- No trust in client-provided user ID or role without server verification
|
|
19
|
+
|
|
20
|
+
## Safe architecture
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Browser → HTTPS API → AuthZ → Parameterized query/ORM → Database
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Supabase
|
|
27
|
+
|
|
28
|
+
- Browser: anon key + **RLS enabled** on all exposed tables
|
|
29
|
+
- Server: service-role key only for admin tasks
|
|
30
|
+
- **Manual review required:** RLS policies for every table
|
|
31
|
+
|
|
32
|
+
## Firebase
|
|
33
|
+
|
|
34
|
+
- Browser: client SDK + Security Rules
|
|
35
|
+
- Server: Admin SDK only
|
|
36
|
+
- **Manual review required:** Firestore/Storage rules
|
|
37
|
+
|
|
38
|
+
## Audit checklist
|
|
39
|
+
|
|
40
|
+
- [ ] No DB queries or drivers in client code (TG-DB-001, TG-DB-003)
|
|
41
|
+
- [ ] No connection strings or service-role keys in bundle (TG-DB-002)
|
|
42
|
+
- [ ] All mutations authorized server-side
|
|
43
|
+
- [ ] Supabase RLS / Firebase rules reviewed and tested
|
|
44
|
+
|
|
45
|
+
## Framework guides
|
|
46
|
+
|
|
47
|
+
- [Supabase](../../guides/supabase-security.md)
|
|
48
|
+
- [Firebase](../../guides/firebase-security.md)
|
|
49
|
+
- [React/Vite](../../guides/react-vite-security.md)
|
|
50
|
+
|
|
51
|
+
## Related rules
|
|
52
|
+
|
|
53
|
+
TG-SEC-002, TG-AUTH-002, TG-AUTH-003
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# GraphQL Security
|
|
2
|
+
|
|
3
|
+
- Resolver-level authentication and authorization.
|
|
4
|
+
- Query depth limits.
|
|
5
|
+
- Query complexity limits.
|
|
6
|
+
- Pagination and page-size caps.
|
|
7
|
+
- Batching controls.
|
|
8
|
+
- Introspection policy.
|
|
9
|
+
- Aliases and recursive relationships.
|
|
10
|
+
- Error sanitization.
|
|
11
|
+
- Sensitive field exposure.
|
|
12
|
+
- Data-loader and N+1 concerns as resource risks.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Input Validation and Injection Prevention
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check input`, API route reviews, or upload/webhook implementation.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-INPUT-001](../../rules/TG-INPUT-001-missing-server-validation.md) — Missing Server Validation (High)
|
|
10
|
+
- [TG-INPUT-002](../../rules/TG-INPUT-002-raw-sql-concatenation.md) — Raw SQL Concatenation (Critical)
|
|
11
|
+
- [TG-INPUT-003](../../rules/TG-INPUT-003-unsafe-html-or-code-execution.md) — Unsafe HTML/Code Execution (High)
|
|
12
|
+
- [TG-INPUT-004](../../rules/TG-INPUT-004-unrestricted-file-upload.md) — Unrestricted File Upload (High)
|
|
13
|
+
|
|
14
|
+
## Hard bans
|
|
15
|
+
|
|
16
|
+
- No raw SQL concatenation with request input
|
|
17
|
+
- No `eval`, `Function()`, or shell execution with untrusted input
|
|
18
|
+
- No unsanitized user HTML via `dangerouslySetInnerHTML`
|
|
19
|
+
- No file upload without size, type, and authorization checks
|
|
20
|
+
- No trust in `req.body.role`, `isAdmin`, or `userId`
|
|
21
|
+
|
|
22
|
+
## Safe defaults
|
|
23
|
+
|
|
24
|
+
- Validate all external input on the server: body, query, params, headers, cookies, webhooks, uploads
|
|
25
|
+
- Treat third-party API and **LLM output** as untrusted
|
|
26
|
+
- Use Zod, Joi, Yup, or Ajv schemas at route entry
|
|
27
|
+
- Parameterized queries or safe ORM APIs only
|
|
28
|
+
- Redirect URLs must use allowlists
|
|
29
|
+
- Uploads: MIME allowlist, size cap, server-generated filenames, storage outside web root
|
|
30
|
+
|
|
31
|
+
## Audit checklist
|
|
32
|
+
|
|
33
|
+
- [ ] Every API route validates input (TG-INPUT-001)
|
|
34
|
+
- [ ] No concatenated SQL (TG-INPUT-002)
|
|
35
|
+
- [ ] No unsafe HTML/code execution (TG-INPUT-003)
|
|
36
|
+
- [ ] Upload routes restricted (TG-INPUT-004)
|
|
37
|
+
|
|
38
|
+
## Framework notes
|
|
39
|
+
|
|
40
|
+
- **Express** — validation middleware before handlers
|
|
41
|
+
- **Next.js** — validate in route handlers and Server Actions
|
|
42
|
+
- **Supabase** — Edge Functions validate before privileged ops
|
|
43
|
+
|
|
44
|
+
## Manual review
|
|
45
|
+
|
|
46
|
+
- Business-logic validation beyond schema (e.g., cross-field rules)
|
|
47
|
+
- NoSQL injection patterns in MongoDB query builders
|
|
48
|
+
|
|
49
|
+
## Related rules
|
|
50
|
+
|
|
51
|
+
TG-AUTH-002, TG-RATE-003, TG-PLATFORM-004
|
package/skills/torusguard/payload/skills/torusguard/references/mass-assignment-and-property-auth.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Mass Assignment and Property Authorization
|
|
2
|
+
|
|
3
|
+
- Explicit writable-field allowlists.
|
|
4
|
+
- DTOs or request schemas.
|
|
5
|
+
- Separate user-editable and server-managed fields.
|
|
6
|
+
- Server-side assignment for role, balance, status, ownership, and verification.
|
|
7
|
+
- Authorization checks for sensitive individual properties.
|
|
8
|
+
- Tests that submit unexpected fields.
|
|
9
|
+
|
|
10
|
+
## Unsafe
|
|
11
|
+
```javascript
|
|
12
|
+
await User.update(req.body, { where: { id: req.user.id } });
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Safe
|
|
16
|
+
```javascript
|
|
17
|
+
const input = updateProfileSchema.parse(req.body);
|
|
18
|
+
await User.update(
|
|
19
|
+
{ displayName: input.displayName, avatarUrl: input.avatarUrl },
|
|
20
|
+
{ where: { id: req.user.id } }
|
|
21
|
+
);
|
|
22
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Platform and HTTP Hardening
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check platform`, deployment prep, or `/TorusGuard verify`.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-PLATFORM-001](../../rules/TG-PLATFORM-001-wildcard-cors-with-credentials.md) — Wildcard CORS + Credentials (High)
|
|
10
|
+
- [TG-PLATFORM-002](../../rules/TG-PLATFORM-002-missing-security-headers.md) — Missing Security Headers (Medium)
|
|
11
|
+
- [TG-PLATFORM-003](../../rules/TG-PLATFORM-003-production-stack-trace-exposure.md) — Stack Trace Exposure (Medium)
|
|
12
|
+
- [TG-PLATFORM-004](../../rules/TG-PLATFORM-004-missing-request-size-limits.md) — Missing Request Size Limits (Medium)
|
|
13
|
+
|
|
14
|
+
## Hard bans
|
|
15
|
+
|
|
16
|
+
- No `Access-Control-Allow-Origin: *` with credentials
|
|
17
|
+
- No production stack traces or raw DB errors to clients
|
|
18
|
+
- No debug mode in production
|
|
19
|
+
- No missing body limits on public JSON endpoints
|
|
20
|
+
- No executable uploads in public web directories
|
|
21
|
+
|
|
22
|
+
## Safe defaults
|
|
23
|
+
|
|
24
|
+
- CORS explicit allowlist
|
|
25
|
+
- Helmet or equivalent: CSP, `X-Content-Type-Options`, HSTS (production), `Referrer-Policy`, clickjacking protection
|
|
26
|
+
- Generic user-facing errors; detailed logs server-side with request ID
|
|
27
|
+
- HTTPS enforced in production
|
|
28
|
+
- `express.json({ limit: '100kb' })` or appropriate caps
|
|
29
|
+
- Dependency audit before deploy
|
|
30
|
+
|
|
31
|
+
## Audit checklist
|
|
32
|
+
|
|
33
|
+
- [ ] CORS allowlist (TG-PLATFORM-001)
|
|
34
|
+
- [ ] Security headers configured (TG-PLATFORM-002)
|
|
35
|
+
- [ ] Errors sanitized (TG-PLATFORM-003)
|
|
36
|
+
- [ ] Request/upload limits set (TG-PLATFORM-004)
|
|
37
|
+
|
|
38
|
+
## Framework notes
|
|
39
|
+
|
|
40
|
+
- **Express** — Helmet + central error handler
|
|
41
|
+
- **Next.js** — headers in `next.config` or middleware
|
|
42
|
+
- **Reverse proxy** — TLS termination, HSTS, rate limits
|
|
43
|
+
|
|
44
|
+
## Manual review
|
|
45
|
+
|
|
46
|
+
- CSP compatibility with actual script/style sources
|
|
47
|
+
- Infrastructure firewall and WAF rules
|
|
48
|
+
- Backup and monitoring configuration
|
|
49
|
+
|
|
50
|
+
## Related rules
|
|
51
|
+
|
|
52
|
+
TG-RATE-003, TG-SEC-004, TG-CLIENT-001
|
|
53
|
+
|
|
54
|
+
## Framework guide
|
|
55
|
+
|
|
56
|
+
[Express Security](../../guides/express-security.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Python Dependencies and Supply Chain
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Python dependency manifests (`requirements.txt`, `pyproject.toml`, `Pipfile`, `poetry.lock`, `uv.lock`) or `.github/workflows/*.yml` are detected.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Lockfile Integrity
|
|
10
|
+
* `TG-SUPPLY-001`: Verify that deterministic lockfiles exist alongside manifests and are not excluded in `.gitignore`.
|
|
11
|
+
|
|
12
|
+
### 2. Known CVE Vulnerability Auditing
|
|
13
|
+
* `TG-SUPPLY-002`: Check for vulnerable dependencies using `pip-audit`. Avoid recommending blind major-version upgrades that introduce breaking changes without tests.
|
|
14
|
+
|
|
15
|
+
### 3. CI/CD Workflow Hardening
|
|
16
|
+
* `TG-SUPPLY-004`: Inspect `.github/workflows/*.yml` for unpinned 3rd-party actions and overbroad default permissions.
|