Add governed test plane and close T04/T08
Encode fail-closed admission, target registrations, and a credential broker that never returns secret values. Calibrate audit-core shaped probes in-process. Send no packets and request no live credentials. Assistant: grok Assistant-Session: 01a02670-3345-76f2-a014-70fde8e2a2bb
This commit is contained in:
parent
0aab0cb4c6
commit
95129d7a35
35 changed files with 1599 additions and 103 deletions
|
|
@ -6,19 +6,26 @@ import sys
|
|||
from dataclasses import asdict
|
||||
from pathlib import Path
|
||||
|
||||
from .audit_fixtures import AuditFixture, audit_probe_suite
|
||||
from .capacity import CapacitySample, characterize
|
||||
from .differential import execute
|
||||
from .e3 import CADENCE, PROBES
|
||||
from .engagement import AuthorizationError, Engagement
|
||||
from .fixtures import FixtureService, probe_suite
|
||||
from .model import RunReport, utc_now
|
||||
from .reporting import risk_nexus_message
|
||||
from .plane import KillSwitch, admit, default_broker, retired_ids
|
||||
from .reporting import queue_risk_nexus, risk_nexus_message
|
||||
from .targets import load_catalog, load_registration
|
||||
|
||||
|
||||
def fixture_calibration() -> dict:
|
||||
started = utc_now()
|
||||
good = [execute(probe) for probe in probe_suite(FixtureService(enforce_tenant=True))]
|
||||
bad = [execute(probe) for probe in probe_suite(FixtureService(enforce_tenant=False))]
|
||||
good_generic = probe_suite(FixtureService(enforce_tenant=True))
|
||||
bad_generic = probe_suite(FixtureService(enforce_tenant=False))
|
||||
good_audit = audit_probe_suite(AuditFixture(enforce_tenant=True))
|
||||
bad_audit = audit_probe_suite(AuditFixture(enforce_tenant=False))
|
||||
good = [execute(probe) for probe in (*good_generic, *good_audit)]
|
||||
bad = [execute(probe) for probe in (*bad_generic, *bad_audit)]
|
||||
detected = all(result.outcome == "finding" for result in bad)
|
||||
rejected = all(result.outcome == "pass" for result in good)
|
||||
return {
|
||||
|
|
@ -78,6 +85,15 @@ def main(argv: list[str] | None = None) -> None:
|
|||
engagement.add_argument("path")
|
||||
packs = commands.add_parser("validate-packs")
|
||||
packs.add_argument("path")
|
||||
targets = commands.add_parser("validate-targets")
|
||||
targets.add_argument("path")
|
||||
admit_plane = commands.add_parser("admit-plane")
|
||||
admit_plane.add_argument("engagement")
|
||||
admit_plane.add_argument("registration")
|
||||
commands.add_parser("kill-switch")
|
||||
deliver = commands.add_parser("deliver")
|
||||
deliver.add_argument("report")
|
||||
deliver.add_argument("--outbox", default="outbox")
|
||||
commands.add_parser("e3-plan")
|
||||
commands.add_parser("capacity-fixture")
|
||||
message = commands.add_parser("risk-message")
|
||||
|
|
@ -108,6 +124,42 @@ def main(argv: list[str] | None = None) -> None:
|
|||
validate_pack(path)
|
||||
print(f"validated {len(paths)} probe packs")
|
||||
return
|
||||
if args.command == "validate-targets":
|
||||
try:
|
||||
catalog = load_catalog(args.path)
|
||||
except (AuthorizationError, OSError, ValueError, json.JSONDecodeError) as error:
|
||||
print(f"not authorized: {error}", file=sys.stderr)
|
||||
raise SystemExit(2) from None
|
||||
print(f"validated {len(catalog)} target registrations")
|
||||
return
|
||||
if args.command == "admit-plane":
|
||||
try:
|
||||
record = Engagement.load(args.engagement)
|
||||
registration = load_registration(args.registration)
|
||||
lease = admit(engagement=record, registration=registration,
|
||||
broker=default_broker(record), kill_switch=KillSwitch(),
|
||||
retired=retired_ids())
|
||||
except (AuthorizationError, OSError, ValueError, json.JSONDecodeError) as error:
|
||||
print(f"not authorized: {error}", file=sys.stderr)
|
||||
raise SystemExit(2) from None
|
||||
print(f"admitted: {lease.engagement.raw['engagement_id']} lease={lease.lease_id}")
|
||||
return
|
||||
if args.command == "kill-switch":
|
||||
switch = KillSwitch()
|
||||
if switch.engaged():
|
||||
print(f"engaged: {switch.path}")
|
||||
raise SystemExit(1)
|
||||
print("clear")
|
||||
return
|
||||
if args.command == "deliver":
|
||||
try:
|
||||
report = RunReport(**json.loads(Path(args.report).read_text(encoding="utf-8")))
|
||||
path = queue_risk_nexus(report, args.outbox)
|
||||
except (AuthorizationError, OSError, ValueError, json.JSONDecodeError, TypeError) as error:
|
||||
print(f"not authorized: {error}", file=sys.stderr)
|
||||
raise SystemExit(2) from None
|
||||
print(f"queued: {path}")
|
||||
return
|
||||
if args.command == "e3-plan":
|
||||
print(json.dumps({"cadence": CADENCE, "probes": [asdict(probe) for probe in PROBES]},
|
||||
indent=2, sort_keys=True))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue