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,164 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://torusguard.dev/schemas/finding.schema.json",
|
|
4
|
+
"title": "TorusGuardCanonicalFinding",
|
|
5
|
+
"description": "Canonical normalized finding object schema for TorusGuard v0.5.1 with provenance and auditable confidence scoring.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"finding_id",
|
|
9
|
+
"rule_id",
|
|
10
|
+
"title",
|
|
11
|
+
"category",
|
|
12
|
+
"severity",
|
|
13
|
+
"confidence",
|
|
14
|
+
"status",
|
|
15
|
+
"affected_component",
|
|
16
|
+
"evidence",
|
|
17
|
+
"provenance",
|
|
18
|
+
"reproduction_method",
|
|
19
|
+
"remediation",
|
|
20
|
+
"retest_result",
|
|
21
|
+
"timestamps"
|
|
22
|
+
],
|
|
23
|
+
"properties": {
|
|
24
|
+
"finding_id": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"pattern": "^TG-FIND-[0-9]{4}-[a-f0-9]{4,12}$",
|
|
27
|
+
"description": "Unique canonical identifier for this finding instance."
|
|
28
|
+
},
|
|
29
|
+
"rule_id": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^TG-[A-Z0-9]+-[0-9]{3}$",
|
|
32
|
+
"description": "Canonical TorusGuard Rule ID (e.g. TG-AUTH-007, TG-SEC-001)."
|
|
33
|
+
},
|
|
34
|
+
"title": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Concise, human-readable finding title."
|
|
37
|
+
},
|
|
38
|
+
"category": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": [
|
|
41
|
+
"authentication-authorization",
|
|
42
|
+
"input-validation-encoding",
|
|
43
|
+
"data-access-orm",
|
|
44
|
+
"file-upload-handling",
|
|
45
|
+
"secrets-configuration",
|
|
46
|
+
"dependency-supply-chain",
|
|
47
|
+
"network-ssrf-boundaries",
|
|
48
|
+
"business-logic-rate-limiting",
|
|
49
|
+
"client-cache-platform"
|
|
50
|
+
],
|
|
51
|
+
"description": "Normalized lifecycle taxonomy category."
|
|
52
|
+
},
|
|
53
|
+
"severity": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"required": ["level", "rationale", "rubric_justification"],
|
|
56
|
+
"properties": {
|
|
57
|
+
"level": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"enum": ["Critical", "High", "Medium", "Low", "Informational"]
|
|
60
|
+
},
|
|
61
|
+
"rationale": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"description": "Justification for assigned severity level."
|
|
64
|
+
},
|
|
65
|
+
"rubric_justification": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Explicit reason why this finding is not a higher or lower severity."
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"confidence": {
|
|
72
|
+
"$ref": "confidence.schema.json"
|
|
73
|
+
},
|
|
74
|
+
"status": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"enum": [
|
|
77
|
+
"Confirmed",
|
|
78
|
+
"High Confidence",
|
|
79
|
+
"Medium Confidence",
|
|
80
|
+
"Low Confidence",
|
|
81
|
+
"Unconfirmed",
|
|
82
|
+
"Needs Review",
|
|
83
|
+
"Remediated",
|
|
84
|
+
"Verified Fixed"
|
|
85
|
+
],
|
|
86
|
+
"description": "Standardized operational verification status."
|
|
87
|
+
},
|
|
88
|
+
"affected_component": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"required": ["component_name", "target_path"],
|
|
91
|
+
"properties": {
|
|
92
|
+
"component_name": { "type": "string" },
|
|
93
|
+
"target_path": { "type": "string" },
|
|
94
|
+
"start_line": { "type": "integer" },
|
|
95
|
+
"end_line": { "type": "integer" },
|
|
96
|
+
"symbol": { "type": "string" }
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"evidence": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"minItems": 1,
|
|
102
|
+
"items": { "$ref": "evidence.schema.json" }
|
|
103
|
+
},
|
|
104
|
+
"provenance": {
|
|
105
|
+
"$ref": "provenance.schema.json"
|
|
106
|
+
},
|
|
107
|
+
"reproduction_method": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"required": ["step_by_step", "deterministic"],
|
|
110
|
+
"properties": {
|
|
111
|
+
"step_by_step": {
|
|
112
|
+
"type": "array",
|
|
113
|
+
"items": { "type": "string" }
|
|
114
|
+
},
|
|
115
|
+
"test_command": { "type": "string" },
|
|
116
|
+
"deterministic": { "type": "boolean" },
|
|
117
|
+
"expected_failure_response": { "type": "string" }
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"remediation": {
|
|
121
|
+
"$ref": "remediation.schema.json"
|
|
122
|
+
},
|
|
123
|
+
"retest_result": {
|
|
124
|
+
"$ref": "retest.schema.json"
|
|
125
|
+
},
|
|
126
|
+
"requirement_reference": {
|
|
127
|
+
"type": "object",
|
|
128
|
+
"properties": {
|
|
129
|
+
"asvs_v4": { "type": "string" },
|
|
130
|
+
"nist_ssdf": { "type": "string" },
|
|
131
|
+
"owasp_top10": { "type": "string" }
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"cwe": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"pattern": "^CWE-[0-9]{1,5}$"
|
|
137
|
+
},
|
|
138
|
+
"timestamps": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"required": ["discovered_at", "updated_at"],
|
|
141
|
+
"properties": {
|
|
142
|
+
"discovered_at": { "type": "string", "format": "date-time" },
|
|
143
|
+
"verified_at": { "type": "string", "format": "date-time" },
|
|
144
|
+
"remediated_at": { "type": "string", "format": "date-time" },
|
|
145
|
+
"retested_at": { "type": "string", "format": "date-time" },
|
|
146
|
+
"updated_at": { "type": "string", "format": "date-time" }
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"notes": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": ["raw_facts_summary", "ai_interpretation"],
|
|
152
|
+
"properties": {
|
|
153
|
+
"raw_facts_summary": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"description": "Objective, unembellished summary of verified code facts."
|
|
156
|
+
},
|
|
157
|
+
"ai_interpretation": {
|
|
158
|
+
"type": "string",
|
|
159
|
+
"description": "AI-generated risk analysis and contextual reasoning."
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://torusguard.dev/schemas/provenance.schema.json",
|
|
4
|
+
"title": "TorusGuardProvenanceChain",
|
|
5
|
+
"description": "Structured provenance chain tracking discovery and decision path for TorusGuard v0.5.1 findings.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"discovery_module",
|
|
9
|
+
"triggering_input",
|
|
10
|
+
"evidence_collected",
|
|
11
|
+
"decision_path",
|
|
12
|
+
"verification_step"
|
|
13
|
+
],
|
|
14
|
+
"properties": {
|
|
15
|
+
"discovery_module": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Module or rule that initiated the detection (e.g. rules/authorization/TG-AUTH-007)."
|
|
18
|
+
},
|
|
19
|
+
"triggering_input": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The specific input, AST node, manifest line, or configuration key that triggered detection."
|
|
22
|
+
},
|
|
23
|
+
"evidence_collected": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": { "type": "string" },
|
|
26
|
+
"description": "List of evidence identifiers or file locations gathered during discovery."
|
|
27
|
+
},
|
|
28
|
+
"decision_path": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"items": { "type": "string" },
|
|
31
|
+
"description": "Ordered sequence of logical evaluation steps leading to the finding classification."
|
|
32
|
+
},
|
|
33
|
+
"verification_step": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Verification method used to confirm or refute the finding."
|
|
36
|
+
},
|
|
37
|
+
"agent_environment": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Runtime context (e.g. TorusGuard Engine v0.5.1 on Python 3.11)."
|
|
40
|
+
},
|
|
41
|
+
"timestamp": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"format": "date-time"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -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
|
+
}
|
|
Binary file
|
|
@@ -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()
|