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,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://torusguard.dev/schemas/remediation.schema.json",
|
|
4
|
+
"title": "TorusGuardRemediation",
|
|
5
|
+
"description": "Standard remediation guidance schema for TorusGuard v0.5.0 findings.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"problem_statement",
|
|
9
|
+
"risk_explanation",
|
|
10
|
+
"recommended_fix",
|
|
11
|
+
"framework_pattern",
|
|
12
|
+
"verification_method",
|
|
13
|
+
"residual_risk_notes"
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"problem_statement": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Direct, single-sentence summary of the flaw in the current implementation."
|
|
19
|
+
},
|
|
20
|
+
"risk_explanation": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Explains how an adversary can abuse this pattern and the concrete security impact."
|
|
23
|
+
},
|
|
24
|
+
"recommended_fix": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Clear, prescriptive step-by-step instructions to remediate the vulnerability."
|
|
27
|
+
},
|
|
28
|
+
"framework_pattern": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"required": ["framework", "unsafe_snippet", "safe_snippet"],
|
|
31
|
+
"properties": {
|
|
32
|
+
"framework": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Target framework or ecosystem (e.g. Django, DRF, FastAPI, Flask, SQLAlchemy, Express, Next.js)."
|
|
35
|
+
},
|
|
36
|
+
"unsafe_snippet": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Illustrative code demonstrating the unsafe pattern."
|
|
39
|
+
},
|
|
40
|
+
"safe_snippet": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Framework-native, production-grade hardened code snippet."
|
|
43
|
+
},
|
|
44
|
+
"least_invasive": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "True if the remediation preserves existing architectural patterns without unnecessary rewrites."
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"verification_method": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "How a human engineer or automated test can verify that the fix was applied successfully."
|
|
53
|
+
},
|
|
54
|
+
"residual_risk_notes": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "Known edge cases, out-of-band requirements (e.g. cloud IAM, reverse proxy headers), or operational trade-offs."
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://torusguard.dev/schemas/retest.schema.json",
|
|
4
|
+
"title": "TorusGuardRetestRecord",
|
|
5
|
+
"description": "Schema for explicit retest execution, fix verification, and closure status in TorusGuard v0.5.1.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"retest_performed",
|
|
9
|
+
"closure_status"
|
|
10
|
+
],
|
|
11
|
+
"properties": {
|
|
12
|
+
"retest_performed": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "True if an automated or manual retest has been executed on the post-fix codebase."
|
|
15
|
+
},
|
|
16
|
+
"retest_timestamp": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"format": "date-time"
|
|
19
|
+
},
|
|
20
|
+
"fix_applied": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Summary of the code patch or configuration change applied."
|
|
23
|
+
},
|
|
24
|
+
"retest_method": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Method used to verify resolution (e.g. differential static recheck, automated unit test)."
|
|
27
|
+
},
|
|
28
|
+
"retest_evidence_hash": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "SHA-256 hash of the modified source file confirming post-fix state."
|
|
31
|
+
},
|
|
32
|
+
"closure_status": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": [
|
|
35
|
+
"Unconfirmed",
|
|
36
|
+
"Open",
|
|
37
|
+
"Remediated",
|
|
38
|
+
"Verified Fixed",
|
|
39
|
+
"Fix Incomplete",
|
|
40
|
+
"Suppressed - Accepted Risk"
|
|
41
|
+
],
|
|
42
|
+
"description": "Final verified operational status of the finding."
|
|
43
|
+
},
|
|
44
|
+
"residual_risk": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Any residual operational or architectural risk remaining after the fix."
|
|
47
|
+
},
|
|
48
|
+
"verifier_notes": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Human or AI verifier notes detailing retest observations."
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "TorusGuardRuntimeEvidence",
|
|
4
|
+
"description": "Schema for TorusGuard v0.7.0 captured runtime HTTP/browser evidence.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"evidence_id",
|
|
8
|
+
"finding_id",
|
|
9
|
+
"timestamp",
|
|
10
|
+
"method",
|
|
11
|
+
"url",
|
|
12
|
+
"status_code",
|
|
13
|
+
"exploitability_status"
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"evidence_id": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"finding_id": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"cluster_id": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"timestamp": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"format": "date-time"
|
|
28
|
+
},
|
|
29
|
+
"method": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"enum": ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]
|
|
32
|
+
},
|
|
33
|
+
"url": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
},
|
|
36
|
+
"path": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"status_code": {
|
|
40
|
+
"type": "integer"
|
|
41
|
+
},
|
|
42
|
+
"request_headers": {
|
|
43
|
+
"type": "object"
|
|
44
|
+
},
|
|
45
|
+
"response_headers": {
|
|
46
|
+
"type": "object"
|
|
47
|
+
},
|
|
48
|
+
"response_body_snippet": {
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
"exploitability_status": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": [
|
|
54
|
+
"Runtime Confirmed",
|
|
55
|
+
"Runtime Likely",
|
|
56
|
+
"Needs Manual Review",
|
|
57
|
+
"Not Reproducible in Scope",
|
|
58
|
+
"Blocked by Environment / Controls"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
"reproducible": {
|
|
62
|
+
"type": "boolean"
|
|
63
|
+
},
|
|
64
|
+
"route_context": {
|
|
65
|
+
"type": "string"
|
|
66
|
+
},
|
|
67
|
+
"reviewer_notes": {
|
|
68
|
+
"type": "string"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"additionalProperties": true
|
|
72
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TorusGuard Content-Aware Diff Line Scanner (v0.9.3)
|
|
4
|
+
Evaluates unified diff patches against security invariants before harden or apply.
|
|
5
|
+
Pure Python 3.10+ standard library (zero external dependencies).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
import os
|
|
10
|
+
import re
|
|
11
|
+
import json
|
|
12
|
+
import argparse
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Dict, List, Any, Optional
|
|
15
|
+
|
|
16
|
+
BYPASS_PATTERNS = [
|
|
17
|
+
(re.compile(r'(?:#|//)\s*(?:TODO\s*:?\s*)?(?:bypass|skip|disable)[_\s]*(?:auth|security|check|guard|filter|csrf|tenant)', re.IGNORECASE), "Suspicious authentication or security check bypass comment"),
|
|
18
|
+
(re.compile(r'\bverify\s*=\s*False\b'), "Disabled TLS certificate verification (verify=False)"),
|
|
19
|
+
(re.compile(r'\b(?:skip_auth|bypass_auth|disable_auth|allow_all|permit_all)\s*=\s*True\b', re.IGNORECASE), "Explicit security bypass flag enabled"),
|
|
20
|
+
(re.compile(r'@(?:csrf_exempt|allow_anonymous|disable_token_check)\b'), "Decorator disabling route-level security or CSRF protection"),
|
|
21
|
+
(re.compile(r'\bCORS_ALLOW_ALL_ORIGINS\s*=\s*True\b'), "Wildcard CORS origin enabled in patch"),
|
|
22
|
+
(re.compile(r'(?:#|//)\s*nosec\b', re.IGNORECASE), "Suppression comment (nosec) hiding potential vulnerability")
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
SECRET_PATTERNS = [
|
|
26
|
+
(re.compile(r'\b(?:sk_live|ak_live)_[0-9a-zA-Z]{20,}\b'), "Live payment or cloud API secret key"),
|
|
27
|
+
(re.compile(r'\bgh[pousr]_[0-9a-zA-Z]{36}\b'), "GitHub personal access token"),
|
|
28
|
+
(re.compile(r'\beyJ[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.[A-Za-z0-9-_.+/=]+\b'), "Hardcoded JSON Web Token (JWT) string"),
|
|
29
|
+
(re.compile(r'-----BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY-----'), "Hardcoded private key block"),
|
|
30
|
+
(re.compile(r'(?:password|secret|api_key|access_token)\s*=\s*["\'][A-Za-z0-9@#$%^&+=_\-]{8,}["\']', re.IGNORECASE), "Hardcoded credential or API secret string")
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
TENANT_FILTER_PATTERNS = [
|
|
34
|
+
re.compile(r'\.filter\([^)]*\btenant\s*='),
|
|
35
|
+
re.compile(r'\.filter_by\([^)]*\btenant\s*='),
|
|
36
|
+
re.compile(r'\bwhere\s+tenant_id\s*='),
|
|
37
|
+
re.compile(r'\btenant_id\s*==?')
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def audit_diff(diff_content: str) -> Dict[str, Any]:
|
|
42
|
+
"""
|
|
43
|
+
Parses a unified diff and returns detected violations.
|
|
44
|
+
"""
|
|
45
|
+
lines = diff_content.splitlines()
|
|
46
|
+
violations: List[Dict[str, Any]] = []
|
|
47
|
+
|
|
48
|
+
current_file = "unknown"
|
|
49
|
+
current_line = 0
|
|
50
|
+
|
|
51
|
+
additions: List[tuple[int, str]] = []
|
|
52
|
+
deletions: List[tuple[int, str]] = []
|
|
53
|
+
|
|
54
|
+
for line_idx, line in enumerate(lines, 1):
|
|
55
|
+
if line.startswith('+++ b/'):
|
|
56
|
+
current_file = line[6:].strip()
|
|
57
|
+
continue
|
|
58
|
+
elif line.startswith('--- a/'):
|
|
59
|
+
continue
|
|
60
|
+
elif line.startswith('@@'):
|
|
61
|
+
# Parse line number e.g. @@ -10,5 +12,6 @@
|
|
62
|
+
match = re.search(r'\+(\d+)', line)
|
|
63
|
+
if match:
|
|
64
|
+
current_line = int(match.group(1)) - 1
|
|
65
|
+
continue
|
|
66
|
+
|
|
67
|
+
if line.startswith('+') and not line.startswith('+++'):
|
|
68
|
+
current_line += 1
|
|
69
|
+
added_content = line[1:]
|
|
70
|
+
additions.append((current_line, added_content))
|
|
71
|
+
|
|
72
|
+
# Check bypass patterns
|
|
73
|
+
for pat, desc in BYPASS_PATTERNS:
|
|
74
|
+
if pat.search(added_content):
|
|
75
|
+
violations.append({
|
|
76
|
+
"rule_id": "TG-DIFF-001",
|
|
77
|
+
"category": "Bypass Sink",
|
|
78
|
+
"severity": "CRITICAL",
|
|
79
|
+
"file": current_file,
|
|
80
|
+
"line": current_line,
|
|
81
|
+
"content": added_content.strip(),
|
|
82
|
+
"description": desc
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
# Check secret ingestion
|
|
86
|
+
for pat, desc in SECRET_PATTERNS:
|
|
87
|
+
if pat.search(added_content):
|
|
88
|
+
violations.append({
|
|
89
|
+
"rule_id": "TG-DIFF-002",
|
|
90
|
+
"category": "Secret Ingestion",
|
|
91
|
+
"severity": "CRITICAL",
|
|
92
|
+
"file": current_file,
|
|
93
|
+
"line": current_line,
|
|
94
|
+
"content": "[REDACTED_POTENTIAL_SECRET]",
|
|
95
|
+
"description": desc
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
elif line.startswith('-') and not line.startswith('---'):
|
|
99
|
+
deleted_content = line[1:]
|
|
100
|
+
deletions.append((line_idx, deleted_content))
|
|
101
|
+
|
|
102
|
+
# Check for tenant filter deletion without replacement
|
|
103
|
+
for del_idx, del_line in deletions:
|
|
104
|
+
for t_pat in TENANT_FILTER_PATTERNS:
|
|
105
|
+
if t_pat.search(del_line):
|
|
106
|
+
# Verify if an equivalent tenant filter exists in additions
|
|
107
|
+
replaced = any(t_pat.search(add_line) for _, add_line in additions)
|
|
108
|
+
if not replaced:
|
|
109
|
+
violations.append({
|
|
110
|
+
"rule_id": "TG-DIFF-003",
|
|
111
|
+
"category": "Tenant Filter Removal",
|
|
112
|
+
"severity": "HIGH",
|
|
113
|
+
"file": current_file,
|
|
114
|
+
"line": del_idx,
|
|
115
|
+
"content": del_line.strip(),
|
|
116
|
+
"description": "Tenant isolation filter was removed without being restored in additions"
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
status = "PASSED" if not violations else "BLOCKED"
|
|
120
|
+
return {
|
|
121
|
+
"status": status,
|
|
122
|
+
"files_inspected": list(set(v["file"] for v in violations)) if violations else [current_file],
|
|
123
|
+
"additions_count": len(additions),
|
|
124
|
+
"deletions_count": len(deletions),
|
|
125
|
+
"total_violations": len(violations),
|
|
126
|
+
"violations": violations
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def audit_diff_file(file_path: str) -> Dict[str, Any]:
|
|
131
|
+
path = Path(file_path)
|
|
132
|
+
if not path.is_file():
|
|
133
|
+
return {
|
|
134
|
+
"status": "ERROR",
|
|
135
|
+
"error": f"File not found: {file_path}",
|
|
136
|
+
"violations": []
|
|
137
|
+
}
|
|
138
|
+
content = path.read_text(encoding="utf-8", errors="replace")
|
|
139
|
+
return audit_diff(content)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def main():
|
|
143
|
+
parser = argparse.ArgumentParser(description="TorusGuard Unified Diff Security Scanner")
|
|
144
|
+
parser.add_argument("diff_path", nargs="?", help="Path to unified diff file (or read stdin if omitted)")
|
|
145
|
+
parser.add_argument("--json", action="store_true", help="Output results as JSON")
|
|
146
|
+
args = parser.parse_args()
|
|
147
|
+
|
|
148
|
+
if args.diff_path:
|
|
149
|
+
res = audit_diff_file(args.diff_path)
|
|
150
|
+
else:
|
|
151
|
+
if sys.stdin.isatty():
|
|
152
|
+
parser.print_help()
|
|
153
|
+
sys.exit(1)
|
|
154
|
+
diff_text = sys.stdin.read()
|
|
155
|
+
res = audit_diff(diff_text)
|
|
156
|
+
|
|
157
|
+
if args.json:
|
|
158
|
+
print(json.dumps(res, indent=2))
|
|
159
|
+
else:
|
|
160
|
+
if res.get("status") == "PASSED":
|
|
161
|
+
print(f"[PASS] Diff Guard: Clean patch (+{res['additions_count']}/-{res['deletions_count']}). Zero security bypasses.")
|
|
162
|
+
sys.exit(0)
|
|
163
|
+
else:
|
|
164
|
+
print(f"[BLOCKED] Diff Guard: Found {res.get('total_violations', 0)} security invariant violation(s):")
|
|
165
|
+
for v in res.get("violations", []):
|
|
166
|
+
print(f" - [{v['severity']}] {v['rule_id']} at {v['file']}:{v['line']} -> {v['description']}")
|
|
167
|
+
sys.exit(1)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
main()
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TorusGuard 5-Factor Finding Confidence Scorer
|
|
4
|
+
Evaluates finding confidence against the objective 0–100 scoring model.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
import json
|
|
9
|
+
import argparse
|
|
10
|
+
from typing import Dict, Any, Tuple
|
|
11
|
+
|
|
12
|
+
def compute_confidence_score(
|
|
13
|
+
evidence_quality: int = 35,
|
|
14
|
+
reproduction_success: int = 0,
|
|
15
|
+
independent_confirmations: int = 5,
|
|
16
|
+
environmental_clarity: int = 15,
|
|
17
|
+
manual_review_status: int = 0
|
|
18
|
+
) -> Tuple[int, str, Dict[str, int]]:
|
|
19
|
+
"""
|
|
20
|
+
Computes total score and assigns confidence band.
|
|
21
|
+
Max points:
|
|
22
|
+
- evidence_quality: 35
|
|
23
|
+
- reproduction_success: 25
|
|
24
|
+
- independent_confirmations: 15
|
|
25
|
+
- environmental_clarity: 15
|
|
26
|
+
- manual_review_status: 10
|
|
27
|
+
"""
|
|
28
|
+
eq = min(max(evidence_quality, 0), 35)
|
|
29
|
+
rs = min(max(reproduction_success, 0), 25)
|
|
30
|
+
ic = min(max(independent_confirmations, 0), 15)
|
|
31
|
+
ec = min(max(environmental_clarity, 0), 15)
|
|
32
|
+
mr = min(max(manual_review_status, 0), 10)
|
|
33
|
+
|
|
34
|
+
total = eq + rs + ic + ec + mr
|
|
35
|
+
|
|
36
|
+
if total >= 90:
|
|
37
|
+
band = "Confirmed"
|
|
38
|
+
elif total >= 70:
|
|
39
|
+
band = "High Confidence"
|
|
40
|
+
elif total >= 50:
|
|
41
|
+
band = "Medium Confidence"
|
|
42
|
+
else:
|
|
43
|
+
band = "Needs Review"
|
|
44
|
+
|
|
45
|
+
factors = {
|
|
46
|
+
"evidence_quality": eq,
|
|
47
|
+
"reproduction_success": rs,
|
|
48
|
+
"independent_confirmations": ic,
|
|
49
|
+
"environmental_clarity": ec,
|
|
50
|
+
"manual_review_status": mr,
|
|
51
|
+
"total_score": total,
|
|
52
|
+
"classification_band": band
|
|
53
|
+
}
|
|
54
|
+
return total, band, factors
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def main():
|
|
58
|
+
parser = argparse.ArgumentParser(description="TorusGuard Confidence Scorer")
|
|
59
|
+
parser.add_argument("--eq", type=int, default=35, help="Evidence quality score (0-35)")
|
|
60
|
+
parser.add_argument("--rs", type=int, default=0, help="Reproduction success score (0-25)")
|
|
61
|
+
parser.add_argument("--ic", type=int, default=5, help="Independent confirmations score (0-15)")
|
|
62
|
+
parser.add_argument("--ec", type=int, default=15, help="Environmental clarity score (0-15)")
|
|
63
|
+
parser.add_argument("--mr", type=int, default=0, help="Manual review status score (0-10)")
|
|
64
|
+
parser.add_argument("--json", action="store_true", help="Output JSON")
|
|
65
|
+
args = parser.parse_args()
|
|
66
|
+
|
|
67
|
+
total, band, factors = compute_confidence_score(
|
|
68
|
+
evidence_quality=args.eq,
|
|
69
|
+
reproduction_success=args.rs,
|
|
70
|
+
independent_confirmations=args.ic,
|
|
71
|
+
environmental_clarity=args.ec,
|
|
72
|
+
manual_review_status=args.mr
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if args.json:
|
|
76
|
+
print(json.dumps(factors, indent=2))
|
|
77
|
+
else:
|
|
78
|
+
print(f"Total Confidence Score: {total}/100")
|
|
79
|
+
print(f"Classification Band: {band}")
|
|
80
|
+
print("Factor Breakdown:")
|
|
81
|
+
for k, v in factors.items():
|
|
82
|
+
if k not in ("total_score", "classification_band"):
|
|
83
|
+
print(f" - {k}: {v}")
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
main()
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
TorusGuard Cryptographic Manifest Builder & Verifier
|
|
4
|
+
Generates or validates SHA-256 integrity digests for all .torusguard files.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import json
|
|
10
|
+
import hashlib
|
|
11
|
+
import argparse
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def compute_file_sha256(filepath):
|
|
16
|
+
"""Compute SHA-256 digest of a file in binary mode."""
|
|
17
|
+
hasher = hashlib.sha256()
|
|
18
|
+
with open(filepath, "rb") as fh:
|
|
19
|
+
while chunk := fh.read(65536):
|
|
20
|
+
hasher.update(chunk)
|
|
21
|
+
return hasher.hexdigest()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def scan_workspace_files(base_dir):
|
|
25
|
+
"""Scan all files inside .torusguard, ignoring runs, pyc, and gitkeep."""
|
|
26
|
+
base_dir = Path(base_dir).resolve()
|
|
27
|
+
file_map = {}
|
|
28
|
+
|
|
29
|
+
for root, dirs, files in os.walk(base_dir):
|
|
30
|
+
if "runs" in dirs:
|
|
31
|
+
dirs.remove("runs")
|
|
32
|
+
if "__pycache__" in dirs:
|
|
33
|
+
dirs.remove("__pycache__")
|
|
34
|
+
|
|
35
|
+
for f in sorted(files):
|
|
36
|
+
if f in [".manifest.json", ".gitkeep"] or f.endswith(".pyc"):
|
|
37
|
+
continue
|
|
38
|
+
full_path = Path(root) / f
|
|
39
|
+
rel_path = full_path.relative_to(base_dir).as_posix()
|
|
40
|
+
file_map[rel_path] = compute_file_sha256(full_path)
|
|
41
|
+
|
|
42
|
+
return file_map
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def check_manifest(base_dir):
|
|
46
|
+
"""Check disk files against existing .manifest.json."""
|
|
47
|
+
base_dir = Path(base_dir).resolve()
|
|
48
|
+
manifest_file = base_dir / ".manifest.json"
|
|
49
|
+
|
|
50
|
+
if not manifest_file.exists():
|
|
51
|
+
print(f"[ERROR] Missing manifest file: {manifest_file}")
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
with open(manifest_file, "r", encoding="utf-8") as fh:
|
|
55
|
+
expected = json.load(fh)
|
|
56
|
+
|
|
57
|
+
current = scan_workspace_files(base_dir)
|
|
58
|
+
|
|
59
|
+
# Files expected to change during user initialization/configuration
|
|
60
|
+
USER_CONFIGS = {"config/torusguard.json", "config/scope.json"}
|
|
61
|
+
|
|
62
|
+
missing = set(expected.keys()) - set(current.keys())
|
|
63
|
+
added = set(current.keys()) - set(expected.keys())
|
|
64
|
+
altered_core = [k for k in expected if k in current and expected[k] != current[k] and k not in USER_CONFIGS]
|
|
65
|
+
altered_configs = [k for k in expected if k in current and expected[k] != current[k] and k in USER_CONFIGS]
|
|
66
|
+
|
|
67
|
+
print("================================================================================")
|
|
68
|
+
print("TORUSGUARD INTEGRITY MANIFEST VERIFICATION")
|
|
69
|
+
print("================================================================================")
|
|
70
|
+
print(f"Directory: {base_dir}")
|
|
71
|
+
print(f"Indexed Files: {len(expected)}")
|
|
72
|
+
|
|
73
|
+
if missing:
|
|
74
|
+
print(f"\n[FAIL] Missing files ({len(missing)}):")
|
|
75
|
+
for m in sorted(missing):
|
|
76
|
+
print(f" - {m}")
|
|
77
|
+
|
|
78
|
+
if altered_core:
|
|
79
|
+
print(f"\n[FAIL] Altered / Tampered core files ({len(altered_core)}):")
|
|
80
|
+
for a in sorted(altered_core):
|
|
81
|
+
print(f" - {a}")
|
|
82
|
+
|
|
83
|
+
if altered_configs:
|
|
84
|
+
print(f"\n[INFO] Tailored user project configs ({len(altered_configs)}):")
|
|
85
|
+
for ac in sorted(altered_configs):
|
|
86
|
+
print(f" * {ac}")
|
|
87
|
+
|
|
88
|
+
if added:
|
|
89
|
+
print(f"\n[INFO] Untracked new files ({len(added)}):")
|
|
90
|
+
for ad in sorted(added):
|
|
91
|
+
print(f" + {ad}")
|
|
92
|
+
|
|
93
|
+
if not missing and not altered_core:
|
|
94
|
+
print("\n[PASS] 100% of workspace files match cryptographic SHA-256 signatures cleanly.")
|
|
95
|
+
print("================================================================================")
|
|
96
|
+
return True
|
|
97
|
+
|
|
98
|
+
print("\n================================================================================")
|
|
99
|
+
print("INTEGRITY VERIFICATION FAILED")
|
|
100
|
+
print("================================================================================")
|
|
101
|
+
return False
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def write_manifest(base_dir):
|
|
105
|
+
"""Write freshly computed manifest to .torusguard/.manifest.json."""
|
|
106
|
+
base_dir = Path(base_dir).resolve()
|
|
107
|
+
manifest_file = base_dir / ".manifest.json"
|
|
108
|
+
|
|
109
|
+
current = scan_workspace_files(base_dir)
|
|
110
|
+
with open(manifest_file, "w", encoding="utf-8") as fh:
|
|
111
|
+
json.dump(current, fh, indent=2)
|
|
112
|
+
|
|
113
|
+
print(f"[SUCCESS] Wrote {len(current)} entries to {manifest_file}")
|
|
114
|
+
return True
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
parser = argparse.ArgumentParser(description="TorusGuard Manifest Builder & Verifier")
|
|
119
|
+
parser.add_argument("--dir", default=".torusguard", help="Target .torusguard directory")
|
|
120
|
+
parser.add_argument("--write", action="store_true", help="Generate and write manifest")
|
|
121
|
+
parser.add_argument("--check", action="store_true", help="Check workspace against manifest")
|
|
122
|
+
args = parser.parse_args()
|
|
123
|
+
|
|
124
|
+
if args.write:
|
|
125
|
+
success = write_manifest(args.dir)
|
|
126
|
+
else:
|
|
127
|
+
# Default to --check
|
|
128
|
+
success = check_manifest(args.dir)
|
|
129
|
+
|
|
130
|
+
sys.exit(0 if success else 1)
|