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,256 @@
|
|
|
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, full_commands=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
|
+
# 5. Register Slash Commands for AI IDEs (.agent, .claude, .cursor)
|
|
141
|
+
print("\n3. Registering slash commands with AI IDE environments...")
|
|
142
|
+
registered_ides = []
|
|
143
|
+
tg_workflow_content = """---
|
|
144
|
+
description: TorusGuard Autonomous Security Command Engine — run static security audits, authorized runtime web validation, governed remediation, and SARIF exports.
|
|
145
|
+
version: 0.9.2
|
|
146
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
147
|
+
agent: auditor
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
# /torusguard — Autonomous Application Security Guardrails
|
|
151
|
+
|
|
152
|
+
$ARGUMENTS
|
|
153
|
+
|
|
154
|
+
## Objective
|
|
155
|
+
Execute TorusGuard security workflows across Python and TypeScript codebases.
|
|
156
|
+
|
|
157
|
+
## Execution
|
|
158
|
+
Parse the requested action from `$ARGUMENTS` (e.g. `audit`, `verify`, `web-validate`, `exploit-check`, `harden`, `apply`, `recheck`, `report`, `status`, `init`):
|
|
159
|
+
1. **If action is omitted or 'status':** View `.torusguard/workflows/status.md` and report posture.
|
|
160
|
+
2. **If action is specified:** Load the dedicated workflow from `.torusguard/workflows/<action>.md` and matching skill from `.torusguard/skills/torusguard-<action>/SKILL.md`.
|
|
161
|
+
3. Follow the phase execution steps defined in the workflow.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
# Ensure .agent/workflows and .agents/workflows are created
|
|
165
|
+
dest_workflow_dirs = []
|
|
166
|
+
if (target_root / ".agents").exists():
|
|
167
|
+
agents_wf = target_root / ".agents" / "workflows"
|
|
168
|
+
agents_wf.mkdir(parents=True, exist_ok=True)
|
|
169
|
+
(agents_wf / "torusguard.md").write_text(tg_workflow_content, encoding="utf-8")
|
|
170
|
+
dest_workflow_dirs.append(agents_wf)
|
|
171
|
+
registered_ides.append("Antigravity / Gemini (.agents/workflows/torusguard.md)")
|
|
172
|
+
|
|
173
|
+
agent_wf = target_root / ".agent" / "workflows"
|
|
174
|
+
agent_wf.mkdir(parents=True, exist_ok=True)
|
|
175
|
+
(agent_wf / "torusguard.md").write_text(tg_workflow_content, encoding="utf-8")
|
|
176
|
+
dest_workflow_dirs.append(agent_wf)
|
|
177
|
+
registered_ides.append("Antigravity / Tribunal (.agent/workflows/torusguard.md)")
|
|
178
|
+
|
|
179
|
+
# When full_commands is requested (e.g. via NPM package npx torusguard init),
|
|
180
|
+
# unlock and register all 11 individual slash commands (/torusguard-audit, /torusguard-harden, etc.)
|
|
181
|
+
if full_commands:
|
|
182
|
+
src_wf = torusguard_target / "workflows"
|
|
183
|
+
if src_wf.is_dir():
|
|
184
|
+
count = 0
|
|
185
|
+
for wf_file in src_wf.glob("*.md"):
|
|
186
|
+
if wf_file.name == "torusguard.md":
|
|
187
|
+
continue
|
|
188
|
+
cmd_filename = f"torusguard-{wf_file.name}"
|
|
189
|
+
for d in dest_workflow_dirs:
|
|
190
|
+
shutil.copy2(wf_file, d / cmd_filename)
|
|
191
|
+
count += 1
|
|
192
|
+
registered_ides.append(f"Unlocked {count} Individual Slash Commands (/torusguard-audit, /torusguard-apply, etc.)")
|
|
193
|
+
|
|
194
|
+
# Claude Code (.claude/commands)
|
|
195
|
+
claude_dir = target_root / ".claude"
|
|
196
|
+
if claude_dir.exists():
|
|
197
|
+
claude_commands = claude_dir / "commands"
|
|
198
|
+
claude_commands.mkdir(parents=True, exist_ok=True)
|
|
199
|
+
(claude_commands / "torusguard.md").write_text(tg_workflow_content, encoding="utf-8")
|
|
200
|
+
registered_ides.append("Claude Code (.claude/commands/torusguard.md)")
|
|
201
|
+
|
|
202
|
+
# Cursor (.cursor/rules)
|
|
203
|
+
cursor_dir = target_root / ".cursor"
|
|
204
|
+
if cursor_dir.exists():
|
|
205
|
+
cursor_rules = cursor_dir / "rules"
|
|
206
|
+
cursor_rules.mkdir(parents=True, exist_ok=True)
|
|
207
|
+
(cursor_rules / "torusguard.mdc").write_text(tg_workflow_content, encoding="utf-8")
|
|
208
|
+
registered_ides.append("Cursor (.cursor/rules/torusguard.mdc)")
|
|
209
|
+
|
|
210
|
+
# Windsurf (.windsurfrules)
|
|
211
|
+
if (target_root / ".windsurfrules").exists() or (target_root / ".windsurf").exists():
|
|
212
|
+
windsurf_rules = target_root / ".windsurfrules"
|
|
213
|
+
current_content = windsurf_rules.read_text(encoding="utf-8") if windsurf_rules.exists() else ""
|
|
214
|
+
if "TorusGuard" not in current_content:
|
|
215
|
+
windsurf_rules.write_text(current_content + "\n\n" + tg_workflow_content, encoding="utf-8")
|
|
216
|
+
registered_ides.append("Windsurf (.windsurfrules)")
|
|
217
|
+
|
|
218
|
+
# VS Code / GitHub Copilot (.github/copilot-instructions.md)
|
|
219
|
+
github_dir = target_root / ".github"
|
|
220
|
+
if github_dir.exists():
|
|
221
|
+
copilot_file = github_dir / "copilot-instructions.md"
|
|
222
|
+
current_content = copilot_file.read_text(encoding="utf-8") if copilot_file.exists() else ""
|
|
223
|
+
if "TorusGuard" not in current_content:
|
|
224
|
+
copilot_file.write_text(current_content + "\n\n# TorusGuard Security Instructions\n" + tg_workflow_content, encoding="utf-8")
|
|
225
|
+
registered_ides.append("VS Code / Copilot (.github/copilot-instructions.md)")
|
|
226
|
+
|
|
227
|
+
# Universal AGENTS.md (Kimi, Codex, Open Agent Standard)
|
|
228
|
+
agents_md = target_root / "AGENTS.md"
|
|
229
|
+
current_agents = agents_md.read_text(encoding="utf-8") if agents_md.exists() else ""
|
|
230
|
+
if "TorusGuard" not in current_agents:
|
|
231
|
+
agents_md.write_text(current_agents + ("\n\n" if current_agents else "") + "# TorusGuard Security Guardrails\n\nRun `/torusguard audit` to scan the codebase or refer to `.torusguard/` for security guidelines.\n", encoding="utf-8")
|
|
232
|
+
registered_ides.append("Universal Agent Standard (AGENTS.md for Kimi / Open Agents)")
|
|
233
|
+
|
|
234
|
+
for r in registered_ides:
|
|
235
|
+
print(f" [REGISTERED] {r}")
|
|
236
|
+
|
|
237
|
+
print("\n================================================================================")
|
|
238
|
+
print("[SUCCESS] TORUSGUARD WORKSPACE SCAFFOLDED SUCCESSFULLY!")
|
|
239
|
+
print("================================================================================")
|
|
240
|
+
print(f"Workspace Path: {torusguard_target}")
|
|
241
|
+
print("\nNext Steps:")
|
|
242
|
+
print(" 1. Run `/torusguard audit` in your AI IDE to scan the project.")
|
|
243
|
+
print(" 2. Run `/torusguard status` to verify active security posture.")
|
|
244
|
+
print("================================================================================")
|
|
245
|
+
return True
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
if __name__ == "__main__":
|
|
249
|
+
parser = argparse.ArgumentParser(description="TorusGuard Autonomous Workspace Bootstrapper")
|
|
250
|
+
parser.add_argument("--target", type=str, help="Target project root directory")
|
|
251
|
+
parser.add_argument("--force", action="store_true", help="Force overwrite existing workspace")
|
|
252
|
+
parser.add_argument("--full-commands", action="store_true", help="Unlock and register all 11 individual slash commands")
|
|
253
|
+
args = parser.parse_args()
|
|
254
|
+
|
|
255
|
+
success = scaffold_workspace(target_root=args.target, force=args.force, full_commands=args.full_commands)
|
|
256
|
+
sys.exit(0 if success else 1)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ARCHITECTURE.md": "0ecacc797932daaf95ccf5032c47f11550c9b6fe07cdfece5c075e11ec5e9cf7",
|
|
3
|
+
"TORUSGUARD.md": "c980b0ddd3778d5981f6c16c64015c60dc713b6f151fc531bc5681ecd770fb50",
|
|
4
|
+
"agents/auditor.md": "4ba2c92982823d0886c7ae369126cd5ddd322085a85d3b7e7fa23154f8753314",
|
|
5
|
+
"agents/profiler.md": "0ee9ebbddf4ebd557d454dda8472fffea471e263abeccf40298163084b7ce9a9",
|
|
6
|
+
"agents/remediator.md": "f708a0e315760e8d519bd640d22bdf6b7ec61ed7de3da69bd038bd60dc3d5b47",
|
|
7
|
+
"agents/reviewer.md": "69b280bb8a7b2fe425644d01a6f9cb454f9629f348782cd14968657076977c28",
|
|
8
|
+
"agents/validator.md": "79fc4431de5c5507f8730aee6c5c3e61fd238cbf8cf8c7c6aac462eee9761ed6",
|
|
9
|
+
"config/scope.json": "b198a86186b4c6d5e1af516bf4e3a6afa8878e622ca1d57a5bf72d294f8c6f25",
|
|
10
|
+
"config/slash-commands.json": "5390f0d26f8117a62e56c58147d3a0d2deab1a20956302b212703281d13fa84e",
|
|
11
|
+
"config/torusguard.json": "5f775da1f77aaffcd8173fac6a8f422ecc4d754627cb1f3c71d014dad299101d",
|
|
12
|
+
"references/django-security.md": "a15b7eb11b51dd1970d3d65544cf79ebea91fb99dc0e085e58a56532a718dce7",
|
|
13
|
+
"references/drf-security.md": "c7a7af3acaef895bf4798590acc88b3a2e9831a49eb2d23b4d8f31540ab264cc",
|
|
14
|
+
"references/express-security.md": "dff1db15e614d29d8c272f9da345b418077e62dc883fe210c7a50c552c76493f",
|
|
15
|
+
"references/fastapi-security.md": "933a08a3f096f70cb75c6a1e6d887c96a1613bb9f9def3904bb76e8c21cc7668",
|
|
16
|
+
"references/firebase-security.md": "11b1c51d530ff70230e2419475fceb9382f05c4334145366c66bb1304448f5b5",
|
|
17
|
+
"references/flask-security.md": "96d438980272f6fa95c825ef01baae55989c19618470b044dde1458a421a92f4",
|
|
18
|
+
"references/nextjs-security.md": "57f17d00ce24bf06d2826ab9d774177342ff892f6c9bc4193d6b65345d6c7661",
|
|
19
|
+
"references/react-vite-security.md": "d6468a6f623f02e58250a43327e27825b5dc7df34edf6ee27da2398bab94d6a4",
|
|
20
|
+
"references/sqlalchemy-security.md": "50421be1fba477721f9f1f5a877d4359420cf61ee9bda136e21998a3c1338e1c",
|
|
21
|
+
"references/supabase-security.md": "52a53aff66b3d94e5d07484f458252015ad3d713fa07162f59db89581ee597b6",
|
|
22
|
+
"rules/README.md": "a1b80344b0ca199a4917bdbd00463a8ae1459187f65467dbd627ce93a103042e",
|
|
23
|
+
"rules/TORUSGUARD.md": "fc7e0852ae0a92c45017f11dbc83c562b94ab957e7816d9903b95fb6849a9e5b",
|
|
24
|
+
"rules/active/TG-DIFF-001.md": "f67be0f2725eb23c3d11a8a7a4c29dcee648d3f9743e122a2197e8892f4da4de",
|
|
25
|
+
"rules/active/TG-DIFF-002.md": "1058cf5ba4e700176cf74eb55fb6304d320d3be5fdd011c5c61780d2a99c1a0e",
|
|
26
|
+
"rules/active/TG-DIFF-003.md": "0ffc0872ba4e0db9d087d5f2764d5d178401d2fab3cb1d129b387452ca489741",
|
|
27
|
+
"schemas/authorization.schema.json": "59af3c6038270e0bc3541a353b2a4a53b7f5d11a37e0012875d6a69c0f1d0bab",
|
|
28
|
+
"schemas/confidence.schema.json": "08b3a564d7370e123dd5bfadde9fb077d2954e36b523685b9e1d7bdd2aa4b8cb",
|
|
29
|
+
"schemas/evidence.schema.json": "d3dcaa10fd2420a4046ea68836fb836a55d003ada4cdc6682229f232881182bf",
|
|
30
|
+
"schemas/finding.schema.json": "e0a7c28fa4a5f84bdedb5cf5223da26348250d633479d2dbf7ce3ebd6790a852",
|
|
31
|
+
"schemas/provenance.schema.json": "781215801249532414643638b6608dc8f52febc9bca43ae03827b90aecc03256",
|
|
32
|
+
"schemas/remediation.schema.json": "217cb2743ae1a912dc074382e9f05634da93f2e30a880c03f6020600ef7e43d3",
|
|
33
|
+
"schemas/retest.schema.json": "773b764082f6d2e8c3656ea105e0ce09febd1020520bf262bbcd17f5924da11e",
|
|
34
|
+
"schemas/runtime-evidence.schema.json": "dbe13741a7fb68cca2a044d47a644ee0bdaacb83a28621dc2a98bffdd59989a6",
|
|
35
|
+
"scripts/diff_guard.py": "227bf56d2e6c9aef293a51ad1a3209782e6d9204dc1775956d372c3a6851a736",
|
|
36
|
+
"scripts/finding_scorer.py": "b78c6315f22000fb64f5d4e6ff1f3467439769d3d5507aaa99380453df4eb464",
|
|
37
|
+
"scripts/manifest_builder.py": "b759131592966053db17ef710dc5f313127a9583295cb867a39ab22a7c996580",
|
|
38
|
+
"scripts/monorepo_detector.py": "38f1eb948ee2856f175e1212956bce211effdd1327d3a31f7303d32ba9478ebe",
|
|
39
|
+
"scripts/run_manager.py": "e853874e4fb0cb697596ea338f71ba7e955f2b41a6fc649733b45fa755e94768",
|
|
40
|
+
"scripts/safety_gate.py": "3379b7534b2590cf563717a448983ad8ed7e8f174f0ad65683d33e8a10f51558",
|
|
41
|
+
"scripts/sarif_exporter.py": "35c66637413afc4b72d5bd426638447c77231d2a8594dce5addceffd4803a20d",
|
|
42
|
+
"scripts/stack_detect.py": "99b7bdf9829d58ff5b8c59afd6e8b6429bbb11d830ac73dec491101cbbc41574",
|
|
43
|
+
"skills/torusguard/SKILL.md": "70094a7ee80c3d827f9f9437effe3433fe0da53c0389f9ad28aed199a0e3f3d4",
|
|
44
|
+
"skills/torusguard/bootstrap.py": "7e348065a622089ab1d51e9bf4864e5b0022aaee1ccb2ecbf7057c14e792e2c7",
|
|
45
|
+
"skills/torusguard/references/auth-and-sessions.md": "34c2843f8c0dbe3574e54f00a39a92a1f431527ec5f69b2d64c84240d424a39e",
|
|
46
|
+
"skills/torusguard/references/business-logic-and-abuse.md": "0d6088936bc1a01023070332fccef0f2e0734358a5119379055f3d2895c22567",
|
|
47
|
+
"skills/torusguard/references/cache-and-sensitive-responses.md": "8f920cacde29c50b1f5f98de341a60db0bc607fe8c212a7e618ef7af08c86511",
|
|
48
|
+
"skills/torusguard/references/client-code-exposure.md": "1810b18c3b89a25d3f5ef9bc53a721b9d05179bcd2086d6679ad1f29f5403bb9",
|
|
49
|
+
"skills/torusguard/references/csrf-and-cross-origin.md": "1bab49feee1f31fa6b280ddba893fe5ffa0c3c9ac0a46fc4d6c96c1206b32204",
|
|
50
|
+
"skills/torusguard/references/dependency-and-supply-chain.md": "3b429214af8d1271f5e6dc24ac5ecc9a7bdaff6116a96dc60a89a2057d8d1d2a",
|
|
51
|
+
"skills/torusguard/references/django-security.md": "a15b7eb11b51dd1970d3d65544cf79ebea91fb99dc0e085e58a56532a718dce7",
|
|
52
|
+
"skills/torusguard/references/drf-security.md": "c7a7af3acaef895bf4798590acc88b3a2e9831a49eb2d23b4d8f31540ab264cc",
|
|
53
|
+
"skills/torusguard/references/fastapi-security.md": "933a08a3f096f70cb75c6a1e6d887c96a1613bb9f9def3904bb76e8c21cc7668",
|
|
54
|
+
"skills/torusguard/references/flask-security.md": "96d438980272f6fa95c825ef01baae55989c19618470b044dde1458a421a92f4",
|
|
55
|
+
"skills/torusguard/references/frontend-no-db.md": "a543c8107605777a16a0abfd5ebbaca6f216ac50f078a8c3ef485a5afe6bfdca",
|
|
56
|
+
"skills/torusguard/references/graphql-security.md": "486e7a54e9ad677ff6d08016f0d4e1f173ccbba5c89e7e806a7097e3265442cd",
|
|
57
|
+
"skills/torusguard/references/input-and-injection.md": "e632ab3031088f3f13be826886430ea7f0abf02922e29c26507f3c234c00f00d",
|
|
58
|
+
"skills/torusguard/references/mass-assignment-and-property-auth.md": "fcddd881573c1bc8fc703a796b1ddc9ba9bd8e0cc0d51d8e9a59e79cc9a5ebd9",
|
|
59
|
+
"skills/torusguard/references/platform-hardening.md": "c58d1a86536cbaeb548d8cfeaa298e3662a4367854512858bbf594735dc6f717",
|
|
60
|
+
"skills/torusguard/references/python-dependencies.md": "34969226665d60d22e658a1801cb6857a56ea669859abcf617a8b985a26f952d",
|
|
61
|
+
"skills/torusguard/references/python-security-overview.md": "2165747d64b86b12a744ee4f21ea918678bd6a179793a37bd02b2c0953190a9b",
|
|
62
|
+
"skills/torusguard/references/rate-limit-and-abuse.md": "77c5c982d9e28d7e3c1871172bdbfe76542e356d97f2197f5df0a4f56405bc21",
|
|
63
|
+
"skills/torusguard/references/secrets-and-config.md": "9abe5fe9e6556a2ffc1460876e9c98f6eacf683cd0d8a7dba82eaeef825133c6",
|
|
64
|
+
"skills/torusguard/references/sqlalchemy-security.md": "50421be1fba477721f9f1f5a877d4359420cf61ee9bda136e21998a3c1338e1c",
|
|
65
|
+
"skills/torusguard/references/ssrf-and-outbound-requests.md": "31c6c69ba14ca4a1fb866654f6c89a5c8edd636724c9d349be94c160c976749c",
|
|
66
|
+
"skills/torusguard/references/webhook-security.md": "a0c7efb663c664dd840ba99b689cb67d4688643106f8b6e80d18a424c6add386",
|
|
67
|
+
"skills/torusguard/references/websocket-security.md": "5624a84abd75bbb4eed029cd217e0c794ee452cbecc0730a8ab4d0f371537cd7",
|
|
68
|
+
"skills/torusguard-apply/SKILL.md": "9436fa5cdefa661677ada22936a3949de06aca276e4f4bb27e0ef5b7ea34edc3",
|
|
69
|
+
"skills/torusguard-audit/SKILL.md": "d0e0c21d6c36d9d128ccce6ad628b978ff771d27552ba80e0a4981e18b9f5a51",
|
|
70
|
+
"skills/torusguard-authorize/SKILL.md": "da849585f2e46c08ef528b89737be14647f1109fd365fd27f3f6da57a396724b",
|
|
71
|
+
"skills/torusguard-exploit-check/SKILL.md": "e9a173e154a88cc9cb929c59d79a65ab13d5cf9567b4112bd7f272746cf9c3f9",
|
|
72
|
+
"skills/torusguard-full/SKILL.md": "cc97684d37de378e51fefd12f6f9a7cd15cc469ce46079a0599440aa7b073f7b",
|
|
73
|
+
"skills/torusguard-harden/SKILL.md": "86a8dee6c614477e2122287752f5c16e3688c0451d0e7ae9bfd2a23802bcdde3",
|
|
74
|
+
"skills/torusguard-init/SKILL.md": "1f7844d66219955581fdb266029eefdc355dbebb5741b848daf0062e606202a2",
|
|
75
|
+
"skills/torusguard-recheck/SKILL.md": "4725a9be6a6ddedb3d389d1957c7ce3e0f9ce288107816fce85b5953951e13e5",
|
|
76
|
+
"skills/torusguard-report/SKILL.md": "bde44d114bdc85c04472644a644a7796ed2f182a23e0c057838a3251e4910a09",
|
|
77
|
+
"skills/torusguard-status/SKILL.md": "4e71d03c71b240afd7f6108569530b7da3702634c512a74ca8dc3174f3c6b0fb",
|
|
78
|
+
"skills/torusguard-verify/SKILL.md": "10c19e0926255686351e3b75ae774880cf35562d42bd30b87a877bb8f284fc1f",
|
|
79
|
+
"skills/torusguard-web-validate/SKILL.md": "0d159f0d75f06ca97f64a52f3e414c873f8bb84b87a8230693237cde302e76ac",
|
|
80
|
+
"templates/audit-report.template.md": "71149dd05b01a74287a47781fdc71fd2d1b4b70337da303bf78767d0410a6c90",
|
|
81
|
+
"templates/authorization.template.md": "81ef843d42a19412c369f383b787465ac24173c0b14c1f5f211786eab3d10e8b",
|
|
82
|
+
"templates/finding-card.template.md": "8f756edbd3e4139d3da2fb96f35bd2d2b267b33b754f187b590a89584265c1e6",
|
|
83
|
+
"templates/remediation-bundle.template.md": "4d85a540e3a2e74f9b21fc8a2a1072e27ca03e97cd67ca482f529cfe722acc4d",
|
|
84
|
+
"workflows/apply.md": "ca7fe662f5af462d036d17ecc7e82ab8a08e1989325e9e037df6364af96e2706",
|
|
85
|
+
"workflows/audit.md": "d924b7c02d7a380c68e5c8faa69103194b098119e34c5b427585eec66f8081ca",
|
|
86
|
+
"workflows/authorize.md": "a797addf98eb0cf29acbc9dc8f21f0d61ea93cc83255379d4722ab5ce86a4c29",
|
|
87
|
+
"workflows/exploit-check.md": "9684009b835a61d5aca8827a971ee686a24c800425d86ef96f963dd27de845b8",
|
|
88
|
+
"workflows/harden.md": "509484f844c9dcd10dd14c8bb6e3456021928e6cf6abd374faaf34be8fc34ce2",
|
|
89
|
+
"workflows/init.md": "3d1668a9f6b87417c31f47c887c495f863595ed4a29074e0c5a8ee1ece1d4a35",
|
|
90
|
+
"workflows/recheck.md": "7d374c29a5585c31b81f84fb32d6a466f2e9cb339726dc0523dba25e57bc5d13",
|
|
91
|
+
"workflows/report.md": "56b3449cff362172c63093ee6150446d11bf05e3c8143661966dad9d42df1470",
|
|
92
|
+
"workflows/status.md": "921129646518c592cb47ad8e8ccf3d703e8d11ea6eb89bd21a206f545e022dba",
|
|
93
|
+
"workflows/verify.md": "e1041c38e8ada59788f66ac1bc754313a4c966c36f4c13aa6d9d9a2b90d9e06c",
|
|
94
|
+
"workflows/web-validate.md": "d3db1fea264cd89addffbc227d8452987b050e533993c394d537f50c177224d4"
|
|
95
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# 🛡️ TorusGuard Security Kit v0.9.1 — System Architecture
|
|
2
|
+
|
|
3
|
+
TorusGuard works natively in **Antigravity**, **Cursor**, **Windsurf**, **Claude Code**, **Cline**, and any AI IDE or coding assistant that indexes workspace security guardrails.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. System Flow & Execution Lifecycle
|
|
8
|
+
|
|
9
|
+
Every security operation, static scan, runtime probe, and remediation patch progresses through an auditable, deterministic 7-stage closed-loop pipeline:
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
flowchart TD
|
|
13
|
+
A["User Request / Slash Command"] --> B{"Classify Action"}
|
|
14
|
+
|
|
15
|
+
B -->|/torusguard init| C["Phase 0: Baseline Discovery"]
|
|
16
|
+
B -->|/torusguard authorize| D["Phase 1: Legal Scope Gate"]
|
|
17
|
+
B -->|/torusguard audit| E["Phase 2: Static Scan & Cluster"]
|
|
18
|
+
B -->|/torusguard verify| F["Phase 3a: Evidence Verification"]
|
|
19
|
+
B -->|/torusguard web-validate| G["Phase 3b: Runtime Probing"]
|
|
20
|
+
B -->|/torusguard exploit-check| H["Phase 3c: Exploitability Check"]
|
|
21
|
+
B -->|/torusguard harden| I["Phase 4: Remediation Bundles"]
|
|
22
|
+
B -->|/torusguard apply| J["Phase 5: Governed Patch Apply"]
|
|
23
|
+
B -->|/torusguard recheck| K["Phase 6: Regression Re-scan"]
|
|
24
|
+
B -->|/torusguard report| L["Phase 7: Report & SARIF Export"]
|
|
25
|
+
B -->|/torusguard status| M["Diagnostic Overview"]
|
|
26
|
+
B -->|/torusguard full| N["End-to-End Orchestrator"]
|
|
27
|
+
|
|
28
|
+
C --> C1["Detect Stack & Activate TG-* Rules"]
|
|
29
|
+
D --> D1["Validate Ownership & Write scope.json"]
|
|
30
|
+
E --> E1["AST Matching + Line Hash Fingerprints + Root-Cause Clustering"]
|
|
31
|
+
|
|
32
|
+
E1 --> F1{"Confidence Score"}
|
|
33
|
+
F1 -->|Medium / High| G1{"Authorized for Runtime?"}
|
|
34
|
+
G1 -->|Yes| G
|
|
35
|
+
G1 -->|No| I
|
|
36
|
+
|
|
37
|
+
G --> H1["Redact Tokens & Capture Replay Trace"]
|
|
38
|
+
H --> H2["Update Confidence with Runtime Verdict"]
|
|
39
|
+
H2 --> I
|
|
40
|
+
|
|
41
|
+
I --> I1["Enforce Ponytail Limits (<=35 add, <=25 del)"]
|
|
42
|
+
I1 --> I2{"Human Gate Review"}
|
|
43
|
+
I2 -->|Approved| J
|
|
44
|
+
I2 -->|Rejected / Revised| I
|
|
45
|
+
|
|
46
|
+
J --> J1["Save Pre-Apply Snapshot & Apply Surgical Diffs"]
|
|
47
|
+
J1 --> K
|
|
48
|
+
|
|
49
|
+
K --> K1{"Classify Outcome"}
|
|
50
|
+
K1 -->|Fixed| L
|
|
51
|
+
K1 -->|Partially Fixed| I
|
|
52
|
+
K1 -->|Regression| J2["Rollback Snapshot & Alert"]
|
|
53
|
+
|
|
54
|
+
L --> L1["Emit summary.md + OASIS SARIF v2.1.0"]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 2. Decoupled Specialist Skills & Lazy Routing
|
|
60
|
+
|
|
61
|
+
TorusGuard enforces **strict context budget discipline**. Rather than dumping monolithic rules into the LLM context, each task routes to an atomic specialist skill:
|
|
62
|
+
|
|
63
|
+
- **Startup Overhead**: ~50–150 tokens per specialized task vs 85,000+ tokens for full-repo manual review.
|
|
64
|
+
- **Zero Hallucination Grounding**: Every specialist skill embeds its own execution steps, safety constraints, and scoring models inline.
|
|
65
|
+
- **Lazy Resolution**: The root `torusguard` router intercepts commands and loads exclusively the matching specialist file.
|
|
66
|
+
|
|
67
|
+
| Specialist Skill | Agent Role | Focus Area | Context Budget |
|
|
68
|
+
| :--- | :--- | :--- | :---: |
|
|
69
|
+
| `torusguard-init` | `profiler` | Framework & data layer discovery | 120 lines |
|
|
70
|
+
| `torusguard-authorize` | `reviewer` | Ownership confirmation & scope limits | 94 lines |
|
|
71
|
+
| `torusguard-audit` | `auditor` | Static AST scanning & root-cause clustering | 150 lines |
|
|
72
|
+
| `torusguard-verify` | `validator` | Fresh disk state check & score computation | 90 lines |
|
|
73
|
+
| `torusguard-web-validate`| `validator` | Bounded HTTP probing & token redaction | 124 lines |
|
|
74
|
+
| `torusguard-exploit-check`| `validator` | Safe canary verification for SQLi/XSS/SSRF | 100 lines |
|
|
75
|
+
| `torusguard-harden` | `remediator` | Ponytail-bounded remediation bundles | 105 lines |
|
|
76
|
+
| `torusguard-apply` | `remediator` | Pre-apply snapshots & surgical application | 71 lines |
|
|
77
|
+
| `torusguard-recheck` | `reviewer` | Differential regression detection | 89 lines |
|
|
78
|
+
| `torusguard-report` | `reviewer` | Executive posture & OASIS SARIF v2.1.0 | 102 lines |
|
|
79
|
+
| `torusguard-status` | *System* | Read-only configuration & history ledger | 80 lines |
|
|
80
|
+
| `torusguard-full` | *All Roles* | 7-stage master pipeline orchestrator | 165 lines |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 3. Authority Separation & Role Handoff Contracts
|
|
85
|
+
|
|
86
|
+
To prevent self-confirming bias, security responsibilities are divided across 5 formal roles:
|
|
87
|
+
|
|
88
|
+
1. **Profiler (`profiler.md`)**:
|
|
89
|
+
- Discovers project languages, frameworks, dependency manifests, and database layers.
|
|
90
|
+
- *Authority Boundary*: Read-only inspection; never alters source code.
|
|
91
|
+
2. **Auditor (`auditor.md`)**:
|
|
92
|
+
- Scans source ASTs, computes line-shift invariant fingerprints, groups findings by root-cause cluster, and scores initial confidence.
|
|
93
|
+
- *Authority Boundary*: Read-only; cannot mark findings as "Confirmed" without exact AST source citations.
|
|
94
|
+
3. **Validator (`validator.md`)**:
|
|
95
|
+
- Executes authorized runtime HTTP probes, performs safe canary checks, redacts secrets, and assigns exploitability verdicts.
|
|
96
|
+
- *Authority Boundary*: Bound strictly by `scope.json`; cannot execute destructive write mutations.
|
|
97
|
+
4. **Remediator (`remediator.md`)**:
|
|
98
|
+
- Packages minimal unified diffs constrained by Ponytail Protocol bounds and applies governed patches.
|
|
99
|
+
- *Authority Boundary*: Must obtain Human Gate approval before disk modification; must save pre-apply snapshots.
|
|
100
|
+
5. **Reviewer (`reviewer.md`)**:
|
|
101
|
+
- Re-scans modified files to verify fix integrity, audits evidence sufficiency, detects regressions, and exports SARIF logs.
|
|
102
|
+
- *Authority Boundary*: Independent audit of remediator outputs; cannot apply code modifications.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 4. Governance & Safety Enforcement
|
|
107
|
+
|
|
108
|
+
### The Ponytail Protocol
|
|
109
|
+
```
|
|
110
|
+
┌────────────────────────────────────────────────────────┐
|
|
111
|
+
│ PONYTAIL PROTOCOL BOUNDS │
|
|
112
|
+
├────────────────────────────────────────────────────────┤
|
|
113
|
+
│ • Additions: <= 35 lines per bundle │
|
|
114
|
+
│ • Deletions: <= 25 lines per bundle │
|
|
115
|
+
│ • Zero full-file rewrites │
|
|
116
|
+
│ • Preserve all existing tenant isolation & auth checks │
|
|
117
|
+
│ • Preserve all existing logging & error handling │
|
|
118
|
+
└────────────────────────────────────────────────────────┘
|
|
119
|
+
```
|
|
120
|
+
Any remediation exceeding these thresholds is partitioned into sequential atomic sub-bundles or flagged as `Requires Manual Architectural Refactor`.
|
|
121
|
+
|
|
122
|
+
### Universal Safety Constraints
|
|
123
|
+
- **Folder-Per-Run Isolation**: All logs, findings, bundles, and reports are saved to `.torusguard/runs/<run-id>/`. The project root is never polluted.
|
|
124
|
+
- **Rollback Assurance**: A byte-for-byte pre-apply snapshot is archived in `patches/<bundle-id>/pre_apply/` prior to any code edit.
|
|
125
|
+
- **Credential Redaction**: Raw secrets, Bearer JWTs, and database credentials are automatically redacted with SHA-256 prefix digests before disk persistence.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 5. Objective 0–100 Confidence Scoring Rubric
|
|
130
|
+
|
|
131
|
+
Finding confidence is scored objectively across 5 verifiable factors:
|
|
132
|
+
|
|
133
|
+
| Dimension | Max Points | Criteria |
|
|
134
|
+
| :--- | :---: | :--- |
|
|
135
|
+
| **Evidence Quality** | **35** | Exact AST match (35) · Regex pattern (20) · Indirect indicator (10) |
|
|
136
|
+
| **Reproduction Success** | **25** | Deterministic test reproduction (25) · Partial trace (15) · Static only (0) |
|
|
137
|
+
| **Independent Confirmations** | **15** | Corroborated in 3+ files (15) · 2 files (10) · Single file (5) |
|
|
138
|
+
| **Environmental Clarity** | **15** | Direct route mapping (15) · Minor ambiguity (8) · Complex unknown proxy (0) |
|
|
139
|
+
| **Manual Review Status** | **10** | Security engineer verified (10) · Secondary agent consensus (5) · Unreviewed (0) |
|
|
140
|
+
|
|
141
|
+
- **`90–100` (`Confirmed`)**: Indisputable proof with code citation or deterministic trace.
|
|
142
|
+
- **`70–89` (`High Confidence`)**: Strong direct indicators; prioritized remediation.
|
|
143
|
+
- **`50–69` (`Medium Confidence`)**: Probable flaw; runtime confirmation recommended.
|
|
144
|
+
- **`< 50` (`Needs Review`)**: Architectural ambiguity or potential delegated control.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 6. Directory Topology
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
.torusguard/
|
|
152
|
+
├── TORUSGUARD.md # Master always-on security rules
|
|
153
|
+
├── ARCHITECTURE.md # System architecture & lifecycle blueprint
|
|
154
|
+
├── .manifest.json # Cryptographic SHA-256 integrity ledger
|
|
155
|
+
├── config/ # Project configuration & command registry
|
|
156
|
+
├── agents/ # 5 Specialist AI Agent definitions
|
|
157
|
+
├── workflows/ # 11 Slash command execution guides
|
|
158
|
+
├── scripts/ # 5 Pure Python automation utilities
|
|
159
|
+
├── skills/ # Mirrored specialist skills
|
|
160
|
+
├── templates/ # 4 Standard Markdown report templates
|
|
161
|
+
├── schemas/ # 9 Validated JSON Schemas
|
|
162
|
+
├── references/ # 10 Framework security reference guides
|
|
163
|
+
├── rules/ # Rule taxonomy & active tailored rules
|
|
164
|
+
│ ├── active/ # Project-tailored rules
|
|
165
|
+
│ ├── README.md # Rule catalog & guide
|
|
166
|
+
│ └── TORUSGUARD.md # Dual-path master rules copy
|
|
167
|
+
└── runs/ # Execution artifacts directory (gitignored)
|
|
168
|
+
```
|