targetzero 0.3.2__py3-none-any.whl

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.
Files changed (66) hide show
  1. targetzero/__init__.py +4 -0
  2. targetzero/__main__.py +6 -0
  3. targetzero/admins.py +109 -0
  4. targetzero/cli.py +366 -0
  5. targetzero/common/__init__.py +2 -0
  6. targetzero/common/changes.py +46 -0
  7. targetzero/common/config.py +83 -0
  8. targetzero/common/ids.py +17 -0
  9. targetzero/common/output.py +91 -0
  10. targetzero/common/resources.py +32 -0
  11. targetzero/common/roles.py +24 -0
  12. targetzero/common/schema.py +45 -0
  13. targetzero/config/approved_exposure.example.csv +4 -0
  14. targetzero/config/privileged_roles.yaml +50 -0
  15. targetzero/config/targetzero.example.yaml +57 -0
  16. targetzero/external/__init__.py +2 -0
  17. targetzero/external/dangling.py +106 -0
  18. targetzero/external/discover.py +181 -0
  19. targetzero/external/dnsinfo.py +54 -0
  20. targetzero/external/enrich.py +137 -0
  21. targetzero/external/http.py +33 -0
  22. targetzero/external/kev.py +222 -0
  23. targetzero/external/ports.py +63 -0
  24. targetzero/external/scan.py +260 -0
  25. targetzero/external/scope.py +54 -0
  26. targetzero/external/waf.py +202 -0
  27. targetzero/external/web.py +124 -0
  28. targetzero/gws/__init__.py +2 -0
  29. targetzero/gws/admins.py +230 -0
  30. targetzero/gws/changes.py +190 -0
  31. targetzero/gws/client.py +94 -0
  32. targetzero/gws/domains.py +36 -0
  33. targetzero/registers/__init__.py +2 -0
  34. targetzero/registers/exceptions.py +85 -0
  35. targetzero/registers/findings.py +108 -0
  36. targetzero/registers/inventory.py +142 -0
  37. targetzero/registers/manual_admins.py +43 -0
  38. targetzero/schemas/admins.schema.json +27 -0
  39. targetzero/schemas/alert_tests.schema.json +19 -0
  40. targetzero/schemas/config.schema.json +71 -0
  41. targetzero/schemas/exceptions.schema.json +20 -0
  42. targetzero/schemas/findings.schema.json +23 -0
  43. targetzero/schemas/inventory.schema.json +26 -0
  44. targetzero/schemas/summary.schema.json +36 -0
  45. targetzero/scorecard/__init__.py +2 -0
  46. targetzero/scorecard/scorecard.py +201 -0
  47. targetzero/templates/alert_tests.csv +1 -0
  48. targetzero/templates/exceptions.csv +1 -0
  49. targetzero/templates/findings.csv +1 -0
  50. targetzero/templates/inventory.csv +1 -0
  51. targetzero/templates/manual_admins.csv +1 -0
  52. targetzero/templates/origins.csv +1 -0
  53. targetzero/templates/recovery_page.md +51 -0
  54. targetzero/vendors/__init__.py +2 -0
  55. targetzero/vendors/cisco_asa.py +151 -0
  56. targetzero/vendors/common.py +84 -0
  57. targetzero/vendors/fortigate.py +176 -0
  58. targetzero/vendors/panos.py +141 -0
  59. targetzero/vendors/redfish.py +124 -0
  60. targetzero/vendors/vsphere.py +108 -0
  61. targetzero-0.3.2.dist-info/METADATA +116 -0
  62. targetzero-0.3.2.dist-info/RECORD +66 -0
  63. targetzero-0.3.2.dist-info/WHEEL +4 -0
  64. targetzero-0.3.2.dist-info/entry_points.txt +2 -0
  65. targetzero-0.3.2.dist-info/licenses/LICENSE +202 -0
  66. targetzero-0.3.2.dist-info/licenses/NOTICE +7 -0
