-
Notifications
You must be signed in to change notification settings - Fork 1
feat(promote): enforce the no-self-escalation ceiling at the gate — #5-ceiling #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,12 +28,13 @@ def build_bundle(*, run_id, created, operator, intent, source, configs, batfish, | |
| twin, diff, compliance, tier, needs_approval, approver, | ||
| approval_utc, rollback_plan, decision, reason, | ||
| model_identity: dict | None = None, | ||
| authority: dict | None = None, | ||
| signed: bool = False) -> dict: | ||
| severity = _severity(diff["devices_affected"], | ||
| len(diff["sessions_dropped"]), | ||
| batfish["errors"], twin["converged"]) | ||
| bundle = { | ||
| "bundle_version": "1.1", | ||
| "bundle_version": "1.2", | ||
| "run_id": run_id, | ||
| "created_utc": created, | ||
| "operator": operator, | ||
|
|
@@ -53,6 +54,8 @@ def build_bundle(*, run_id, created, operator, intent, source, configs, batfish, | |
| }, | ||
| "model_identity": (model_identity if model_identity is not None | ||
| else _unknown_identity()), | ||
| "authority": (authority if authority is not None | ||
| else _failclosed_authority(severity)), | ||
| }, | ||
| "twin": { | ||
| "engine": "containerlab", | ||
|
|
@@ -136,3 +139,18 @@ def unattested_identity() -> dict: | |
| "capabilities": [], | ||
| "resolved_at_utc": _SYNTHETIC_RESOLVED_AT, | ||
| } | ||
|
|
||
|
|
||
| def _failclosed_authority(severity: str) -> dict: | ||
| """Fallback when no authority was computed (a direct build_bundle call). Fail CLOSED: | ||
| an unknown authority is BLOCK, so it can never be promoted. run_preflight always | ||
| supplies a real record (core.risk.authority_record).""" | ||
| return { | ||
| "severity": severity, | ||
| "required": "block", | ||
| "max_authorized": "auto", | ||
| "allowed": False, | ||
| "effective": "block", | ||
|
Comment on lines
+144
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Align the fail-closed authority ceiling with This fallback uses |
||
| "change_class": {"touches_asn": False, "touches_rd_rt": False, | ||
| "touches_spine": False, "touches_underlay": False}, | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Defensively handle non-dict
authorityvalues to avoid runtime AttributeError.If
bundle['change']['authority']exists but is not a mapping (e.g., a string or list),authority.get(...)will raiseAttributeErrorand crash the gate instead of failing closed. Please guard withisinstance(authority, Mapping)(ordict) and, on failure, return a fail-closedGateDecision, consistent with the missing/KeyErrorhandling.