feat(security): 鎖住 Telegram 通知出口新增旁路
This commit is contained in:
@@ -231,12 +231,18 @@ def validate(root: Path) -> None:
|
||||
telegram_notification_egress_inventory = load_json(
|
||||
security_dir / "telegram-notification-egress-inventory.snapshot.json"
|
||||
)
|
||||
telegram_notification_egress_no_new_bypass_guard = load_json(
|
||||
security_dir / "telegram-notification-egress-no-new-bypass-guard.snapshot.json"
|
||||
)
|
||||
telegram_notification_egress_owner_request_draft = load_json(
|
||||
security_dir / "telegram-notification-egress-owner-request-draft.snapshot.json"
|
||||
)
|
||||
telegram_notification_egress_migration_plan_draft = load_json(
|
||||
security_dir / "telegram-notification-egress-migration-plan-draft.snapshot.json"
|
||||
)
|
||||
telegram_notification_egress_owner_response_acceptance = load_json(
|
||||
security_dir / "telegram-notification-egress-owner-response-acceptance.snapshot.json"
|
||||
)
|
||||
public_runtime_config_change_evidence_acceptance = load_json(
|
||||
security_dir / "public-runtime-config-change-evidence-acceptance.snapshot.json"
|
||||
)
|
||||
@@ -21894,6 +21900,238 @@ def validate(root: Path) -> None:
|
||||
f"telegram_notification_egress_migration_plan_draft.{item['migration_candidate_id']}.{false_key}",
|
||||
item[false_key],
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_no_new_bypass_guard.schema",
|
||||
telegram_notification_egress_no_new_bypass_guard["schema_version"],
|
||||
"telegram_notification_egress_no_new_bypass_guard_v1",
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_no_new_bypass_guard.status",
|
||||
telegram_notification_egress_no_new_bypass_guard["status"],
|
||||
"pass_no_new_bypass",
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_no_new_bypass_guard.mode",
|
||||
telegram_notification_egress_no_new_bypass_guard["mode"],
|
||||
"repo_source_scan_no_secret_value_no_telegram_send",
|
||||
)
|
||||
expected_telegram_egress_no_new_bypass_summary = {
|
||||
"source_direct_bot_api_call_count": 18,
|
||||
"source_direct_bot_api_file_count": 11,
|
||||
"baseline_signature_count": 18,
|
||||
"current_direct_bot_api_call_count": 18,
|
||||
"current_direct_bot_api_file_count": 11,
|
||||
"guarded_method_count": 9,
|
||||
"sendMessage_call_count": 18,
|
||||
"sendDocument_call_count": 0,
|
||||
"sendPhoto_call_count": 0,
|
||||
"sendMediaGroup_call_count": 0,
|
||||
"editMessageText_call_count": 0,
|
||||
"other_guarded_method_call_count": 0,
|
||||
"new_bypass_count": 0,
|
||||
"new_bypass_file_count": 0,
|
||||
"removed_baseline_call_count": 0,
|
||||
"runtime_gate_count": 0,
|
||||
"action_button_count": 0,
|
||||
}
|
||||
for key, expected in expected_telegram_egress_no_new_bypass_summary.items():
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_no_new_bypass_guard.summary.{key}",
|
||||
telegram_notification_egress_no_new_bypass_guard["summary"][key],
|
||||
expected,
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_no_new_bypass_guard.current_paths",
|
||||
[item["path"] for item in telegram_notification_egress_no_new_bypass_guard["current_direct_bot_api_calls"]],
|
||||
[
|
||||
".gitea/workflows/cd-dev.yaml",
|
||||
".gitea/workflows/cd-dev.yaml",
|
||||
".gitea/workflows/cd-dev.yaml",
|
||||
".gitea/workflows/cd.yaml",
|
||||
".gitea/workflows/cd.yaml",
|
||||
".gitea/workflows/cd.yaml",
|
||||
".gitea/workflows/cd.yaml",
|
||||
".gitea/workflows/cd.yaml",
|
||||
".gitea/workflows/code-review.yaml",
|
||||
".gitea/workflows/code-review.yaml",
|
||||
".gitea/workflows/deploy-alerts.yaml",
|
||||
".gitea/workflows/e2e-health.yaml",
|
||||
".gitea/workflows/run-migration.yml",
|
||||
"apps/api/src/services/channel_hub.py",
|
||||
"scripts/ops/backup-from-110.sh",
|
||||
"scripts/ops/docker-health-monitor.sh",
|
||||
"scripts/ops/dr-drill.sh",
|
||||
"scripts/ops/pg-backup.sh",
|
||||
],
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_no_new_bypass_guard.new_bypass_findings",
|
||||
telegram_notification_egress_no_new_bypass_guard["new_bypass_findings"],
|
||||
[],
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_no_new_bypass_guard.removed_baseline_signatures",
|
||||
telegram_notification_egress_no_new_bypass_guard["removed_baseline_signatures"],
|
||||
[],
|
||||
)
|
||||
for key, value in telegram_notification_egress_no_new_bypass_guard["execution_boundaries"].items():
|
||||
if key == "not_authorization":
|
||||
assert_true(f"telegram_notification_egress_no_new_bypass_guard.execution_boundaries.{key}", value)
|
||||
else:
|
||||
assert_false(f"telegram_notification_egress_no_new_bypass_guard.execution_boundaries.{key}", value)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_owner_response_acceptance.schema",
|
||||
telegram_notification_egress_owner_response_acceptance["schema_version"],
|
||||
"telegram_notification_egress_owner_response_acceptance_v1",
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_owner_response_acceptance.status",
|
||||
telegram_notification_egress_owner_response_acceptance["status"],
|
||||
"owner_response_acceptance_ledger_ready_no_runtime_action",
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_owner_response_acceptance.mode",
|
||||
telegram_notification_egress_owner_response_acceptance["mode"],
|
||||
"metadata_only_no_secret_value_no_telegram_send_no_workflow_script_api_change",
|
||||
)
|
||||
expected_telegram_egress_owner_response_acceptance_summary = {
|
||||
"source_request_draft_count": 11,
|
||||
"source_migration_candidate_count": 11,
|
||||
"source_direct_bot_api_call_count": 18,
|
||||
"acceptance_candidate_count": 11,
|
||||
"workflow_acceptance_candidate_count": 6,
|
||||
"ops_script_acceptance_candidate_count": 4,
|
||||
"api_direct_acceptance_candidate_count": 1,
|
||||
"acceptance_field_count": 32,
|
||||
"required_owner_field_count": 19,
|
||||
"reviewer_check_count": 22,
|
||||
"outcome_lane_count": 10,
|
||||
"forbidden_payload_count": 14,
|
||||
"blocked_action_count": 35,
|
||||
"request_sent_count": 0,
|
||||
"recipient_confirmed_count": 0,
|
||||
"audit_event_emitted_count": 0,
|
||||
"owner_response_received_count": 0,
|
||||
"owner_response_accepted_count": 0,
|
||||
"owner_response_rejected_count": 0,
|
||||
"owner_response_quarantined_count": 0,
|
||||
"supplement_requested_count": 0,
|
||||
"formatter_convergence_accepted_count": 0,
|
||||
"redaction_contract_accepted_count": 0,
|
||||
"delivery_receipt_accepted_count": 0,
|
||||
"break_glass_fallback_accepted_count": 0,
|
||||
"maintenance_window_accepted_count": 0,
|
||||
"rollback_owner_accepted_count": 0,
|
||||
"postcheck_evidence_accepted_count": 0,
|
||||
"dedup_or_fingerprint_accepted_count": 0,
|
||||
"no_false_green_accepted_count": 0,
|
||||
"direct_bot_api_migration_authorized_count": 0,
|
||||
"workflow_modification_authorized_count": 0,
|
||||
"script_modification_authorized_count": 0,
|
||||
"api_sender_refactor_authorized_count": 0,
|
||||
"telegram_send_authorized_count": 0,
|
||||
"bot_api_call_authorized_count": 0,
|
||||
"workflow_dispatch_authorized_count": 0,
|
||||
"production_deploy_authorized_count": 0,
|
||||
"secret_value_collection_allowed_count": 0,
|
||||
"raw_payload_storage_allowed_count": 0,
|
||||
"production_write_authorized_count": 0,
|
||||
"runtime_gate_count": 0,
|
||||
"action_button_count": 0,
|
||||
}
|
||||
for key, expected in expected_telegram_egress_owner_response_acceptance_summary.items():
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.summary.{key}",
|
||||
telegram_notification_egress_owner_response_acceptance["summary"][key],
|
||||
expected,
|
||||
)
|
||||
assert_equal(
|
||||
"telegram_notification_egress_owner_response_acceptance.source_paths",
|
||||
[item["source_path"] for item in telegram_notification_egress_owner_response_acceptance["acceptance_candidates"]],
|
||||
expected_telegram_egress_request_paths,
|
||||
)
|
||||
for key, value in telegram_notification_egress_owner_response_acceptance["execution_boundaries"].items():
|
||||
if key == "not_authorization":
|
||||
assert_true(
|
||||
f"telegram_notification_egress_owner_response_acceptance.execution_boundaries.{key}",
|
||||
value,
|
||||
)
|
||||
else:
|
||||
assert_false(
|
||||
f"telegram_notification_egress_owner_response_acceptance.execution_boundaries.{key}",
|
||||
value,
|
||||
)
|
||||
for item in telegram_notification_egress_owner_response_acceptance["acceptance_candidates"]:
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.acceptance_fields",
|
||||
len(item["acceptance_fields"]),
|
||||
32,
|
||||
)
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.required_owner_fields",
|
||||
len(item["required_owner_fields"]),
|
||||
19,
|
||||
)
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.reviewer_checks",
|
||||
len(item["reviewer_checks"]),
|
||||
22,
|
||||
)
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.outcome_lanes",
|
||||
len(item["outcome_lanes"]),
|
||||
10,
|
||||
)
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.forbidden_payloads",
|
||||
len(item["forbidden_payloads"]),
|
||||
14,
|
||||
)
|
||||
assert_equal(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.blocked_actions",
|
||||
len(item["blocked_actions"]),
|
||||
35,
|
||||
)
|
||||
assert_true(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.not_authorization",
|
||||
item["not_authorization"],
|
||||
)
|
||||
for false_key in [
|
||||
"request_sent",
|
||||
"recipient_confirmed",
|
||||
"audit_event_emitted",
|
||||
"owner_response_received",
|
||||
"owner_response_accepted",
|
||||
"owner_response_rejected",
|
||||
"owner_response_quarantined",
|
||||
"supplement_requested",
|
||||
"formatter_convergence_accepted",
|
||||
"redaction_contract_accepted",
|
||||
"delivery_receipt_accepted",
|
||||
"break_glass_fallback_accepted",
|
||||
"maintenance_window_accepted",
|
||||
"rollback_owner_accepted",
|
||||
"postcheck_evidence_accepted",
|
||||
"dedup_or_fingerprint_accepted",
|
||||
"no_false_green_accepted",
|
||||
"direct_bot_api_migration_authorized",
|
||||
"workflow_modification_authorized",
|
||||
"script_modification_authorized",
|
||||
"api_sender_refactor_authorized",
|
||||
"telegram_send_authorized",
|
||||
"bot_api_call_authorized",
|
||||
"workflow_dispatch_authorized",
|
||||
"production_deploy_authorized",
|
||||
"secret_value_collection_allowed",
|
||||
"raw_payload_storage_allowed",
|
||||
"production_write_authorized",
|
||||
"runtime_gate",
|
||||
"action_buttons_allowed",
|
||||
]:
|
||||
assert_false(
|
||||
f"telegram_notification_egress_owner_response_acceptance.{item['acceptance_candidate_id']}.{false_key}",
|
||||
item[false_key],
|
||||
)
|
||||
assert_equal(
|
||||
"public_runtime_config_change_evidence_acceptance.schema",
|
||||
public_runtime_config_change_evidence_acceptance["schema_version"],
|
||||
|
||||
Reference in New Issue
Block a user