torusguard 1.3.5 → 1.3.6
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 +35 -35
- package/.torusguard/runs/report-latest.html +2685 -303
- package/.torusguard/runs/results-latest.sarif +20 -0
- package/.torusguard/runs/run-20260918-104221-audit/findings.json +1 -0
- package/.torusguard/runs/run-20260918-104221-audit/findings.md +8 -0
- package/.torusguard/runs/run-20260918-104221-audit/manifest.json +12 -0
- package/.torusguard/runs/run-20260918-104221-audit/summary.md +5 -0
- package/.torusguard/runs/run-20260918-104236-audit/findings.json +2314 -0
- package/.torusguard/runs/run-20260918-104236-audit/findings.md +960 -0
- package/.torusguard/runs/run-20260918-104236-audit/manifest.json +12 -0
- package/.torusguard/runs/run-20260918-104236-audit/summary.md +5 -0
- package/.torusguard/runs/run-20260918-105723-audit/findings.json +2382 -0
- package/.torusguard/runs/run-20260918-105723-audit/findings.md +960 -0
- package/.torusguard/runs/run-20260918-105723-audit/manifest.json +12 -0
- package/.torusguard/runs/run-20260918-105723-audit/summary.md +5 -0
- package/.torusguard/runs/run-20260918-105731-audit/findings.json +1 -0
- package/.torusguard/runs/run-20260918-105731-audit/findings.md +8 -0
- package/.torusguard/runs/run-20260918-105731-audit/manifest.json +12 -0
- package/.torusguard/runs/run-20260918-105731-audit/summary.md +5 -0
- package/.torusguard/runs/run-20260918-105940-audit/findings.json +1 -0
- package/.torusguard/runs/run-20260918-105940-audit/findings.md +8 -0
- package/.torusguard/runs/run-20260918-105940-audit/manifest.json +12 -0
- package/.torusguard/runs/run-20260918-105940-audit/summary.md +5 -0
- package/.torusguard/scripts/__pycache__/apply_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/diff_guard.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/harden_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/html_reporter.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/memory_engine.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/recheck_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/report_sync.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/run_manager.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/sarif_exporter.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/stack_detect.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
- package/.torusguard/scripts/apply_runner.py +11 -5
- package/.torusguard/scripts/audit_runner.py +222 -15
- package/.torusguard/scripts/harden_runner.py +3 -3
- package/.torusguard/scripts/html_reporter.py +2668 -648
- package/.torusguard/scripts/recheck_runner.py +3 -3
- package/.torusguard/scripts/recipes_runner.py +3 -3
- package/.torusguard/scripts/report_sync.py +370 -74
- package/.torusguard/scripts/sarif_exporter.py +48 -8
- package/.torusguard/scripts/stack_detect.py +44 -2
- package/.torusguard/scripts/term_ui.py +1 -1
- package/.torusguard/skills/torusguard/SKILL.md +75 -72
- package/.torusguard/skills/torusguard-apply/SKILL.md +84 -80
- package/.torusguard/skills/torusguard-audit/SKILL.md +87 -83
- package/.torusguard/skills/torusguard-authorize/SKILL.md +7 -2
- package/.torusguard/skills/torusguard-exploit-check/SKILL.md +7 -2
- package/.torusguard/skills/torusguard-full/SKILL.md +7 -2
- package/.torusguard/skills/torusguard-harden/SKILL.md +98 -94
- package/.torusguard/skills/torusguard-init/SKILL.md +68 -64
- package/.torusguard/skills/torusguard-recheck/SKILL.md +81 -77
- package/.torusguard/skills/torusguard-report/SKILL.md +93 -72
- package/.torusguard/skills/torusguard-status/SKILL.md +62 -58
- package/.torusguard/skills/torusguard-verify/SKILL.md +7 -2
- package/.torusguard/skills/torusguard-web-validate/SKILL.md +7 -2
- package/.torusguard/workflows/apply.md +1 -1
- package/.torusguard/workflows/audit.md +1 -1
- package/.torusguard/workflows/authorize.md +1 -1
- package/.torusguard/workflows/exploit-check.md +1 -1
- package/.torusguard/workflows/harden.md +1 -1
- package/.torusguard/workflows/init.md +1 -1
- package/.torusguard/workflows/memory.md +1 -1
- package/.torusguard/workflows/recheck.md +1 -1
- package/.torusguard/workflows/report.md +1 -1
- package/.torusguard/workflows/status.md +1 -1
- package/.torusguard/workflows/verify.md +1 -1
- package/.torusguard/workflows/web-validate.md +1 -1
- package/README.md +14 -8
- package/bin/torusguard.js +56 -20
- package/package.json +1 -1
- package/skills/torusguard/SKILL.md +1 -1
- package/skills/torusguard/bootstrap.py +7 -2
- package/skills/torusguard/payload/.manifest.json +35 -35
- package/skills/torusguard/payload/scripts/__pycache__/apply_runner.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/audit_runner.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/diff_guard.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/finding_scorer.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/harden_runner.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/html_reporter.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/html_reporter.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/memory_engine.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/memory_engine.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/monorepo_detector.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/recheck_runner.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/report_sync.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/report_sync.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/rules_sync.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/run_manager.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/run_manager.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/sarif_exporter.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/stack_detect.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/stack_detect.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/apply_runner.py +11 -5
- package/skills/torusguard/payload/scripts/audit_runner.py +222 -15
- package/skills/torusguard/payload/scripts/harden_runner.py +3 -3
- package/skills/torusguard/payload/scripts/html_reporter.py +2668 -648
- package/skills/torusguard/payload/scripts/recheck_runner.py +3 -3
- package/skills/torusguard/payload/scripts/recipes_runner.py +3 -3
- package/skills/torusguard/payload/scripts/report_sync.py +370 -74
- package/skills/torusguard/payload/scripts/sarif_exporter.py +48 -8
- package/skills/torusguard/payload/scripts/stack_detect.py +44 -2
- package/skills/torusguard/payload/scripts/term_ui.py +1 -1
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +40 -23
- package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +1 -1
- package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +1 -1
- package/skills/torusguard/payload/workflows/apply.md +1 -1
- package/skills/torusguard/payload/workflows/audit.md +1 -1
- package/skills/torusguard/payload/workflows/authorize.md +1 -1
- package/skills/torusguard/payload/workflows/exploit-check.md +1 -1
- package/skills/torusguard/payload/workflows/harden.md +1 -1
- package/skills/torusguard/payload/workflows/init.md +1 -1
- package/skills/torusguard/payload/workflows/memory.md +1 -1
- package/skills/torusguard/payload/workflows/recheck.md +1 -1
- package/skills/torusguard/payload/workflows/report.md +1 -1
- package/skills/torusguard/payload/workflows/status.md +1 -1
- package/skills/torusguard/payload/workflows/verify.md +1 -1
- package/skills/torusguard/payload/workflows/web-validate.md +1 -1
- package/skills/torusguard-apply/SKILL.md +1 -1
- package/skills/torusguard-audit/SKILL.md +1 -1
- package/skills/torusguard-authorize/SKILL.md +1 -1
- package/skills/torusguard-exploit-check/SKILL.md +1 -1
- package/skills/torusguard-full/SKILL.md +1 -1
- package/skills/torusguard-harden/SKILL.md +1 -1
- package/skills/torusguard-init/SKILL.md +1 -1
- package/skills/torusguard-recheck/SKILL.md +1 -1
- package/skills/torusguard-report/SKILL.md +40 -23
- package/skills/torusguard-status/SKILL.md +1 -1
- package/skills/torusguard-verify/SKILL.md +1 -1
- package/skills/torusguard-web-validate/SKILL.md +1 -1
|
@@ -9,6 +9,7 @@ import sys
|
|
|
9
9
|
import json
|
|
10
10
|
import hashlib
|
|
11
11
|
import argparse
|
|
12
|
+
from pathlib import Path
|
|
12
13
|
from typing import List, Dict, Any
|
|
13
14
|
|
|
14
15
|
def generate_sarif(findings: List[Dict[str, Any]], run_id: str = "default", category: str = "torusguard/static") -> Dict[str, Any]:
|
|
@@ -76,7 +77,7 @@ def generate_sarif(findings: List[Dict[str, Any]], run_id: str = "default", cate
|
|
|
76
77
|
"tool": {
|
|
77
78
|
"driver": {
|
|
78
79
|
"name": "TorusGuard",
|
|
79
|
-
"semanticVersion": "1.3.
|
|
80
|
+
"semanticVersion": "1.3.6",
|
|
80
81
|
"informationUri": "https://github.com/githubmofo/TorusGuard",
|
|
81
82
|
"rules": list(rules_map.values())
|
|
82
83
|
}
|
|
@@ -95,22 +96,61 @@ def main():
|
|
|
95
96
|
parser = argparse.ArgumentParser(description="TorusGuard SARIF v2.1.0 Exporter")
|
|
96
97
|
parser.add_argument("--input", "-i", help="Path to findings JSON file")
|
|
97
98
|
parser.add_argument("--output", "-o", help="Output path for sarif.json")
|
|
98
|
-
parser.add_argument("--
|
|
99
|
+
parser.add_argument("--root", "-r", help="Project root override")
|
|
100
|
+
parser.add_argument("--run-id", default=None, help="Unique execution Run ID")
|
|
101
|
+
parser.add_argument("--stdout", action="store_true", help="Print SARIF JSON to stdout")
|
|
99
102
|
args = parser.parse_args()
|
|
100
103
|
|
|
104
|
+
root = Path(args.root).resolve() if args.root else Path.cwd().resolve()
|
|
101
105
|
findings = []
|
|
106
|
+
run_id = args.run_id or "run-default"
|
|
107
|
+
|
|
102
108
|
if args.input:
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
in_path = Path(args.input)
|
|
110
|
+
if not in_path.is_absolute():
|
|
111
|
+
in_path = (root / in_path).resolve()
|
|
112
|
+
if in_path.is_file():
|
|
113
|
+
with open(in_path, "r", encoding="utf-8") as f:
|
|
114
|
+
findings = json.load(f)
|
|
115
|
+
else:
|
|
116
|
+
# Auto-discover latest audit run findings
|
|
117
|
+
runs_dir = root / ".torusguard" / "runs"
|
|
118
|
+
if runs_dir.is_dir():
|
|
119
|
+
run_folders = sorted(
|
|
120
|
+
[d for d in runs_dir.iterdir() if d.is_dir() and (d / "findings.json").is_file()],
|
|
121
|
+
key=lambda p: p.stat().st_mtime,
|
|
122
|
+
reverse=True
|
|
123
|
+
)
|
|
124
|
+
if run_folders:
|
|
125
|
+
latest_run = run_folders[0]
|
|
126
|
+
run_id = args.run_id or latest_run.name
|
|
127
|
+
findings_file = latest_run / "findings.json"
|
|
128
|
+
try:
|
|
129
|
+
with open(findings_file, "r", encoding="utf-8") as f:
|
|
130
|
+
findings = json.load(f)
|
|
131
|
+
except Exception:
|
|
132
|
+
findings = []
|
|
105
133
|
|
|
106
|
-
sarif = generate_sarif(findings, run_id=
|
|
134
|
+
sarif = generate_sarif(findings, run_id=run_id)
|
|
107
135
|
|
|
108
136
|
if args.output:
|
|
109
|
-
|
|
137
|
+
out_path = Path(args.output)
|
|
138
|
+
if not out_path.is_absolute():
|
|
139
|
+
out_path = (root / out_path).resolve()
|
|
140
|
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
141
|
+
with open(out_path, "w", encoding="utf-8") as f:
|
|
110
142
|
json.dump(sarif, f, indent=2)
|
|
111
|
-
print(f"SARIF log written to: {
|
|
112
|
-
|
|
143
|
+
print(f"[SUCCESS] SARIF log written to: {out_path}")
|
|
144
|
+
elif args.stdout:
|
|
113
145
|
print(json.dumps(sarif, indent=2))
|
|
146
|
+
else:
|
|
147
|
+
# Default to writing in .torusguard/runs/results-latest.sarif
|
|
148
|
+
default_sarif = root / ".torusguard" / "runs" / "results-latest.sarif"
|
|
149
|
+
default_sarif.parent.mkdir(parents=True, exist_ok=True)
|
|
150
|
+
with open(default_sarif, "w", encoding="utf-8") as f:
|
|
151
|
+
json.dump(sarif, f, indent=2)
|
|
152
|
+
print(f"[SUCCESS] SARIF log written to: {default_sarif}")
|
|
153
|
+
|
|
114
154
|
|
|
115
155
|
if __name__ == "__main__":
|
|
116
156
|
main()
|
|
@@ -221,6 +221,24 @@ def detect_stack(project_root: Path) -> dict[str, Any]:
|
|
|
221
221
|
"indicator": "Flask application instantiation"
|
|
222
222
|
})
|
|
223
223
|
profile["recommended_references"].append("flask-security.md")
|
|
224
|
+
elif "tornado" in content or "tornado.web" in content:
|
|
225
|
+
add_to_list(profile, "languages_found", "Python")
|
|
226
|
+
profile["ecosystem_family"] = "python"
|
|
227
|
+
add_to_list(profile, "frameworks_found", "Tornado")
|
|
228
|
+
profile["confidence"] = "Confirmed"
|
|
229
|
+
profile["detection_evidence"].append({
|
|
230
|
+
"file": str(py_file.relative_to(project_root)),
|
|
231
|
+
"indicator": "Tornado application"
|
|
232
|
+
})
|
|
233
|
+
elif "starlette" in content:
|
|
234
|
+
add_to_list(profile, "languages_found", "Python")
|
|
235
|
+
profile["ecosystem_family"] = "python"
|
|
236
|
+
add_to_list(profile, "frameworks_found", "Starlette")
|
|
237
|
+
profile["confidence"] = "Confirmed"
|
|
238
|
+
profile["detection_evidence"].append({
|
|
239
|
+
"file": str(py_file.relative_to(project_root)),
|
|
240
|
+
"indicator": "Starlette application"
|
|
241
|
+
})
|
|
224
242
|
|
|
225
243
|
if "sqlalchemy" in content:
|
|
226
244
|
add_to_list(profile, "data_layers_found", "SQLAlchemy")
|
|
@@ -286,11 +304,27 @@ def detect_stack(project_root: Path) -> dict[str, Any]:
|
|
|
286
304
|
profile["confidence"] = "Confirmed"
|
|
287
305
|
profile["detection_evidence"].append({"file": "package.json", "indicator": "express dependency"})
|
|
288
306
|
profile["recommended_references"].append("express-security.md")
|
|
307
|
+
elif "fastify" in deps:
|
|
308
|
+
add_to_list(profile, "frameworks_found", "Fastify")
|
|
309
|
+
profile["confidence"] = "Confirmed"
|
|
310
|
+
profile["detection_evidence"].append({"file": "package.json", "indicator": "fastify dependency"})
|
|
311
|
+
elif "koa" in deps:
|
|
312
|
+
add_to_list(profile, "frameworks_found", "Koa")
|
|
313
|
+
profile["confidence"] = "Confirmed"
|
|
314
|
+
profile["detection_evidence"].append({"file": "package.json", "indicator": "koa dependency"})
|
|
315
|
+
elif "@remix-run/react" in deps or "@remix-run/node" in deps:
|
|
316
|
+
add_to_list(profile, "frameworks_found", "Remix")
|
|
317
|
+
profile["confidence"] = "Confirmed"
|
|
318
|
+
profile["detection_evidence"].append({"file": "package.json", "indicator": "Remix dependency"})
|
|
289
319
|
elif "react" in deps:
|
|
290
320
|
add_to_list(profile, "frameworks_found", "React / Vite")
|
|
291
321
|
profile["confidence"] = "Confirmed"
|
|
292
322
|
profile["detection_evidence"].append({"file": "package.json", "indicator": "react dependency"})
|
|
293
323
|
profile["recommended_references"].append("react-vite-security.md")
|
|
324
|
+
elif "vite" in deps:
|
|
325
|
+
add_to_list(profile, "frameworks_found", "Vite")
|
|
326
|
+
profile["confidence"] = "Confirmed"
|
|
327
|
+
profile["detection_evidence"].append({"file": "package.json", "indicator": "vite dependency"})
|
|
294
328
|
|
|
295
329
|
# ORM / Data layer detection
|
|
296
330
|
if "@prisma/client" in deps or "prisma" in deps:
|
|
@@ -433,6 +467,8 @@ def detect_stack(project_root: Path) -> dict[str, Any]:
|
|
|
433
467
|
|
|
434
468
|
if "Microsoft.NET.Sdk.Web" in csproj_content or "Microsoft.AspNetCore" in csproj_content or "Swashbuckle" in csproj_content:
|
|
435
469
|
add_to_list(profile, "frameworks_found", "ASP.NET Core")
|
|
470
|
+
if list(project_root.glob("**/*.razor")) or "Microsoft.AspNetCore.Components" in csproj_content or "blazor" in csproj_content.lower():
|
|
471
|
+
add_to_list(profile, "frameworks_found", "Blazor")
|
|
436
472
|
if "Microsoft.EntityFrameworkCore" in csproj_content:
|
|
437
473
|
add_to_list(profile, "data_layers_found", "Entity Framework Core")
|
|
438
474
|
elif "Dapper" in csproj_content:
|
|
@@ -442,11 +478,17 @@ def detect_stack(project_root: Path) -> dict[str, Any]:
|
|
|
442
478
|
# G. PHP Ecosystem
|
|
443
479
|
# -------------------------------------------------------------------------
|
|
444
480
|
composer_json = project_root / "composer.json"
|
|
445
|
-
|
|
481
|
+
is_wordpress = (project_root / "wp-config.php").is_file() or (project_root / "wp-load.php").is_file() or (project_root / "wp-content").is_dir()
|
|
482
|
+
if composer_json.is_file() or is_wordpress:
|
|
446
483
|
add_to_list(profile, "languages_found", "PHP")
|
|
447
484
|
profile["ecosystem_family"] = "php"
|
|
448
485
|
profile["confidence"] = "Confirmed"
|
|
449
|
-
|
|
486
|
+
if is_wordpress:
|
|
487
|
+
add_to_list(profile, "frameworks_found", "WordPress")
|
|
488
|
+
add_to_list(profile, "data_layers_found", "MySQL / wpdb")
|
|
489
|
+
profile["detection_evidence"].append({"file": "wp-config.php" if (project_root / "wp-config.php").is_file() else "wp-content", "indicator": "WordPress installation"})
|
|
490
|
+
if composer_json.is_file():
|
|
491
|
+
profile["detection_evidence"].append({"file": "composer.json", "indicator": "PHP Composer manifest"})
|
|
450
492
|
profile["recommended_rules"].extend(["TG-SEC-*", "TG-INPUT-001", "TG-INPUT-002", "TG-PLATFORM-*"])
|
|
451
493
|
profile["recommended_references"].append("polyglot-security-matrix.md")
|
|
452
494
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
TorusGuard Unified Terminal UI Engine (v1.3.
|
|
3
|
+
TorusGuard Unified Terminal UI Engine (v1.3.6)
|
|
4
4
|
Provides mathematically exact 75-column card formatting, ANSI-stripping,
|
|
5
5
|
Unicode/emoji visual width calculation, and visual truncation with ellipsis.
|
|
6
6
|
Pure Python 3.10+ standard library (zero external dependencies).
|
|
@@ -1,72 +1,75 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: torusguard
|
|
3
|
-
description: Universal autonomous security engine:
|
|
4
|
-
version: 1.3.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# TorusGuard Master Security Engine & Command Router
|
|
8
|
-
|
|
9
|
-
**Core Invariant:** If the browser or client receives it, users can inspect it. Never expose database credentials, master keys, or private API secrets in client bundles. Always isolate multi-tenant database queries.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Command Catalog: Terminal CLI & AI Chat Parity
|
|
14
|
-
|
|
15
|
-
TorusGuard operates with 100% feature parity across both the terminal CLI and AI chat slash commands:
|
|
16
|
-
|
|
17
|
-
| Capability | Terminal CLI Command | AI Chat Slash Command | Specialist Skill | Purpose |
|
|
18
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
19
|
-
| **Init** | `npx torusguard init` | `/torusguard init` | `skills/torusguard-init` | Stack discovery, rule activation, workspace scaffolding |
|
|
20
|
-
| **Status** | `npx torusguard status` | `/torusguard status` | `skills/torusguard-status` | Posture score, active rules, run history, scope check |
|
|
21
|
-
| **Audit** | `npx torusguard audit` | `/torusguard audit` | `skills/torusguard-audit` | Static AST scan, invariant fingerprinting, confidence scoring |
|
|
22
|
-
| **Verify** | `npx torusguard verify` | `/torusguard verify` | `skills/torusguard-verify` | Evidence sufficiency audit & line match calibration |
|
|
23
|
-
| **Harden** | `npx torusguard harden` | `/torusguard harden` | `skills/torusguard-harden` | Ponytail patch formulation ($\le 35$ add, $\le 25$ del) |
|
|
24
|
-
| **Apply** | `npx torusguard apply [--yes]` | `/torusguard apply` | `skills/torusguard-apply` | Human Gate review, `.bak` snapshots, patch application |
|
|
25
|
-
| **Rollback** | `npx torusguard rollback` | `/torusguard rollback` | `skills/torusguard-apply` | Instant 1-step rollback from pre-apply snapshots |
|
|
26
|
-
| **Recheck** | `npx torusguard recheck` | `/torusguard recheck` | `skills/torusguard-recheck` | Targeted differential AST scan, fix closure verification |
|
|
27
|
-
| **Recipes** | `npx torusguard recipes` | `/torusguard recipes` | `skills/torusguard-harden` | Explore verified Golden Fix Recipes from persistent memory |
|
|
28
|
-
| **Report** | `npx torusguard report --html` | `/torusguard report` | `skills/torusguard-report` | Executive posture reporting, SARIF v2.1.0 & visual HTML |
|
|
29
|
-
| **Authorize** | `npx torusguard authorize` | `/torusguard authorize` | `skills/torusguard-authorize`| Legal scope definition & safety boundaries |
|
|
30
|
-
| **Validate** | `npx torusguard web-validate` | `/torusguard web-validate` | `skills/torusguard-web-validate`| Authorized non-destructive HTTP probing |
|
|
31
|
-
| **Exploit** | `npx torusguard exploit-check` | `/torusguard exploit-check`| `skills/torusguard-exploit-check`| Bounded single-step exploitability confirmation |
|
|
32
|
-
| **Full** | `npx torusguard full` | `/torusguard full` | `skills/torusguard-full` | End-to-end 7-stage closed-loop execution |
|
|
33
|
-
| **Sync** | `npx torusguard rules sync` | `/torusguard rules sync` | `skills/torusguard-init` | Synchronize rules across AI editors (Cursor, Claude, Antigravity) |
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Non-Negotiable Invariants
|
|
38
|
-
|
|
39
|
-
1. **Browser-Code Truth:** If the client receives it, it is public. Zero hardcoded secrets (`SUPABASE_SERVICE_ROLE_KEY`, private tokens, live API keys) in frontend code.
|
|
40
|
-
2. **Multi-Tenant Isolation:** All database lookups must be scoped by organization or user ownership (`tenant_id`, `organization_id`, `where: { tenantId }`).
|
|
41
|
-
3. **Ponytail Churn Bounds:** Patches must be minimal and surgical ($\le 35$ additions, $\le 25$ deletions). Never perform full-file rewrites.
|
|
42
|
-
4. **Standardized 75-Column Terminal:** All CLI terminal output is strictly normalized to 75 visual columns with Unicode emoji width calculation, ANSI escape handling, and visual truncation with ellipsis (`...`).
|
|
43
|
-
5. **Zero Security Bypasses:** Never insert `# nosec`, `verify=False`, `InsecureSkipVerify: true`, `[AllowAnonymous]`, or `csrf().disable()`.
|
|
44
|
-
6. **Snapshots Before Edits:** Every code modification must capture a byte-for-byte pre-apply backup in `.torusguard/snapshots/<run_id>/` before touching disk code.
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Workspace Layout Structure
|
|
49
|
-
```
|
|
50
|
-
.torusguard/
|
|
51
|
-
├── config/
|
|
52
|
-
│ ├── torusguard.json # Detected stack, settings, and rule counts
|
|
53
|
-
│ └── scope.json # Authorized runtime validation targets & TTL
|
|
54
|
-
├── memory/
|
|
55
|
-
│ ├── context.json # Aggregated security memory context
|
|
56
|
-
│ ├── patterns.json # Distilled Golden Fix Recipes
|
|
57
|
-
│ └── events.json # Historical audit, apply, and recheck events
|
|
58
|
-
├── rules/
|
|
59
|
-
│ └── active/ # Active TG-* rule definitions
|
|
60
|
-
├── runs/
|
|
61
|
-
│ └── run-YYYYMMDD-HHMMSS-audit/
|
|
62
|
-
│ ├── findings.json # Machine-readable AST findings
|
|
63
|
-
│ ├── findings.md # Actionable markdown finding cards
|
|
64
|
-
│ ├── remediation.md # Formulated candidate patch catalog
|
|
65
|
-
│ ├── diff_summary.md # Summary of applied diffs
|
|
66
|
-
│ ├── recheck.md # Differential recheck status transitions
|
|
67
|
-
│ ├── report.html # Single-file visual dark-mode HTML report
|
|
68
|
-
│ ├── results.sarif # OASIS SARIF v2.1.0 log
|
|
69
|
-
│ └── bundles/ # Formulated Ponytail remediation bundles
|
|
70
|
-
└── snapshots/
|
|
71
|
-
└── run-YYYYMMDD-HHMMSS-audit/ # Pre-apply .bak files for instant rollback
|
|
72
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: torusguard
|
|
3
|
+
description: Universal autonomous security engine: 74 canonical rules across 18 families, polyglot stack detection across 16+ languages, Ponytail remediation bounds (<=35 add, <=25 del), standardized 75-column terminal UI, SARIF v2.1.0 exports, and persistent security memory context.
|
|
4
|
+
version: 1.3.6
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TorusGuard Master Security Engine & Command Router
|
|
8
|
+
|
|
9
|
+
**Core Invariant:** If the browser or client receives it, users can inspect it. Never expose database credentials, master keys, or private API secrets in client bundles. Always isolate multi-tenant database queries.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Command Catalog: Terminal CLI & AI Chat Parity
|
|
14
|
+
|
|
15
|
+
TorusGuard operates with 100% feature parity across both the terminal CLI and AI chat slash commands:
|
|
16
|
+
|
|
17
|
+
| Capability | Terminal CLI Command | AI Chat Slash Command | Specialist Skill | Purpose |
|
|
18
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
19
|
+
| **Init** | `npx torusguard init` | `/torusguard init` | `skills/torusguard-init` | Stack discovery, rule activation, workspace scaffolding |
|
|
20
|
+
| **Status** | `npx torusguard status` | `/torusguard status` | `skills/torusguard-status` | Posture score, active rules, run history, scope check |
|
|
21
|
+
| **Audit** | `npx torusguard audit` | `/torusguard audit` | `skills/torusguard-audit` | Static AST scan, invariant fingerprinting, confidence scoring |
|
|
22
|
+
| **Verify** | `npx torusguard verify` | `/torusguard verify` | `skills/torusguard-verify` | Evidence sufficiency audit & line match calibration |
|
|
23
|
+
| **Harden** | `npx torusguard harden` | `/torusguard harden` | `skills/torusguard-harden` | Ponytail patch formulation ($\le 35$ add, $\le 25$ del) |
|
|
24
|
+
| **Apply** | `npx torusguard apply [--yes]` | `/torusguard apply` | `skills/torusguard-apply` | Human Gate review, `.bak` snapshots, patch application |
|
|
25
|
+
| **Rollback** | `npx torusguard rollback` | `/torusguard rollback` | `skills/torusguard-apply` | Instant 1-step rollback from pre-apply snapshots |
|
|
26
|
+
| **Recheck** | `npx torusguard recheck` | `/torusguard recheck` | `skills/torusguard-recheck` | Targeted differential AST scan, fix closure verification |
|
|
27
|
+
| **Recipes** | `npx torusguard recipes` | `/torusguard recipes` | `skills/torusguard-harden` | Explore verified Golden Fix Recipes from persistent memory |
|
|
28
|
+
| **Report** | `npx torusguard report --html` | `/torusguard report` | `skills/torusguard-report` | Executive posture reporting, SARIF v2.1.0 & visual HTML |
|
|
29
|
+
| **Authorize** | `npx torusguard authorize` | `/torusguard authorize` | `skills/torusguard-authorize`| Legal scope definition & safety boundaries |
|
|
30
|
+
| **Validate** | `npx torusguard web-validate` | `/torusguard web-validate` | `skills/torusguard-web-validate`| Authorized non-destructive HTTP probing |
|
|
31
|
+
| **Exploit** | `npx torusguard exploit-check` | `/torusguard exploit-check`| `skills/torusguard-exploit-check`| Bounded single-step exploitability confirmation |
|
|
32
|
+
| **Full** | `npx torusguard full` | `/torusguard full` | `skills/torusguard-full` | End-to-end 7-stage closed-loop execution |
|
|
33
|
+
| **Sync** | `npx torusguard rules sync` | `/torusguard rules sync` | `skills/torusguard-init` | Synchronize rules across AI editors (Cursor, Claude, Antigravity) |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Non-Negotiable Invariants
|
|
38
|
+
|
|
39
|
+
1. **Browser-Code Truth:** If the client receives it, it is public. Zero hardcoded secrets (`SUPABASE_SERVICE_ROLE_KEY`, private tokens, live API keys) in frontend code.
|
|
40
|
+
2. **Multi-Tenant Isolation:** All database lookups must be scoped by organization or user ownership (`tenant_id`, `organization_id`, `where: { tenantId }`).
|
|
41
|
+
3. **Ponytail Churn Bounds:** Patches must be minimal and surgical ($\le 35$ additions, $\le 25$ deletions). Never perform full-file rewrites.
|
|
42
|
+
4. **Standardized 75-Column Terminal:** All CLI terminal output is strictly normalized to 75 visual columns with Unicode emoji width calculation, ANSI escape handling, and visual truncation with ellipsis (`...`).
|
|
43
|
+
5. **Zero Security Bypasses:** Never insert `# nosec`, `verify=False`, `InsecureSkipVerify: true`, `[AllowAnonymous]`, or `csrf().disable()`.
|
|
44
|
+
6. **Snapshots Before Edits:** Every code modification must capture a byte-for-byte pre-apply backup in `.torusguard/snapshots/<run_id>/` before touching disk code.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Workspace Layout Structure
|
|
49
|
+
```
|
|
50
|
+
.torusguard/
|
|
51
|
+
├── config/
|
|
52
|
+
│ ├── torusguard.json # Detected stack, settings, and rule counts
|
|
53
|
+
│ └── scope.json # Authorized runtime validation targets & TTL
|
|
54
|
+
├── memory/
|
|
55
|
+
│ ├── context.json # Aggregated security memory context
|
|
56
|
+
│ ├── patterns.json # Distilled Golden Fix Recipes
|
|
57
|
+
│ └── events.json # Historical audit, apply, and recheck events
|
|
58
|
+
├── rules/
|
|
59
|
+
│ └── active/ # Active TG-* rule definitions
|
|
60
|
+
├── runs/
|
|
61
|
+
│ └── run-YYYYMMDD-HHMMSS-audit/
|
|
62
|
+
│ ├── findings.json # Machine-readable AST findings
|
|
63
|
+
│ ├── findings.md # Actionable markdown finding cards
|
|
64
|
+
│ ├── remediation.md # Formulated candidate patch catalog
|
|
65
|
+
│ ├── diff_summary.md # Summary of applied diffs
|
|
66
|
+
│ ├── recheck.md # Differential recheck status transitions
|
|
67
|
+
│ ├── report.html # Single-file visual dark-mode HTML report
|
|
68
|
+
│ ├── results.sarif # OASIS SARIF v2.1.0 log
|
|
69
|
+
│ └── bundles/ # Formulated Ponytail remediation bundles
|
|
70
|
+
└── snapshots/
|
|
71
|
+
└── run-YYYYMMDD-HHMMSS-audit/ # Pre-apply .bak files for instant rollback
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Living Report Ground Truth
|
|
75
|
+
- Read `security_report.md` in the workspace root before taking any action. Update the relevant finding card after completing remediation.
|
|
@@ -1,80 +1,84 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: torusguard-apply
|
|
3
|
-
description: Apply governed remediation patches to disk with pre-apply rollback snapshots and Human Gate validation via CLI or AI Agent.
|
|
4
|
-
version: 1.3.
|
|
5
|
-
workflow: .torusguard/workflows/apply.md
|
|
6
|
-
tools: Read, Grep, Glob, Write, replace_file_content, run_command
|
|
7
|
-
scripts-binding:
|
|
8
|
-
- .torusguard/scripts/
|
|
9
|
-
- .torusguard/scripts/
|
|
10
|
-
- .torusguard/scripts/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- **
|
|
76
|
-
- **
|
|
77
|
-
- **
|
|
78
|
-
- **
|
|
79
|
-
- **
|
|
80
|
-
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-apply
|
|
3
|
+
description: Apply governed remediation patches to disk with pre-apply rollback snapshots and Human Gate validation via CLI or AI Agent.
|
|
4
|
+
version: 1.3.6
|
|
5
|
+
workflow: .torusguard/workflows/apply.md
|
|
6
|
+
tools: Read, Grep, Glob, Write, replace_file_content, run_command
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/report_sync.py
|
|
9
|
+
- .torusguard/scripts/apply_runner.py
|
|
10
|
+
- .torusguard/scripts/term_ui.py
|
|
11
|
+
- .torusguard/scripts/memory_engine.py
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# TorusGuard Apply — Governed Patch Application & Rollback Snapshot
|
|
15
|
+
|
|
16
|
+
## Objective
|
|
17
|
+
Safely apply approved remediation bundles to disk source files, creating an automated byte-for-byte pre-apply backup snapshot (`.bak`) in `.torusguard/snapshots/<run_id>/`, asserting syntax validity, and distilling passing patterns into Golden Fix Recipes.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Two Execution Modes
|
|
22
|
+
|
|
23
|
+
### Mode A: Automated CLI Execution (Interactive or Non-Interactive)
|
|
24
|
+
Run the governed patch applier from your terminal:
|
|
25
|
+
```bash
|
|
26
|
+
# Interactive Human Gate review (prompts for each patch: [y]es / [n]o / [a]ll / [q]uit)
|
|
27
|
+
npx torusguard apply
|
|
28
|
+
|
|
29
|
+
# Non-interactive automated application
|
|
30
|
+
npx torusguard apply --yes
|
|
31
|
+
|
|
32
|
+
# Apply patches from a specific run ID
|
|
33
|
+
npx torusguard apply --run run-20260910-121618-audit --yes
|
|
34
|
+
|
|
35
|
+
# Emergency rollback from pre-apply snapshot
|
|
36
|
+
npx torusguard rollback
|
|
37
|
+
# or
|
|
38
|
+
npx torusguard apply --rollback
|
|
39
|
+
```
|
|
40
|
+
**Under the Hood:** Executes `python .torusguard/scripts/apply_runner.py`.
|
|
41
|
+
1. Reads candidate bundles from `.torusguard/runs/<run_id>/bundles/`.
|
|
42
|
+
2. Creates `.bak` snapshot in `.torusguard/snapshots/<run_id>/<rel_path>.bak`.
|
|
43
|
+
3. Performs line-aware replacement without corrupting concurrent modifications.
|
|
44
|
+
4. Distills the applied fix into a **Golden Fix Recipe** registered in `.torusguard/memory/patterns.json`.
|
|
45
|
+
5. Emits `diff_summary.md` and `apply_plan.md` in the run directory.
|
|
46
|
+
6. Displays pixel-perfect 75-column terminal cards.
|
|
47
|
+
|
|
48
|
+
### Mode B: In-Session AI Chat Agent Application
|
|
49
|
+
When applying patches directly within an AI chat session:
|
|
50
|
+
1. **Human Gate Confirmation:** Present the unified diff to the operator and request explicit approval before editing code.
|
|
51
|
+
2. **Pre-Apply Snapshot:** Ensure target file backup is created at `.torusguard/snapshots/<run_id>/<rel_path>.bak`.
|
|
52
|
+
3. **Execute Surgical Edit:** Use `replace_file_content` to apply only the approved lines. Strictly adhere to the formulated Ponytail diff.
|
|
53
|
+
4. **Syntax & Integrity Check:** Verify that the patched file is syntactically valid (e.g. `node --check <file>` or `python -m py_compile <file>`). If syntax fails, immediately restore from `.bak`.
|
|
54
|
+
5. **Memory Registration:** Update persistent memory events in `.torusguard/memory/events.json` with event `fix_applied`.
|
|
55
|
+
6. **Recommend Recheck:** Advise running `/torusguard recheck` or `npx torusguard recheck` to verify closure.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Rollback Guarantee
|
|
60
|
+
If an applied patch introduces unexpected runtime behavior or breaks tests:
|
|
61
|
+
```bash
|
|
62
|
+
# Instant one-command rollback of the latest applied run:
|
|
63
|
+
npx torusguard rollback
|
|
64
|
+
|
|
65
|
+
# Or rollback a specific run:
|
|
66
|
+
npx torusguard rollback --run run-20260910-121618-audit
|
|
67
|
+
```
|
|
68
|
+
All affected files are restored byte-for-byte from `.torusguard/snapshots/<run_id>/`.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Output Card Format
|
|
73
|
+
```markdown
|
|
74
|
+
### 🚀 TorusGuard Patch Applied Successfully
|
|
75
|
+
- **Target File:** `server/index.js:9`
|
|
76
|
+
- **Rule ID:** `TG-SEC-001` (Hardcoded JWT secret)
|
|
77
|
+
- **Ponytail Churn:** +1 / -1
|
|
78
|
+
- **Rollback Snapshot:** `.torusguard/snapshots/<run_id>/server/index.js.bak`
|
|
79
|
+
- **Golden Recipe:** Distilled into persistent memory
|
|
80
|
+
- **Next Step:** Run `npx torusguard recheck` or `/torusguard recheck` to verify closure
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Living Report Ground Truth
|
|
84
|
+
- Read `security_report.md` in the workspace root before taking any action. Update the relevant finding card after completing remediation.
|