@@ -0,0 +1,108 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """registers/findings.csv: merge new findings and count those past deadline (Zero 6)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import shutil
7
+ from collections.abc import Iterable, Mapping
8
+ from datetime import UTC, date, datetime
9
+ from pathlib import Path
10
+
11
+ from targetzero.common.config import Config
12
+ from targetzero.common.output import read_csv, run_dir, write_csv, write_summary
13
+
14
+ FIELDS = (
15
+ "id",
16
+ "asset_id",
17
+ "vulnerability",
18
+ "title",
19
+ "severity",
20
+ "published",
21
+ "deadline",
22
+ "status",
23
+ "action",
24
+ "owner",
25
+ "closed_date",
26
+ "notes",
27
+ )
28
+ # Statuses that still count. "exception" stays counted here; the scorecard
29
+ # subtracts it only when a valid, signed exception covers the id.
30
+ COUNTED = ("open", "exception")
31
+
32
+
33
+ def path_for(config: Config) -> Path:
34
+ return config.registers_dir / "findings.csv"
35
+
36
+
37
+ def load(config: Config) -> list[dict[str, str]]:
38
+ path = path_for(config)
39
+ return read_csv(path) if path.exists() else []
40
+
41
+
42
+ def save(config: Config, rows: list[dict[str, str]]) -> Path:
43
+ path = path_for(config)
44
+ if path.exists():
45
+ stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
46
+ shutil.copyfile(path, path.with_name(f"{path.name}.{stamp}.bak"))
47
+ return write_csv(path, [{f: r.get(f, "") for f in FIELDS} for r in rows], FIELDS)
48
+
49
+
50
+ def merge(
51
+ rows: list[dict[str, str]], new: Iterable[Mapping[str, str]]
52
+ ) -> tuple[list[dict[str, str]], int]:
53
+ """Add findings whose id is not in the register yet. Existing rows are left alone."""
54
+ known = {r["id"] for r in rows}
55
+ added = 0
56
+ for finding in new:
57
+ if finding["id"] not in known:
58
+ rows.append({f: finding.get(f, "") for f in FIELDS})
59
+ known.add(finding["id"])
60
+ added += 1
61
+ return rows, added
62
+
63
+
64
+ def parse_time(value: str) -> datetime | None:
65
+ try:
66
+ parsed = datetime.fromisoformat(value)
67
+ except ValueError:
68
+ return None
69
+ return parsed if parsed.tzinfo else parsed.replace(tzinfo=UTC)
70
+
71
+
72
+ def count(
73
+ config: Config,
74
+ run_date: date,
75
+ now: datetime | None = None,
76
+ notes: Iterable[str] = (),
77
+ complete: bool = True,
78
+ ) -> list[Path]:
79
+ """Write 6_findings_overdue.csv and its summary."""
80
+ now = now or datetime.now(UTC)
81
+ rows = load(config)
82
+ records, items = [], []
83
+ for row in rows:
84
+ deadline = parse_time(row.get("deadline", ""))
85
+ overdue = row.get("status") in COUNTED and (deadline is None or deadline < now)
86
+ records.append({**{f: row.get(f, "") for f in FIELDS}, "overdue": "Y" if overdue else "N"})
87
+ if overdue:
88
+ reason = f"{row.get('vulnerability')} on {row.get('asset_id')}, " + (
89
+ f"deadline {row['deadline']}" if deadline else "no valid deadline"
90
+ )
91
+ items.append({"id": row["id"], "reason": reason})
92
+ directory = run_dir(config.output_dir, run_date)
93
+ record_file = "6_findings_overdue.csv"
94
+ return [
95
+ write_csv(directory / record_file, records, (*FIELDS, "overdue")),
96
+ write_summary(
97
+ directory,
98
+ zero=6,
99
+ source="findings",
100
+ name="overdue",
101
+ items=items,
102
+ tool="targetzero registers findings",
103
+ run_date=run_date,
104
+ complete=complete,
105
+ notes=list(notes),
106
+ record_file=record_file,
107
+ ),
108
+ ]
@@ -0,0 +1,142 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """registers/inventory.csv: merge discovered assets and count incomplete rows (Zero 5)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import shutil
7
+ from collections.abc import Iterable, Mapping
8
+ from datetime import date, datetime
9
+ from pathlib import Path
10
+
11
+ from targetzero.common.config import Config
12
+ from targetzero.common.output import read_csv, run_dir, write_csv, write_summary
13
+
14
+ FIELDS = (
15
+ "id",
16
+ "asset",
17
+ "type",
18
+ "ip",
19
+ "owner",
20
+ "purpose",
21
+ "product",
22
+ "version",
23
+ "vendor_supported",
24
+ "eol_date",
25
+ "behind_waf",
26
+ "internet_facing_app",
27
+ "status",
28
+ "last_reviewed",
29
+ "notes",
30
+ )
31
+ REQUIRED = ("owner", "purpose", "product", "version")
32
+ # Columns that discovery may overwrite. Everything else belongs to people.
33
+ MACHINE_COLUMNS = ("ip",)
34
+
35
+
36
+ def path_for(config: Config) -> Path:
37
+ return config.registers_dir / "inventory.csv"
38
+
39
+
40
+ def load(config: Config) -> list[dict[str, str]]:
41
+ path = path_for(config)
42
+ return read_csv(path) if path.exists() else []
43
+
44
+
45
+ def save(config: Config, rows: list[dict[str, str]]) -> Path:
46
+ path = path_for(config)
47
+ if path.exists():
48
+ stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
49
+ shutil.copyfile(path, path.with_name(f"{path.name}.{stamp}.bak"))
50
+ return write_csv(path, [{f: r.get(f, "") for f in FIELDS} for r in rows], FIELDS)
51
+
52
+
53
+ def merge(
54
+ rows: list[dict[str, str]], discovered: Iterable[Mapping[str, str]]
55
+ ) -> tuple[list[dict[str, str]], int, int]:
56
+ """Add new assets as unreviewed rows and refresh machine columns.
57
+
58
+ Returns (rows, added, updated). Hand-filled columns are never changed.
59
+ """
60
+ by_asset = {r["asset"].lower(): r for r in rows}
61
+ added = updated = 0
62
+ for found in discovered:
63
+ key = found["asset"].lower()
64
+ existing = by_asset.get(key)
65
+ if existing is None:
66
+ row = {f: "" for f in FIELDS} | dict(found)
67
+ row["asset"] = key
68
+ row["status"] = "unreviewed"
69
+ rows.append(row)
70
+ by_asset[key] = row
71
+ added += 1
72
+ continue
73
+ for column in MACHINE_COLUMNS:
74
+ value = found.get(column, "")
75
+ if value and existing.get(column) != value:
76
+ existing[column] = value
77
+ updated += 1
78
+ return rows, added, updated
79
+
80
+
81
+ def problems(row: Mapping[str, str], run_date: date, max_age_days: int) -> list[str]:
82
+ found = [f"{c} empty" for c in REQUIRED if not row.get(c)]
83
+ if row.get("vendor_supported") not in ("Y", "N"):
84
+ found.append("vendor_supported not Y or N")
85
+ if row.get("status") == "unreviewed":
86
+ found.append("unreviewed")
87
+ reviewed = row.get("last_reviewed", "")
88
+ try:
89
+ age = (run_date - date.fromisoformat(reviewed)).days if reviewed else None
90
+ except ValueError:
91
+ age = None
92
+ found.append("last_reviewed not a date")
93
+ if not reviewed:
94
+ found.append("never reviewed")
95
+ elif age is not None and age > max_age_days:
96
+ found.append(f"last reviewed {age} days ago")
97
+ return found
98
+
99
+
100
+ def count(
101
+ config: Config, run_date: date, notes: Iterable[str] = (), complete: bool = True
102
+ ) -> list[Path]:
103
+ """Write 5_inventory_rows.csv and its summary."""
104
+ max_age = config.threshold("inventory_review_days", 90)
105
+ rows = [r for r in load(config) if r.get("status") != "retired"]
106
+ records, items = [], []
107
+ for row in rows:
108
+ issues = problems(row, run_date, max_age)
109
+ if row.get("vendor_supported") == "N":
110
+ issues_note = "vendor no longer supports this product: replace it or take it offline"
111
+ else:
112
+ issues_note = ""
113
+ records.append(
114
+ {
115
+ **{f: row.get(f, "") for f in FIELDS},
116
+ "problems": "; ".join(issues),
117
+ "warning": issues_note,
118
+ }
119
+ )
120
+ if issues:
121
+ items.append({"id": row["id"], "reason": "; ".join(issues)})
122
+ directory = run_dir(config.output_dir, run_date)
123
+ record_file = "5_inventory_rows.csv"
124
+ notes = list(notes)
125
+ if not path_for(config).exists():
126
+ notes.append("registers/inventory.csv not found")
127
+ complete = False
128
+ return [
129
+ write_csv(directory / record_file, records, (*FIELDS, "problems", "warning")),
130
+ write_summary(
131
+ directory,
132
+ zero=5,
133
+ source="inventory",
134
+ name="rows",
135
+ items=items,
136
+ tool="targetzero registers inventory",
137
+ run_date=run_date,
138
+ complete=complete,
139
+ notes=notes,
140
+ record_file=record_file,
141
+ ),
142
+ ]
@@ -0,0 +1,43 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Count the admins in registers/manual_admins.csv (systems without a collector)."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from datetime import date
7
+ from pathlib import Path
8
+
9
+ from targetzero.admins import record_id, write_admin_outputs
10
+ from targetzero.common.config import Config
11
+ from targetzero.common.output import read_csv, run_dir
12
+ from targetzero.common.schema import validate
13
+
14
+ SOURCE = "manual"
15
+
16
+
17
+ def run(config: Config, run_date: date) -> list[Path]:
18
+ path = config.registers_dir / "manual_admins.csv"
19
+ rows = read_csv(path) if path.exists() else []
20
+ notes = [] if path.exists() else [f"{path.name} not found: no manual admins counted"]
21
+ records = []
22
+ for n, row in enumerate(rows, start=2):
23
+ row["source"] = row.get("source") or SOURCE
24
+ row["id"] = row.get("id") or record_id(
25
+ row["source"], row.get("system", ""), row.get("account", ""), row.get("role", "")
26
+ )
27
+ problems = validate(row, "admins")
28
+ if problems:
29
+ notes.append(f"row {n} skipped: {'; '.join(problems)}")
30
+ continue
31
+ # Manual rows keep their own source name only if it is "manual"; otherwise ids from
32
+ # different files could collide with collector output.
33
+ row["source"] = SOURCE
34
+ records.append(row)
35
+ return write_admin_outputs(
36
+ run_dir(config.output_dir, run_date),
37
+ source=SOURCE,
38
+ records=records,
39
+ tool="targetzero registers manual-admins",
40
+ run_date=run_date,
41
+ complete=not any(n.startswith("row ") for n in notes) and path.exists(),
42
+ notes=notes,
43
+ )
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/admins.schema.json",
4
+ "title": "TargetZero admin record",
5
+ "description": "One row of an admin CSV. Every admin source (M365, Google Workspace, vendor collectors, manual register) writes this format, so Zero 1 and Zero 2 can be counted across all systems.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["id", "source", "system", "account", "role", "privileged", "permanent", "mfa_class", "mfa_enforced", "break_glass"],
9
+ "properties": {
10
+ "id": { "type": "string", "pattern": "^[a-z0-9-]+:[^\\s;]+$" },
11
+ "source": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
12
+ "system": { "type": "string", "minLength": 1, "description": "Tenant, domain, device or console name." },
13
+ "account": { "type": "string", "minLength": 1 },
14
+ "role": { "type": "string", "minLength": 1 },
15
+ "account_type": { "enum": ["user", "service", "shared", ""], "description": "service = app, service principal or non-interactive account. Service accounts count for Zero 1 but not for Zero 2." },
16
+ "privileged": { "enum": ["Y", "N"], "description": "Y when the role counts as full admin." },
17
+ "permanent": { "enum": ["Y", "N"], "description": "Y when the role is active with no end date." },
18
+ "end_date": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
19
+ "mfa_class": { "enum": ["phishing-resistant", "mfa", "does-not-count", "none", "unknown"] },
20
+ "mfa_enforced": { "enum": ["Y", "N", "unknown"] },
21
+ "separate_admin_account": { "enum": ["Y", "N", "unknown", ""] },
22
+ "break_glass": { "enum": ["Y", "N"] },
23
+ "last_logon": { "type": "string" },
24
+ "last_verified": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
25
+ "notes": { "type": "string" }
26
+ }
27
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/alert_tests.schema.json",
4
+ "title": "TargetZero alert test",
5
+ "description": "One row of registers/alert_tests.csv: the monthly odd-hour admin logon test for one system (Zero 3). Filled in by hand.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["id", "system", "account", "test_time", "alert_received"],
9
+ "properties": {
10
+ "id": { "type": "string", "minLength": 1 },
11
+ "system": { "type": "string", "minLength": 1 },
12
+ "account": { "type": "string", "minLength": 1 },
13
+ "test_time": { "type": "string", "minLength": 10, "description": "ISO 8601 timestamp of the test logon." },
14
+ "alert_received": { "enum": ["Y", "N"] },
15
+ "received_at": { "type": "string" },
16
+ "received_by": { "type": "string" },
17
+ "notes": { "type": "string" }
18
+ }
19
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/config.schema.json",
4
+ "title": "TargetZero configuration",
5
+ "description": "Schema for targetzero.yaml. Relative paths are resolved against the folder that holds the config file.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["organisation"],
9
+ "properties": {
10
+ "organisation": { "type": "string", "minLength": 1 },
11
+ "output_dir": { "type": "string", "minLength": 1, "default": "output" },
12
+ "registers_dir": { "type": "string", "minLength": 1, "default": "registers" },
13
+ "owners": {
14
+ "type": "object",
15
+ "description": "Owner per Target 0 count, keyed 1 to 7.",
16
+ "propertyNames": { "pattern": "^[1-7]$" },
17
+ "additionalProperties": { "type": "string" }
18
+ },
19
+ "break_glass": {
20
+ "type": "object",
21
+ "description": "Emergency accounts per source. Scripts never change these and leave them out of the Zero 1 count.",
22
+ "propertyNames": { "pattern": "^[a-z0-9][a-z0-9-]*$" },
23
+ "additionalProperties": { "type": "array", "items": { "type": "string", "minLength": 1 }, "maxItems": 4 }
24
+ },
25
+ "scope": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "description": "What you own and are authorised to scan. External checks never go outside this list.",
29
+ "properties": {
30
+ "domains": { "type": "array", "items": { "type": "string", "minLength": 1 } },
31
+ "ip_ranges": { "type": "array", "items": { "type": "string", "minLength": 1 } }
32
+ }
33
+ },
34
+ "thresholds": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "properties": {
38
+ "exception_max_days": { "type": "integer", "minimum": 1, "maximum": 90, "default": 90 },
39
+ "inventory_review_days": { "type": "integer", "minimum": 1, "default": 90 },
40
+ "alert_test_max_age_days": { "type": "integer", "minimum": 1, "default": 35 },
41
+ "deadline_hours": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "properties": {
45
+ "kev": { "type": "integer", "minimum": 1, "default": 8 },
46
+ "critical": { "type": "integer", "minimum": 1, "default": 24 },
47
+ "high": { "type": "integer", "minimum": 1, "default": 72 }
48
+ }
49
+ }
50
+ }
51
+ },
52
+ "m365": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "properties": {
56
+ "tenant_id": { "type": "string" },
57
+ "client_id": { "type": "string", "description": "App registration for unattended runs. Leave empty for interactive sign-in." },
58
+ "certificate_thumbprint": { "type": "string" }
59
+ }
60
+ },
61
+ "gws": {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "properties": {
65
+ "customer_id": { "type": "string", "default": "my_customer" },
66
+ "admin_subject": { "type": "string", "description": "Admin account the service account impersonates." },
67
+ "credentials_file": { "type": "string", "description": "Service account key or OAuth client file. Keep it outside the repository." }
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/exceptions.schema.json",
4
+ "title": "TargetZero exception",
5
+ "description": "One row of registers/exceptions.csv. The schema checks the format only; validity (signed, expiry at most 90 days after signing, not expired) is checked by the scorecard.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["id", "zero", "items", "description", "compensating_control", "accepted_by", "signed_date", "expiry_date"],
9
+ "properties": {
10
+ "id": { "type": "string", "pattern": "^EXC-[A-Za-z0-9-]+$" },
11
+ "zero": { "type": "string", "pattern": "^[1-7]$" },
12
+ "items": { "type": "string", "description": "Item ids from the summaries, separated by semicolons." },
13
+ "description": { "type": "string", "description": "What it is and why it cannot be fixed now." },
14
+ "compensating_control": { "type": "string", "description": "What limits the risk in the meantime." },
15
+ "accepted_by": { "type": "string", "description": "Name and role of the manager who signed." },
16
+ "signed_date": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
17
+ "expiry_date": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
18
+ "notes": { "type": "string" }
19
+ }
20
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/findings.schema.json",
4
+ "title": "TargetZero vulnerability finding",
5
+ "description": "One row of registers/findings.csv: a known vulnerability on a public asset (Zero 6).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["id", "asset_id", "vulnerability", "severity", "published", "deadline", "status"],
9
+ "properties": {
10
+ "id": { "type": "string", "pattern": "^[a-z0-9-]+:[^\\s;]+$" },
11
+ "asset_id": { "type": "string", "minLength": 1, "description": "id of the inventory row." },
12
+ "vulnerability": { "type": "string", "minLength": 1, "description": "CVE id or vendor advisory id." },
13
+ "title": { "type": "string" },
14
+ "severity": { "enum": ["kev", "critical", "high", "medium", "low"], "description": "kev = known exploited; deadlines 8 h / 24 h / 72 h apply to kev / critical / high." },
15
+ "published": { "type": "string", "minLength": 10, "description": "ISO 8601 date or timestamp." },
16
+ "deadline": { "type": "string", "minLength": 10, "description": "ISO 8601 timestamp." },
17
+ "status": { "enum": ["open", "mitigated", "patched", "exception"] },
18
+ "action": { "type": "string" },
19
+ "owner": { "type": "string" },
20
+ "closed_date": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
21
+ "notes": { "type": "string" }
22
+ }
23
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/inventory.schema.json",
4
+ "title": "TargetZero inventory row",
5
+ "description": "One row of registers/inventory.csv: one public IP, domain or subdomain (Zero 5).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["id", "asset", "type", "status"],
9
+ "properties": {
10
+ "id": { "type": "string", "pattern": "^[a-z0-9-]+:[^\\s;]+$" },
11
+ "asset": { "type": "string", "minLength": 1 },
12
+ "type": { "enum": ["ip", "domain", "subdomain"] },
13
+ "ip": { "type": "string" },
14
+ "owner": { "type": "string" },
15
+ "purpose": { "type": "string" },
16
+ "product": { "type": "string" },
17
+ "version": { "type": "string" },
18
+ "vendor_supported": { "enum": ["Y", "N", "?", ""] },
19
+ "eol_date": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
20
+ "behind_waf": { "enum": ["Y", "N", "?", "n/a", ""] },
21
+ "internet_facing_app": { "enum": ["Y", "N", ""] },
22
+ "status": { "enum": ["reviewed", "unreviewed", "retired"] },
23
+ "last_reviewed": { "type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$" },
24
+ "notes": { "type": "string" }
25
+ }
26
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/wiresecurity/TargetZero/schema/summary.schema.json",
4
+ "title": "TargetZero count summary",
5
+ "description": "Written by every TargetZero script next to its CSV records. The scorecard reads only these files. Any tool can feed the scorecard by writing a valid summary.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schema_version", "zero", "source", "name", "tool", "tool_version", "run_date", "generated_at", "count", "complete", "items"],
9
+ "properties": {
10
+ "schema_version": { "const": "1.0" },
11
+ "zero": { "type": "integer", "minimum": 1, "maximum": 7, "description": "Target 0 count this summary contributes to." },
12
+ "source": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$", "description": "Platform or system, e.g. m365, gws, external, fortigate." },
13
+ "name": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$", "description": "Short name of the check, e.g. admins, mfa, exposure." },
14
+ "tool": { "type": "string", "minLength": 1 },
15
+ "tool_version": { "type": "string", "minLength": 1 },
16
+ "run_date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
17
+ "generated_at": { "type": "string", "minLength": 20, "description": "ISO 8601 timestamp with time zone." },
18
+ "count": { "type": "integer", "minimum": 0, "description": "Must equal the number of items." },
19
+ "complete": { "type": "boolean", "description": "False when the check could not see everything (missing permission, licence, unreachable system). The scorecard flags incomplete counts." },
20
+ "notes": { "type": "array", "items": { "type": "string" }, "description": "Which path was used, licence fallbacks, warnings." },
21
+ "record_file": { "type": "string", "description": "CSV file with the full records, relative to the summary file." },
22
+ "items": {
23
+ "type": "array",
24
+ "description": "Every item counted. Exceptions refer to these ids.",
25
+ "items": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["id", "reason"],
29
+ "properties": {
30
+ "id": { "type": "string", "pattern": "^[a-z0-9-]+:[^\\s;]+$", "description": "<source>:<stable identifier> without spaces or semicolons, e.g. m365:admin@contoso.com/global-administrator. The same item must get the same id on every run." },
31
+ "reason": { "type": "string", "minLength": 1 }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,2 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Scorecard: combine count summaries into the Target 0 table."""