feat(iwooos): 新增外部入侵主機防堵控制
Some checks failed
CD Pipeline / tests (push) Successful in 1m45s
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / build-and-deploy (push) Successful in 17m44s
CD Pipeline / post-deploy-checks (push) Has been cancelled

This commit is contained in:
Your Name
2026-06-18 10:24:33 +08:00
parent 795ed91f28
commit 5820ca90cc
14 changed files with 5194 additions and 128 deletions

View File

@@ -0,0 +1,657 @@
#!/usr/bin/env python3
"""
IwoooS 外部入侵主機防堵控制矩陣產生器。
本工具只產生 repo 內 snapshot將外部入口、SSH / sudo、端口 /
防火牆、Nginx、runner、secret、Docker / systemd、K8s / ArgoCD、
Wazuh、套件更新、backup / restore 與跨專案同步收斂成同一份可審核
控制矩陣。
它不連線主機、不 SSH、不讀 live config、不改 Nginx / firewall / K8s、
不啟用 Wazuh active response、不重啟服務、不更新套件、不輪替 secret、
不做 active scan也不把 UI 可見、服務 200 或外部 Agent 宣稱當成已防堵。
"""
from __future__ import annotations
import argparse
import json
import subprocess
import sys
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Any
TAIPEI = timezone(timedelta(hours=8))
HOST_ALIASES = ["host-110", "host-188", "dev-host-111", "dev-host-168"]
SENSOR_ALIASES = ["sensor-kali-112"]
PREVENTION_DOMAINS = [
{
"domain_id": "public_ingress_gateway",
"label": "公開入口 / DNS / TLS / Nginx / public gateway",
"control_tier": "C0",
"immediate_risk": "未受控 reload、route drift、上游錯配或 TLS / ACME 變更會造成外部暴露或服務中斷。",
},
{
"domain_id": "ssh_sudo_access",
"label": "SSH / sudo / authorized_keys / known_hosts",
"control_tier": "C0",
"immediate_risk": "未受控登入、sudo 權限、host key 漂移或跳板憑證會擴大入侵面。",
},
{
"domain_id": "firewall_network_policy",
"label": "Firewall / WireGuard / NodePort / NetworkPolicy",
"control_tier": "C0",
"immediate_risk": "端口開關、內網路由、NodePort 或 NetworkPolicy 漂移會直接改變可攻擊面。",
},
{
"domain_id": "host_runtime_services",
"label": "Docker / systemd / process / port binding",
"control_tier": "C0",
"immediate_risk": "容器重啟、failed unit、未知 process、port binding 或 persistence 會影響服務與入侵駐留判讀。",
},
{
"domain_id": "k8s_gitops_runtime",
"label": "K8s / ArgoCD / RBAC / Secret metadata",
"control_tier": "C0",
"immediate_risk": "GitOps drift、RBAC / Secret metadata、image pull 或 pending workload 可能隱藏惡意部署與供應鏈變更。",
},
{
"domain_id": "runner_workflow_supply_chain",
"label": "Gitea runner / workflow / deploy key / webhook",
"control_tier": "C0",
"immediate_risk": "runner、workflow、deploy key 或 webhook 被改動會直接打開 production 寫入路徑。",
},
{
"domain_id": "secret_credential_exposure",
"label": "Secret / session / API token / credential hygiene",
"control_tier": "C0",
"immediate_risk": "secret、session、API token 或 env dump 外洩會讓修復失效並擴散到其他產品。",
},
{
"domain_id": "wazuh_detection_response",
"label": "Wazuh manager / agent / rule / active response",
"control_tier": "C0",
"immediate_risk": "偵測與 response 邊界不清會造成假綠燈、誤隔離、漏封鎖或錯信外部宣稱。",
},
{
"domain_id": "package_patch_vulnerability",
"label": "套件更新 / CVE / maintenance window",
"control_tier": "C1",
"immediate_risk": "未修補套件與服務版本過舊會保留可利用入口,但無維護窗口直接升級也會造成中斷。",
},
{
"domain_id": "backup_restore_resilience",
"label": "Backup / restore / offsite / escrow / rollback",
"control_tier": "C1",
"immediate_risk": "沒有可驗證 restore 與 rollback入侵後清除、重建與服務恢復都沒有可信退路。",
},
{
"domain_id": "monitoring_alerting_false_green",
"label": "Monitoring / alerting / no-false-green",
"control_tier": "C1",
"immediate_risk": "route 200、dashboard up 或 alert quiet 若被當成資安通過,會掩蓋持久化與告警失效。",
},
{
"domain_id": "cross_project_freeze_sync",
"label": "跨專案 freeze / operator sync / break-glass",
"control_tier": "C1",
"immediate_risk": "多 session 或多專案並行修改會造成重複修復、rebase 衝突、錯誤 reload 或未同步封鎖。",
},
]
REQUIRED_OWNER_FIELDS = [
"control_id",
"owner_role",
"owner_team",
"decision",
"decision_reason",
"affected_scope_aliases",
"exposed_surface_aliases",
"current_risk",
"immediate_harm_if_delayed",
"redacted_evidence_refs",
"wazuh_event_refs",
"host_forensic_refs",
"config_diff_refs",
"before_state_ref",
"after_state_ref",
"maintenance_window",
"break_glass_reason",
"rollback_owner",
"rollback_plan_ref",
"validation_metrics",
"postcheck_owner",
"postcheck_ref",
"cross_project_sync_ref",
"communication_channel",
"secret_value_absence_attestation",
"raw_payload_absence_attestation",
"no_internal_name_publication_attestation",
"no_false_green_attestation",
"service_impact_assessment",
"ai_provider_impact_assessment",
"monitoring_alert_impact_assessment",
"backup_restore_impact_assessment",
"recurrence_guard_ref",
"followup_owner",
"expiry_or_review_date",
"reviewer_attestation",
]
REVIEWER_CHECKS = [
{"check_id": "scope_alias_only", "instruction": "只接受 host alias、service alias、product alias不得公開內網 IP、帳號 namespace 或 repo owner 原名。"},
{"check_id": "owner_role_and_team_present", "instruction": "每個防堵候選都需要 owner role / team不能匿名批准。"},
{"check_id": "decision_and_reason_present", "instruction": "需要明確 decision 與 decision reason不得只寫批准或已處理。"},
{"check_id": "wazuh_event_refs_required_for_intrusion", "instruction": "主機入侵、惡意程式或 RCE 類候選必須有 Wazuh event refs。"},
{"check_id": "host_forensic_refs_required", "instruction": "需要 auth、process、network、FIM、package 或 persistence refs服務恢復不能取代鑑識。"},
{"check_id": "gateway_diff_required", "instruction": "公開入口、Nginx、TLS、route 或 upstream 變更需有 source-to-live diff refs。"},
{"check_id": "firewall_before_after_required", "instruction": "端口、防火牆、WireGuard、NodePort 或 NetworkPolicy 需有 before / after state。"},
{"check_id": "ssh_sudo_scope_required", "instruction": "SSH、sudo、deploy key 或 known_hosts 需標示範圍與回滾 owner。"},
{"check_id": "runner_workflow_diff_required", "instruction": "runner、workflow、webhook 或 deploy key 需有 diff、run ref、permission scope 與 workspace cleanup。"},
{"check_id": "secret_values_absent", "instruction": "不得收 secret value、hash、partial token、cookie、env dump、private key 或 runner token。"},
{"check_id": "raw_payload_absent", "instruction": "不得保存 raw Wazuh payload、raw log、raw journal、完整命令輸出或未脫敏截圖。"},
{"check_id": "maintenance_window_required", "instruction": "任何可能中斷服務的防堵都需要 maintenance window。"},
{"check_id": "rollback_owner_required", "instruction": "任何 host、gateway、firewall、runner、K8s 或 secret 相關候選都需要 rollback owner。"},
{"check_id": "validation_metrics_required", "instruction": "防堵後驗證需列 route、API、agent、alert、backup 或 service health 指標。"},
{"check_id": "cross_project_sync_required", "instruction": "影響 AWOOOI、AwoooP、IwoooS、VibeWork、agent-bounty-protocol、stock 或監控需有同步 ref。"},
{"check_id": "no_false_green", "instruction": "route 200、dashboard up、agent active、CD success、UI 可見都不能單獨當資安驗收。"},
{"check_id": "external_agent_claim_not_trusted", "instruction": "外部 Agent 宣稱已封鎖、清除或 Zero-Trust 不能直接 accepted。"},
{"check_id": "active_response_dry_run_first", "instruction": "Wazuh active response 必須先 dry-run、驗證 blast radius 與 rollback不得直接 production enable。"},
{"check_id": "firewall_change_break_glass_only", "instruction": "firewall drop、port close/open 需 break-glass 或 maintenance window不得由候選自動執行。"},
{"check_id": "host_service_write_blocked", "instruction": "不得由本 artifact 觸發 Docker、systemd、kill process、package upgrade 或 reboot。"},
{"check_id": "k8s_argocd_write_blocked", "instruction": "不得由本 artifact 觸發 ArgoCD sync、kubectl、Helm、NetworkPolicy 或 RBAC apply。"},
{"check_id": "backup_restore_not_assumed", "instruction": "備份存在、冷啟動分數或 UI 可見不能代表 restore / rollback 可用。"},
{"check_id": "credential_rotation_requires_decision", "instruction": "credential rotation 需 owner decision、blast radius、dependent services 與 rollback plan。"},
{"check_id": "package_upgrade_requires_window", "instruction": "套件更新、kernel、Docker、Nginx、Wazuh agent 或 Kali 更新需維護窗口與 postcheck。"},
{"check_id": "public_frontend_no_internal_transcript", "instruction": "前台不得顯示工作視窗、內部對話、抱怨、raw namespace 或截圖原文。"},
{"check_id": "production_write_stays_zero", "instruction": "防堵矩陣不是 production write 授權runtime gate 與 action button 必須維持 0。"},
{"check_id": "evidence_refs_redacted", "instruction": "只收脫敏 ref、ticket、artifact pointer不得貼 raw secret 或 raw payload。"},
{"check_id": "parallel_session_conflict_checked", "instruction": "需確認其他 session 是否正在操作同一主機、Nginx、runner、workflow 或 secret。"},
{"check_id": "service_dependency_map_present", "instruction": "端口、gateway、host service 或 AI provider 變更需列服務依賴與受影響產品 alias。"},
{"check_id": "operator_notification_present", "instruction": "即時危害或可能中斷的防堵需有 operator notification / receipt plan。"},
{"check_id": "postcheck_independent", "instruction": "postcheck 必須由獨立於操作人的 reviewer 或 automation readback 驗證。"},
{"check_id": "recurrence_guard_present", "instruction": "需補防再發 guard例如 config drift、runner freeze、secret hygiene、Wazuh rule coverage 或 firewall diff guard。"},
{"check_id": "expiry_or_review_date_present", "instruction": "臨時 freeze、break-glass 或例外需有到期或複審日期。"},
{"check_id": "counts_transition_safe", "instruction": "received / accepted / authorized / executed / allowed 類計數只能由正式驗收推進。"},
]
OUTCOME_LANES = [
{"lane_id": "waiting_owner_prevention_packet", "meaning": "防堵候選已建立,等待 owner 補齊欄位與脫敏證據。"},
{"lane_id": "request_wazuh_event_supplement", "meaning": "缺 Wazuh event / alert refs 時要求補件。"},
{"lane_id": "request_host_forensics_supplement", "meaning": "缺主機鑑識 refs 時要求補件。"},
{"lane_id": "request_config_diff_supplement", "meaning": "缺 Nginx、firewall、runner、workflow、K8s 或 secret metadata diff 時要求補件。"},
{"lane_id": "request_maintenance_window", "meaning": "涉及服務中斷、重啟、封鎖、更新或 active response 時要求維護窗口。"},
{"lane_id": "request_break_glass_record", "meaning": "即時封鎖或緊急變更需補 break-glass reason 與通知紀錄。"},
{"lane_id": "quarantine_secret_or_raw_payload", "meaning": "收到 secret、raw log、raw payload、env dump 或未脫敏截圖時隔離。"},
{"lane_id": "reject_claim_without_evidence", "meaning": "只有外部宣稱、route 200、dashboard up 或 agent active 時拒收。"},
{"lane_id": "route_to_high_value_config_gate", "meaning": "涉及高價值配置時串到既有配置控管 gate。"},
{"lane_id": "ready_for_prevention_reviewer_review", "meaning": "metadata 合格後進 reviewer review不自動執行。"},
{"lane_id": "waiting_runtime_authorization", "meaning": "即使 accepted也需獨立批准才可進 runtime 防堵。"},
{"lane_id": "blocked_no_rollback_or_postcheck", "meaning": "缺 rollback owner、validation 或 postcheck 時不得進下一關。"},
]
BLOCKED_ACTIONS = [
"ssh_read",
"ssh_write",
"sudo_action",
"host_file_read",
"host_file_write",
"host_live_config_read",
"iptables_change",
"ufw_change",
"firewall_drop",
"firewall_allow",
"port_close",
"port_open",
"wireguard_change",
"nodeport_change",
"network_policy_apply",
"nginx_test",
"nginx_reload",
"nginx_conf_write",
"certbot_renew",
"dns_record_change",
"route_change",
"upstream_change",
"websocket_route_change",
"docker_restart",
"docker_kill",
"docker_compose_up",
"docker_compose_down",
"systemctl_restart",
"systemctl_stop",
"systemctl_start",
"kill_process",
"quarantine_host",
"reboot_host",
"apt_update",
"apt_upgrade",
"package_install",
"kernel_upgrade",
"wazuh_active_response_enable",
"wazuh_agent_install",
"wazuh_agent_restart",
"wazuh_rule_change",
"wazuh_decoder_change",
"wazuh_api_live_query_without_owner_gate",
"argocd_sync",
"kubectl_apply",
"kubectl_delete",
"helm_upgrade",
"rbac_change",
"k8s_secret_change",
"workflow_modification",
"gitea_action_dispatch",
"runner_label_change",
"runner_config_change",
"deploy_key_change",
"webhook_change",
"repo_secret_change",
"secret_rotation",
"secret_store_read",
"collect_password",
"collect_private_key",
"collect_runner_token",
"collect_webhook_secret",
"collect_cookie_or_session",
"collect_env_dump",
"store_raw_wazuh_payload",
"store_raw_syslog",
"store_raw_journal",
"store_raw_command_output",
"store_unredacted_screenshot",
"active_scan",
"credentialed_scan",
"exploit_validation",
"backup_run",
"restore_run",
"offsite_sync",
"remote_delete",
"retention_change",
"database_migration",
"production_write",
"add_action_button",
"open_runtime_gate",
"force_push",
]
CONTROL_CANDIDATES = [
{
"control_id": "external_host_prevention:public_gateway_freeze_diff",
"scope_alias": "public-gateway",
"label": "公開入口 / Nginx 變更 freeze 與 source-to-live diff",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "public_ingress_gateway",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:ssh_sudo_access_lockdown",
"scope_alias": "ssh-sudo-access",
"label": "SSH / sudo / authorized_keys / known_hosts 存取收斂",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "ssh_sudo_access",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": True,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:firewall_port_baseline_guard",
"scope_alias": "firewall-port-baseline",
"label": "端口 / 防火牆 / WireGuard / NodePort baseline",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "firewall_network_policy",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": True,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:host_service_persistence_baseline",
"scope_alias": "host-service-persistence",
"label": "Docker / systemd / process / persistence baseline",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "host_runtime_services",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": True,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:k8s_argocd_drift_containment",
"scope_alias": "k8s-argocd-drift",
"label": "K8s / ArgoCD drift、RBAC 與 Secret metadata containment",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "k8s_gitops_runtime",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:runner_workflow_secret_freeze",
"scope_alias": "runner-workflow-secret-freeze",
"label": "Runner / workflow / deploy key / secret freeze",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "runner_workflow_supply_chain",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": True,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:credential_exposure_rotation_gate",
"scope_alias": "credential-exposure",
"label": "疑似 credential exposure 的輪替決策 gate",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "secret_credential_exposure",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": True,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:wazuh_event_triage_gate",
"scope_alias": "wazuh-event-triage",
"label": "Wazuh event triage 與事件分流 gate",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "wazuh_detection_response",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": False,
},
{
"control_id": "external_host_prevention:wazuh_active_response_dry_run",
"scope_alias": "wazuh-active-response-dry-run",
"label": "Wazuh active response dry-run / blast radius / rollback",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "wazuh_detection_response",
"requires_wazuh_event_refs": True,
"requires_host_forensics_refs": True,
"requires_config_diff_refs": False,
},
{
"control_id": "external_host_prevention:backup_restore_recovery_gate",
"scope_alias": "backup-restore-recovery",
"label": "Backup / restore / rollback 可用性防堵 gate",
"control_tier": "C0",
"priority": "P0",
"prevention_domain": "backup_restore_resilience",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": False,
},
{
"control_id": "external_host_prevention:package_patch_window",
"scope_alias": "package-patch-window",
"label": "套件更新 / CVE 修補維護窗口候選",
"control_tier": "C1",
"priority": "P0",
"prevention_domain": "package_patch_vulnerability",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": False,
},
{
"control_id": "external_host_prevention:public_runtime_auth_route_guard",
"scope_alias": "public-runtime-auth-route",
"label": "公開 / 後台 / API runtime auth 與 route guard",
"control_tier": "C1",
"priority": "P0",
"prevention_domain": "public_ingress_gateway",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": True,
},
{
"control_id": "external_host_prevention:monitoring_no_false_green_gate",
"scope_alias": "monitoring-no-false-green",
"label": "監控 / 告警 / route 200 no-false-green gate",
"control_tier": "C1",
"priority": "P0",
"prevention_domain": "monitoring_alerting_false_green",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": False,
},
{
"control_id": "external_host_prevention:cross_project_break_glass_sync",
"scope_alias": "cross-project-break-glass-sync",
"label": "跨專案 freeze、break-glass 與 operator sync",
"control_tier": "C1",
"priority": "P0",
"prevention_domain": "cross_project_freeze_sync",
"requires_wazuh_event_refs": False,
"requires_host_forensics_refs": False,
"requires_config_diff_refs": False,
},
]
EXECUTION_BOUNDARIES = {
"runtime_execution_authorized": False,
"host_read_authorized": False,
"host_write_authorized": False,
"ssh_read_authorized": False,
"ssh_write_authorized": False,
"sudo_action_authorized": False,
"host_live_config_read_authorized": False,
"firewall_change_authorized": False,
"port_close_authorized": False,
"port_open_authorized": False,
"nginx_test_authorized": False,
"nginx_reload_authorized": False,
"dns_tls_change_authorized": False,
"certbot_renew_authorized": False,
"docker_restart_authorized": False,
"systemctl_restart_authorized": False,
"process_kill_authorized": False,
"host_isolation_authorized": False,
"package_upgrade_authorized": False,
"reboot_authorized": False,
"wazuh_api_live_query_authorized": False,
"wazuh_active_response_authorized": False,
"wazuh_rule_change_authorized": False,
"argocd_sync_authorized": False,
"kubectl_action_authorized": False,
"workflow_modification_authorized": False,
"runner_change_authorized": False,
"repo_secret_change_authorized": False,
"secret_rotation_authorized": False,
"secret_value_collection_allowed": False,
"raw_payload_storage_allowed": False,
"active_scan_authorized": False,
"backup_run_authorized": False,
"restore_run_authorized": False,
"production_write_authorized": False,
"action_buttons_allowed": False,
"frontend_internal_transcript_display_allowed": False,
"not_authorization": True,
}
def git_short_sha(root: Path) -> str:
try:
result = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=root,
check=True,
capture_output=True,
text=True,
)
return result.stdout.strip()
except Exception:
return "unknown"
def build_candidate(source: dict[str, Any]) -> dict[str, Any]:
return {
**source,
"status": "waiting_owner_prevention_packet",
"host_aliases": HOST_ALIASES,
"sensor_aliases": SENSOR_ALIASES,
"requires_owner_approval": True,
"requires_maintenance_window": True,
"requires_break_glass_record": source["control_tier"] == "C0",
"requires_cross_project_sync": True,
"requires_rollback_plan": True,
"requires_validation_plan": True,
"owner_role": "pending_owner_response",
"owner_team": "pending_owner_response",
"maintenance_window": "pending_owner_response",
"rollback_owner": "pending_owner_response",
"followup_owner": "pending_owner_response",
"redacted_evidence_refs": [],
"wazuh_event_refs": [],
"host_forensic_refs": [],
"config_diff_refs": [],
"validation_metric_refs": [],
"postcheck_ref": None,
"cross_project_sync_ref": None,
"reviewer_outcome": "waiting_prevention_reviewer_review",
"runtime_gate": False,
"action_buttons_allowed": False,
"not_authorization": True,
"blocked_actions": BLOCKED_ACTIONS,
"required_owner_fields": REQUIRED_OWNER_FIELDS,
"reviewer_checks": [item["check_id"] for item in REVIEWER_CHECKS],
"outcome_lanes": [item["lane_id"] for item in OUTCOME_LANES],
}
def count_if(candidates: list[dict[str, Any]], key: str) -> int:
return sum(1 for item in candidates if item[key])
def build_report(root: Path, generated_at: str | None) -> dict[str, Any]:
report_time = generated_at or datetime.now(TAIPEI).isoformat(timespec="seconds")
candidates = [build_candidate(item) for item in CONTROL_CANDIDATES]
return {
"schema_version": "external_host_intrusion_prevention_control_v1",
"generated_at": report_time,
"git_commit": git_short_sha(root),
"status": "external_host_intrusion_prevention_control_ready_no_runtime_action",
"mode": "control_matrix_only_no_host_write_no_firewall_change_no_active_response",
"source_context": {
"host_aliases": HOST_ALIASES,
"sensor_aliases": SENSOR_ALIASES,
"raw_ip_or_account_namespace_published_to_frontend": False,
"work_session_transcript_published_to_frontend": False,
"external_agent_claim_accepted_without_evidence": False,
"runtime_prevention_enabled": False,
},
"summary": {
"prevention_domain_count": len(PREVENTION_DOMAINS),
"host_alias_count": len(HOST_ALIASES),
"sensor_alias_count": len(SENSOR_ALIASES),
"control_candidate_count": len(candidates),
"c0_control_candidate_count": sum(1 for item in candidates if item["control_tier"] == "C0"),
"c1_control_candidate_count": sum(1 for item in candidates if item["control_tier"] == "C1"),
"p0_control_candidate_count": sum(1 for item in candidates if item["priority"] == "P0"),
"urgent_prevention_candidate_count": len(candidates),
"maintenance_window_required_candidate_count": count_if(candidates, "requires_maintenance_window"),
"break_glass_required_candidate_count": count_if(candidates, "requires_break_glass_record"),
"owner_approval_required_candidate_count": count_if(candidates, "requires_owner_approval"),
"cross_project_sync_required_candidate_count": count_if(candidates, "requires_cross_project_sync"),
"rollback_required_candidate_count": count_if(candidates, "requires_rollback_plan"),
"validation_required_candidate_count": count_if(candidates, "requires_validation_plan"),
"wazuh_event_required_candidate_count": count_if(candidates, "requires_wazuh_event_refs"),
"host_forensics_required_candidate_count": count_if(candidates, "requires_host_forensics_refs"),
"config_diff_required_candidate_count": count_if(candidates, "requires_config_diff_refs"),
"backup_restore_required_candidate_count": sum(1 for item in candidates if item["prevention_domain"] == "backup_restore_resilience"),
"no_false_green_required_candidate_count": len(candidates),
"required_owner_field_count": len(REQUIRED_OWNER_FIELDS),
"reviewer_check_count": len(REVIEWER_CHECKS),
"outcome_lane_count": len(OUTCOME_LANES),
"blocked_action_count": len(BLOCKED_ACTIONS),
"coverage_percent_after_prevention_control": 74,
"docker_compose_systemd_host_config_coverage_percent_after_prevention_control": 68,
"ssh_firewall_network_access_coverage_percent_after_prevention_control": 70,
"monitoring_alerting_observability_coverage_percent_after_prevention_control": 74,
"owner_response_received_count": 0,
"owner_response_accepted_count": 0,
"evidence_ref_received_count": 0,
"evidence_ref_accepted_count": 0,
"prevention_control_accepted_count": 0,
"containment_decision_accepted_count": 0,
"maintenance_window_accepted_count": 0,
"rollback_plan_accepted_count": 0,
"postcheck_accepted_count": 0,
"wazuh_active_response_enabled_count": 0,
"host_write_authorized_count": 0,
"ssh_write_authorized_count": 0,
"firewall_change_authorized_count": 0,
"nginx_reload_authorized_count": 0,
"docker_restart_authorized_count": 0,
"systemctl_restart_authorized_count": 0,
"argocd_sync_authorized_count": 0,
"workflow_modification_authorized_count": 0,
"runner_change_authorized_count": 0,
"repo_secret_change_authorized_count": 0,
"secret_value_collection_allowed_count": 0,
"active_scan_authorized_count": 0,
"package_upgrade_authorized_count": 0,
"production_write_authorized_count": 0,
"runtime_gate_count": 0,
"action_button_count": 0,
},
"execution_boundaries": EXECUTION_BOUNDARIES,
"prevention_domains": PREVENTION_DOMAINS,
"control_candidates": candidates,
"required_owner_fields": REQUIRED_OWNER_FIELDS,
"reviewer_checks": REVIEWER_CHECKS,
"outcome_lanes": OUTCOME_LANES,
"blocked_actions": BLOCKED_ACTIONS,
"operator_interpretation": [
"這份矩陣把外部入侵防堵前移成 P0 控制候選,但不是 host write 或 firewall change 授權。",
"IwoooS 先拒收假綠燈route 200、dashboard up、CD success、UI 可見、agent active 或外部 Agent 宣稱都不能單獨當成已防堵。",
"真正能進 runtime 的防堵需 owner role / team、decision reason、維護窗口、rollback owner、validation metrics、postcheck 與跨專案同步。",
"前台只能顯示 alias、候選數、缺口與 0/false 邊界,不顯示內網 IP、帳號 namespace、raw log、secret 或工作視窗內容。",
],
}
def main() -> int:
parser = argparse.ArgumentParser(description="IwoooS 外部入侵主機防堵控制矩陣")
parser.add_argument("--root", default=".", help="repo root")
parser.add_argument("--output", help="寫出 JSON 報告")
parser.add_argument("--generated-at", help="固定報告時間,供 committed snapshot 使用")
args = parser.parse_args()
root = Path(args.root).resolve()
report = build_report(root, args.generated_at)
payload = json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True)
if args.output:
output = Path(args.output)
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(payload + "\n", encoding="utf-8")
else:
print(payload)
summary = report["summary"]
print(
"EXTERNAL_HOST_INTRUSION_PREVENTION_CONTROL_OK "
f"domains={summary['prevention_domain_count']} "
f"candidates={summary['control_candidate_count']} "
f"hosts={summary['host_alias_count']} "
f"checks={summary['reviewer_check_count']} "
f"blocked={summary['blocked_action_count']} "
f"runtime_gate={summary['runtime_gate_count']}",
file=sys.stderr,
)
return 0
if __name__ == "__main__":
sys.exit(main())

View File

@@ -151,8 +151,8 @@ CONTROL_STATUS_BY_CATEGORY = {
"next_owner_action": "補 repo owner、external agent owner、treasury owner、runtime gate owner、maintenance window、rollback owner 與 validation plan。",
},
"monitoring_alerting_observability": {
"coverage_status": "wazuh_intrusion_readback_plan_ready_needs_wazuh_owner_evidence",
"coverage_percent": 72,
"coverage_status": "external_host_intrusion_prevention_control_ready_needs_wazuh_owner_evidence",
"coverage_percent": 74,
"evidence_refs": [
"docs/security/IWOOOS-CONFIG-CONTROL-INVENTORY.md",
"docs/security/MONITORING-ALERTING-OBSERVABILITY-INVENTORY.md",
@@ -166,15 +166,18 @@ CONTROL_STATUS_BY_CATEGORY = {
"docs/security/WAZUH-IWOOOS-INTRUSION-READBACK-PLAN.md",
"docs/security/wazuh-iwooos-intrusion-readback-plan.snapshot.json",
"scripts/security/wazuh-iwooos-intrusion-readback-plan.py",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
"apps/web/src/app/api/iwooos/wazuh/route.ts",
"docs/schemas/monitoring_alerting_observability_inventory_v1.schema.json",
],
"current_gap": "已固定 60 份 monitoring / alerting / observability owner response acceptance candidate、事故後回讀計畫,並新增 Wazuh / 主機入侵 readback planWazuh 平台、host-110 / host-188 入侵訊號、外部 Agent live 變更宣稱、Runner / secret / gateway 連動、containment / recovery proof、hardcoded credential 拒收與 active response 邊界已納入;仍缺 Wazuh manager health ref、agent status ref、Wazuh event refs、host forensic refs、containment decision、recovery proof、postcheck、recurrence guard、owner response 與 maintenance window。",
"next_owner_action": "補 Wazuh / 主機入侵事故回讀manager / indexer / dashboard / API health ref、host-110 / host-188 agent status ref、event / alert refs、auth log、process tree、network connection、FIM、package inventory、persistence refs、actor attribution、incident time window、affected scope、containment decision、recovery proof、independent postcheck、recurrence guard、cross-project sync、rollback owner、followup owner 與 no-secret / no-raw-payload / no-false-green attestation。",
"current_gap": "已固定 60 份 monitoring / alerting / observability owner response acceptance candidate、事故後回讀計畫Wazuh / 主機入侵 readback plan並新增外部入侵主機防堵控制矩陣Wazuh 平台、host alias 入侵訊號、外部 Agent live 變更宣稱、Runner / secret / gateway 連動、active response dry-run、防再發與 no-false-green 已納入;仍缺 Wazuh manager health ref、agent status ref、Wazuh event refs、host forensic refs、containment decision、recovery proof、postcheck、recurrence guard、owner response 與 maintenance window。",
"next_owner_action": "補 Wazuh / 主機入侵防堵manager / indexer / dashboard / API health ref、host alias agent status ref、event / alert refs、auth log、process tree、network connection、FIM、package inventory、persistence refs、actor attribution、incident time window、affected scope、containment decision、active response dry-run blast radius、recovery proof、independent postcheck、recurrence guard、cross-project sync、rollback owner、followup owner 與 no-secret / no-raw-payload / no-false-green attestation。",
},
"docker_compose_systemd_host_config": {
"coverage_status": "post_incident_readback_plan_ready_needs_host_service_owner_evidence",
"coverage_percent": 64,
"coverage_status": "external_host_intrusion_prevention_control_ready_needs_host_service_owner_evidence",
"coverage_percent": 68,
"evidence_refs": [
"docs/security/IWOOOS-CONFIG-CONTROL-INVENTORY.md",
"docs/security/HOST-SERVICE-CONFIG-INVENTORY.md",
@@ -187,14 +190,17 @@ CONTROL_STATUS_BY_CATEGORY = {
"docs/security/host-service-change-evidence-acceptance.snapshot.json",
"docs/security/HOST-SERVICE-POST-INCIDENT-READBACK-PLAN.md",
"docs/security/host-service-post-incident-readback-plan.snapshot.json",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
"docs/security/DEV-HOSTS-112-111-168-OBSERVE-ONLY-MAPPING.md",
],
"current_gap": "已固定 9 份 Docker / systemd / host service owner response acceptance candidate、change evidence acceptancepost-incident readback plan重啟 actor、boot / recovery window、before / after state、Docker daemon、compose / systemd state、failed unit、port binding、dependency、public/admin route recovery、AI provider health、monitoring alert、operator notice、cross-project sync、restoration、recurrence guard 與 no-false-green 皆已納入只讀帳本;仍缺 owner response、live hash、事故回讀包、maintenance / restart window、rollback owner、post-check plan、disable switch 與 no-secret-value evidence。",
"next_owner_action": "補 host service 事故回讀owner-provided live hash / disposition、change / incident ref、actor role / team、boot time、restart / recovery window、before / after state、Docker daemon state、compose / systemd state、failed unit review、port binding、服務依賴圖、public/admin route recovery、AI provider health、monitoring alert、operator notification、cross-project sync、restoration evidence、recurrence guard、rollback owner、post-check plan 與 no-secret-value evidence。",
"current_gap": "已固定 9 份 Docker / systemd / host service owner response acceptance candidate、change evidence acceptancepost-incident readback plan 與外部入侵防堵控制矩陣;重啟 actor、boot / recovery window、before / after state、Docker daemon、compose / systemd state、failed unit、port binding、dependency、process / persistence baseline、public/admin route recovery、AI provider health、monitoring alert、operator notice、cross-project sync、restoration、recurrence guard 與 no-false-green 皆已納入;仍缺 owner response、live hash、Wazuh / host forensic refs、maintenance / restart window、rollback owner、post-check plan、disable switch 與 no-secret-value evidence。",
"next_owner_action": "補 host service 防堵owner-provided live hash / disposition、change / incident ref、actor role / team、boot time、restart / recovery window、before / after state、Docker daemon state、compose / systemd state、failed unit review、port binding、process / persistence refs、服務依賴圖、public/admin route recovery、AI provider health、monitoring alert、operator notification、cross-project sync、restoration evidence、recurrence guard、rollback owner、post-check plan 與 no-secret-value evidence。",
},
"ssh_firewall_network_access": {
"coverage_status": "post_incident_readback_plan_ready_needs_network_owner_evidence",
"coverage_percent": 64,
"coverage_status": "external_host_intrusion_prevention_control_ready_needs_network_owner_evidence",
"coverage_percent": 70,
"evidence_refs": [
"docs/HARD_RULES.md",
"docs/security/IWOOOS-CONFIG-CONTROL-INVENTORY.md",
@@ -208,9 +214,12 @@ CONTROL_STATUS_BY_CATEGORY = {
"docs/security/port-firewall-change-evidence-acceptance.snapshot.json",
"docs/security/SSH-NETWORK-POST-INCIDENT-READBACK-PLAN.md",
"docs/security/ssh-network-post-incident-readback-plan.snapshot.json",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
],
"current_gap": "owner response acceptance、端口 / 防火牆事故型變更證據驗收post-incident readback plan 都已固定;仍缺 owner-provided change / incident evidence、actor、before / after state、service / AI provider / monitoring impact、operator notification、cross-project sync、restoration evidence、recurrence guard、maintenance window、rollback owner 與 post-check evidence。",
"next_owner_action": "補端口 / 防火牆事故回讀change / incident ref、actor role / team、affected scope、before / after state、service dependency、public route impact、AI provider impact、monitoring alert impact、operator notification、cross-project sync、restoration evidence、recurrence guard、rollback owner 與 post-check 指標。",
"current_gap": "owner response acceptance、端口 / 防火牆事故型變更證據驗收post-incident readback plan 與外部入侵防堵控制矩陣都已固定SSH / sudo、authorized_keys、known_hosts、firewall、WireGuard、NodePort、NetworkPolicy、port close / open 與 break-glass 邊界已納入;仍缺 owner-provided change / incident evidence、actor、before / after state、Wazuh / host forensic refs、service / AI provider / monitoring impact、operator notification、cross-project sync、restoration evidence、recurrence guard、maintenance window、rollback owner 與 post-check evidence。",
"next_owner_action": " SSH / 端口 / 防火牆防堵change / incident ref、actor role / team、affected scope、before / after state、service dependency、public route impact、AI provider impact、monitoring alert impact、operator notification、cross-project sync、restoration evidence、recurrence guard、maintenance window、rollback owner 與 post-check 指標。",
},
"ai_provider_model_routing": {
"coverage_status": "owner_response_acceptance_ready_needs_provider_owner_evidence",
@@ -414,14 +423,17 @@ def build_report(root: Path, generated_at: str | None) -> dict[str, Any]:
"alert_chain_no_false_green_backfill_ready_needs_live_evidence_receipt",
"post_incident_readback_plan_ready_needs_monitoring_owner_evidence",
"wazuh_intrusion_readback_plan_ready_needs_wazuh_owner_evidence",
"external_host_intrusion_prevention_control_ready_needs_wazuh_owner_evidence",
"change_evidence_acceptance_ready_needs_network_owner_evidence",
"incident_change_evidence_acceptance_ready_needs_network_owner_evidence",
"post_incident_readback_plan_ready_needs_network_owner_evidence",
"external_host_intrusion_prevention_control_ready_needs_network_owner_evidence",
"policy_ready_needs_drift_evidence",
"inventory_needed",
"repo_only_inventory_ready_needs_live_owner_evidence",
"incident_recovery_backfill_ready_needs_live_owner_evidence",
"change_evidence_acceptance_ready_needs_host_service_owner_evidence",
"external_host_intrusion_prevention_control_ready_needs_host_service_owner_evidence",
"policy_ready_needs_network_matrix",
"policy_ready_needs_dry_run_pack",
"owner_response_acceptance_ready_needs_provider_owner_evidence",
@@ -471,11 +483,11 @@ def build_report(root: Path, generated_at: str | None) -> dict[str, Any]:
"secret_metadata",
"gitea_workflow_runner_source_control",
"public_admin_api_runtime_config",
"agent_bounty_protocol_runtime",
"docker_compose_systemd_host_config",
"ssh_firewall_network_access",
"ai_provider_model_routing",
"docker_compose_systemd_host_config",
"monitoring_alerting_observability",
"agent_bounty_protocol_runtime",
"ai_provider_model_routing",
"backup_restore_credential",
],
"operator_interpretation": [

View File

@@ -25,9 +25,9 @@ EXPECTED_CATEGORIES = {
"public_admin_api_runtime_config": 66,
"backup_restore_credential": 66,
"agent_bounty_protocol_runtime": 68,
"monitoring_alerting_observability": 70,
"docker_compose_systemd_host_config": 64,
"ssh_firewall_network_access": 64,
"monitoring_alerting_observability": 74,
"docker_compose_systemd_host_config": 68,
"ssh_firewall_network_access": 70,
"ai_provider_model_routing": 64,
"product_surface_runtime_routes": 72,
"security_evidence_tooling": 86,
@@ -69,6 +69,7 @@ REQUIRED_CONTROL_DOCS = [
"docs/security/MONITORING-OWNER-REQUEST-DRAFT.md",
"docs/security/MONITORING-POST-INCIDENT-READBACK-PLAN.md",
"docs/security/WAZUH-IWOOOS-INTRUSION-READBACK-PLAN.md",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/AI-PROVIDER-OWNER-RESPONSE-ACCEPTANCE.md",
"docs/security/AGENT-BOUNTY-OWNER-REQUEST-DRAFT.md",
"docs/security/SECURITY-SUPPLY-CHAIN-CONTRACT-MANIFEST.md",
@@ -858,6 +859,75 @@ ARTIFACT_SPECS = [
"coverage_percent_after_readback_plan": 72,
},
},
{
"label": "external host intrusion prevention control",
"path": "docs/security/external-host-intrusion-prevention-control.snapshot.json",
"schema": "external_host_intrusion_prevention_control_v1",
"status": "external_host_intrusion_prevention_control_ready_no_runtime_action",
"list_counts": {
"prevention_domains": 12,
"control_candidates": 14,
"blocked_actions": 82,
"reviewer_checks": 34,
"outcome_lanes": 12,
"required_owner_fields": 36,
},
"summary_counts": {
"prevention_domain_count": 12,
"host_alias_count": 4,
"sensor_alias_count": 1,
"control_candidate_count": 14,
"c0_control_candidate_count": 10,
"c1_control_candidate_count": 4,
"p0_control_candidate_count": 14,
"urgent_prevention_candidate_count": 14,
"maintenance_window_required_candidate_count": 14,
"break_glass_required_candidate_count": 10,
"owner_approval_required_candidate_count": 14,
"cross_project_sync_required_candidate_count": 14,
"rollback_required_candidate_count": 14,
"validation_required_candidate_count": 14,
"wazuh_event_required_candidate_count": 7,
"host_forensics_required_candidate_count": 6,
"config_diff_required_candidate_count": 8,
"backup_restore_required_candidate_count": 1,
"no_false_green_required_candidate_count": 14,
"required_owner_field_count": 36,
"reviewer_check_count": 34,
"outcome_lane_count": 12,
"blocked_action_count": 82,
"coverage_percent_after_prevention_control": 74,
"docker_compose_systemd_host_config_coverage_percent_after_prevention_control": 68,
"ssh_firewall_network_access_coverage_percent_after_prevention_control": 70,
"monitoring_alerting_observability_coverage_percent_after_prevention_control": 74,
"owner_response_received_count": 0,
"owner_response_accepted_count": 0,
"evidence_ref_received_count": 0,
"evidence_ref_accepted_count": 0,
"prevention_control_accepted_count": 0,
"containment_decision_accepted_count": 0,
"maintenance_window_accepted_count": 0,
"rollback_plan_accepted_count": 0,
"postcheck_accepted_count": 0,
"wazuh_active_response_enabled_count": 0,
"host_write_authorized_count": 0,
"ssh_write_authorized_count": 0,
"firewall_change_authorized_count": 0,
"nginx_reload_authorized_count": 0,
"docker_restart_authorized_count": 0,
"systemctl_restart_authorized_count": 0,
"argocd_sync_authorized_count": 0,
"workflow_modification_authorized_count": 0,
"runner_change_authorized_count": 0,
"repo_secret_change_authorized_count": 0,
"secret_value_collection_allowed_count": 0,
"active_scan_authorized_count": 0,
"package_upgrade_authorized_count": 0,
"production_write_authorized_count": 0,
"runtime_gate_count": 0,
"action_button_count": 0,
},
},
{
"label": "ai provider owner response acceptance",
"path": "docs/security/ai-provider-owner-response-acceptance.snapshot.json",

View File

@@ -191,6 +191,9 @@ def validate(root: Path) -> None:
monitoring_post_incident_readback_plan = load_json(
security_dir / "monitoring-post-incident-readback-plan.snapshot.json"
)
external_host_intrusion_prevention_control = load_json(
security_dir / "external-host-intrusion-prevention-control.snapshot.json"
)
ai_provider_owner_response_acceptance = load_json(
security_dir / "ai-provider-owner-response-acceptance.snapshot.json"
)
@@ -2779,7 +2782,7 @@ def validate(root: Path) -> None:
assert_equal(
"high_value_config_coverage.summary.needs_live_evidence_count",
high_value_config_coverage["summary"]["needs_live_evidence_count"],
9,
10,
)
for key in [
"owner_response_received_count",
@@ -3191,11 +3194,6 @@ def validate(root: Path) -> None:
public_runtime_config_category["evidence_refs"],
evidence_ref,
)
assert_contains(
"high_value_config_coverage.lowest_coverage_categories.docker",
[item["category_id"] for item in high_value_config_coverage["lowest_coverage_categories"]],
"docker_compose_systemd_host_config",
)
docker_systemd_category = next(
item
for item in high_value_config_coverage["coverage_categories"]
@@ -3204,12 +3202,12 @@ def validate(root: Path) -> None:
assert_equal(
"high_value_config_coverage.coverage_categories.docker.coverage_percent",
docker_systemd_category["coverage_percent"],
64,
68,
)
assert_equal(
"high_value_config_coverage.coverage_categories.docker.coverage_status",
docker_systemd_category["coverage_status"],
"post_incident_readback_plan_ready_needs_host_service_owner_evidence",
"external_host_intrusion_prevention_control_ready_needs_host_service_owner_evidence",
)
for evidence_ref in [
"docs/security/HOST-SERVICE-CONFIG-INVENTORY.md",
@@ -3222,6 +3220,9 @@ def validate(root: Path) -> None:
"docs/security/host-service-change-evidence-acceptance.snapshot.json",
"docs/security/HOST-SERVICE-POST-INCIDENT-READBACK-PLAN.md",
"docs/security/host-service-post-incident-readback-plan.snapshot.json",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
]:
assert_contains(
"high_value_config_coverage.coverage_categories.docker.evidence_refs",
@@ -3236,12 +3237,12 @@ def validate(root: Path) -> None:
assert_equal(
"high_value_config_coverage.coverage_categories.ssh_network.coverage_percent",
ssh_network_category["coverage_percent"],
64,
70,
)
assert_equal(
"high_value_config_coverage.coverage_categories.ssh_network.coverage_status",
ssh_network_category["coverage_status"],
"post_incident_readback_plan_ready_needs_network_owner_evidence",
"external_host_intrusion_prevention_control_ready_needs_network_owner_evidence",
)
for evidence_ref in [
"docs/security/SSH-NETWORK-ACCESS-INVENTORY.md",
@@ -3252,6 +3253,9 @@ def validate(root: Path) -> None:
"docs/security/port-firewall-change-evidence-acceptance.snapshot.json",
"docs/security/SSH-NETWORK-POST-INCIDENT-READBACK-PLAN.md",
"docs/security/ssh-network-post-incident-readback-plan.snapshot.json",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
]:
assert_contains(
"high_value_config_coverage.coverage_categories.ssh_network.evidence_refs",
@@ -3321,12 +3325,12 @@ def validate(root: Path) -> None:
assert_equal(
"high_value_config_coverage.coverage_categories.monitoring.coverage_percent",
monitoring_category["coverage_percent"],
72,
74,
)
assert_equal(
"high_value_config_coverage.coverage_categories.monitoring.coverage_status",
monitoring_category["coverage_status"],
"wazuh_intrusion_readback_plan_ready_needs_wazuh_owner_evidence",
"external_host_intrusion_prevention_control_ready_needs_wazuh_owner_evidence",
)
for evidence_ref in [
"docs/security/MONITORING-ALERTING-OBSERVABILITY-INVENTORY.md",
@@ -3340,6 +3344,9 @@ def validate(root: Path) -> None:
"docs/security/WAZUH-IWOOOS-INTRUSION-READBACK-PLAN.md",
"docs/security/wazuh-iwooos-intrusion-readback-plan.snapshot.json",
"scripts/security/wazuh-iwooos-intrusion-readback-plan.py",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
"apps/web/src/app/api/iwooos/wazuh/route.ts",
"docs/schemas/monitoring_alerting_observability_inventory_v1.schema.json",
]:
@@ -3348,6 +3355,107 @@ def validate(root: Path) -> None:
monitoring_category["evidence_refs"],
evidence_ref,
)
assert_equal(
"external_host_intrusion_prevention_control.schema",
external_host_intrusion_prevention_control["schema_version"],
"external_host_intrusion_prevention_control_v1",
)
assert_equal(
"external_host_intrusion_prevention_control.status",
external_host_intrusion_prevention_control["status"],
"external_host_intrusion_prevention_control_ready_no_runtime_action",
)
assert_equal(
"external_host_intrusion_prevention_control.prevention_domains.count",
len(external_host_intrusion_prevention_control["prevention_domains"]),
12,
)
assert_equal(
"external_host_intrusion_prevention_control.control_candidates.count",
len(external_host_intrusion_prevention_control["control_candidates"]),
14,
)
assert_equal(
"external_host_intrusion_prevention_control.reviewer_checks.count",
len(external_host_intrusion_prevention_control["reviewer_checks"]),
34,
)
assert_equal(
"external_host_intrusion_prevention_control.outcome_lanes.count",
len(external_host_intrusion_prevention_control["outcome_lanes"]),
12,
)
assert_equal(
"external_host_intrusion_prevention_control.blocked_actions.count",
len(external_host_intrusion_prevention_control["blocked_actions"]),
82,
)
expected_external_host_intrusion_prevention_summary = {
"prevention_domain_count": 12,
"host_alias_count": 4,
"sensor_alias_count": 1,
"control_candidate_count": 14,
"c0_control_candidate_count": 10,
"c1_control_candidate_count": 4,
"p0_control_candidate_count": 14,
"urgent_prevention_candidate_count": 14,
"maintenance_window_required_candidate_count": 14,
"break_glass_required_candidate_count": 10,
"owner_approval_required_candidate_count": 14,
"cross_project_sync_required_candidate_count": 14,
"rollback_required_candidate_count": 14,
"validation_required_candidate_count": 14,
"wazuh_event_required_candidate_count": 7,
"host_forensics_required_candidate_count": 6,
"config_diff_required_candidate_count": 8,
"backup_restore_required_candidate_count": 1,
"no_false_green_required_candidate_count": 14,
"required_owner_field_count": 36,
"reviewer_check_count": 34,
"outcome_lane_count": 12,
"blocked_action_count": 82,
"coverage_percent_after_prevention_control": 74,
"docker_compose_systemd_host_config_coverage_percent_after_prevention_control": 68,
"ssh_firewall_network_access_coverage_percent_after_prevention_control": 70,
"monitoring_alerting_observability_coverage_percent_after_prevention_control": 74,
"owner_response_received_count": 0,
"owner_response_accepted_count": 0,
"evidence_ref_received_count": 0,
"evidence_ref_accepted_count": 0,
"prevention_control_accepted_count": 0,
"containment_decision_accepted_count": 0,
"maintenance_window_accepted_count": 0,
"rollback_plan_accepted_count": 0,
"postcheck_accepted_count": 0,
"wazuh_active_response_enabled_count": 0,
"host_write_authorized_count": 0,
"ssh_write_authorized_count": 0,
"firewall_change_authorized_count": 0,
"nginx_reload_authorized_count": 0,
"docker_restart_authorized_count": 0,
"systemctl_restart_authorized_count": 0,
"argocd_sync_authorized_count": 0,
"workflow_modification_authorized_count": 0,
"runner_change_authorized_count": 0,
"repo_secret_change_authorized_count": 0,
"secret_value_collection_allowed_count": 0,
"active_scan_authorized_count": 0,
"package_upgrade_authorized_count": 0,
"production_write_authorized_count": 0,
"runtime_gate_count": 0,
"action_button_count": 0,
}
for key, expected in expected_external_host_intrusion_prevention_summary.items():
assert_equal(
f"external_host_intrusion_prevention_control.summary.{key}",
external_host_intrusion_prevention_control["summary"][key],
expected,
)
for key, value in external_host_intrusion_prevention_control["execution_boundaries"].items():
if key == "not_authorization":
assert_true(f"external_host_intrusion_prevention_control.execution_boundaries.{key}", value)
else:
assert_false(f"external_host_intrusion_prevention_control.execution_boundaries.{key}", value)
assert_equal(
"host_service_config_inventory.schema",
host_service_config_inventory["schema_version"],
@@ -7940,6 +8048,9 @@ def validate(root: Path) -> None:
"docs/security/WAZUH-IWOOOS-INTRUSION-READBACK-PLAN.md",
"docs/security/wazuh-iwooos-intrusion-readback-plan.snapshot.json",
"scripts/security/wazuh-iwooos-intrusion-readback-plan.py",
"docs/security/EXTERNAL-HOST-INTRUSION-PREVENTION-CONTROL.md",
"docs/security/external-host-intrusion-prevention-control.snapshot.json",
"scripts/security/external-host-intrusion-prevention-control.py",
"apps/web/src/app/api/iwooos/wazuh/route.ts",
"docs/schemas/monitoring_alerting_observability_inventory_v1.schema.json",
"docs/security/public-runtime-config-change-evidence-acceptance.snapshot.json",
@@ -7970,7 +8081,7 @@ def validate(root: Path) -> None:
"high_value_config_control_coverage_c0_category_count": 8,
"high_value_config_control_coverage_c1_category_count": 4,
"high_value_config_control_coverage_average_percent": 72,
"high_value_config_control_coverage_needs_live_evidence_count": 9,
"high_value_config_control_coverage_needs_live_evidence_count": 10,
"high_value_config_control_coverage_owner_response_required_count": 14,
"high_value_config_control_coverage_owner_response_received_count": 0,
"high_value_config_control_coverage_owner_response_accepted_count": 0,
@@ -7985,6 +8096,15 @@ def validate(root: Path) -> None:
"public_frontend_sensitive_surface_guard_runtime_gate_count": 0,
"k8s_production_gitops_coverage_percent": 66,
"ai_provider_model_routing_coverage_percent": 64,
"docker_compose_systemd_host_config_coverage_percent": 68,
"ssh_firewall_network_access_coverage_percent": 70,
"monitoring_alerting_observability_coverage_percent": 74,
"external_host_intrusion_prevention_control_candidate_count": 14,
"external_host_intrusion_prevention_control_c0_candidate_count": 10,
"external_host_intrusion_prevention_control_required_owner_field_count": 36,
"external_host_intrusion_prevention_control_reviewer_check_count": 34,
"external_host_intrusion_prevention_control_blocked_action_count": 82,
"external_host_intrusion_prevention_control_runtime_gate_count": 0,
}
for key, expected in expected_high_value_config_coverage_summary.items():
assert_equal(
@@ -8100,7 +8220,7 @@ def validate(root: Path) -> None:
"host_service_post_incident_readback_plan_runtime_gate_count": 0,
"host_service_post_incident_readback_plan_action_button_count": 0,
"host_service_post_incident_readback_plan_coverage_percent_after_readback_plan": 64,
"docker_compose_systemd_host_config_coverage_percent": 64,
"docker_compose_systemd_host_config_coverage_percent": 68,
}
for key, expected in expected_host_service_projection_summary.items():
assert_equal(
@@ -13648,6 +13768,8 @@ def validate(root: Path) -> None:
"display_vibework_security_onboarding",
"display_agent_bounty_security_onboarding",
"display_rollout_risk_read_only",
"display_wazuh_intrusion_readback",
"display_external_host_intrusion_prevention_control",
"display_high_value_config_owner_packet",
"display_awooop_high_value_config_owner_packet_read_only",
]:
@@ -18275,6 +18397,119 @@ def validate(root: Path) -> None:
iwooos_projection_page,
text,
)
for key in ["eyebrow", "title", "subtitle", "boundaryTitle", "boundaryIntro"]:
assert_contains(
"web_messages.zh-TW.iwooos.externalHostIntrusionPreventionControl.keys",
list(web_messages_zh["iwooos"]["externalHostIntrusionPreventionControl"].keys()),
key,
)
assert_contains(
"web_messages.en.iwooos.externalHostIntrusionPreventionControl.keys",
list(web_messages_en["iwooos"]["externalHostIntrusionPreventionControl"].keys()),
key,
)
for key in ["domains", "candidates", "hosts", "runtimeGate"]:
assert_contains(
"web_messages.zh-TW.iwooos.externalHostIntrusionPreventionControl.summary",
list(web_messages_zh["iwooos"]["externalHostIntrusionPreventionControl"]["summary"].keys()),
key,
)
assert_contains(
"web_messages.en.iwooos.externalHostIntrusionPreventionControl.summary",
list(web_messages_en["iwooos"]["externalHostIntrusionPreventionControl"]["summary"].keys()),
key,
)
for key in [
"gateway",
"sshFirewall",
"hostRuntime",
"runnerSecret",
"wazuhResponse",
"backupRestore",
"packagePatch",
"sync",
]:
assert_contains(
"web_messages.zh-TW.iwooos.externalHostIntrusionPreventionControl.items",
list(web_messages_zh["iwooos"]["externalHostIntrusionPreventionControl"]["items"].keys()),
key,
)
assert_contains(
"web_messages.en.iwooos.externalHostIntrusionPreventionControl.items",
list(web_messages_en["iwooos"]["externalHostIntrusionPreventionControl"]["items"].keys()),
key,
)
assert_text_contains(
"iwooos_page.external_host_intrusion_prevention_control_testid",
iwooos_projection_page,
'data-testid="iwooos-external-host-intrusion-prevention-control-board"',
)
assert_text_contains(
"iwooos_page.external_host_intrusion_prevention_control_boundary_testid",
iwooos_projection_page,
'data-testid="iwooos-external-host-intrusion-prevention-control-boundaries"',
)
assert_text_before(
"iwooos_page.external_host_intrusion_after_wazuh",
iwooos_projection_page,
"<IwoooSWazuhIntrusionReadbackBoard />",
"<IwoooSExternalHostIntrusionPreventionControlBoard />",
)
assert_text_before(
"iwooos_page.external_host_intrusion_before_config_priority",
iwooos_projection_page,
"<IwoooSExternalHostIntrusionPreventionControlBoard />",
"<IwoooSCriticalConfigPriorityBoard />",
)
for text in [
"external_host_intrusion_prevention_control_visible=true",
"external_host_intrusion_prevention_control_domain_count=12",
"external_host_intrusion_prevention_control_candidate_count=14",
"external_host_intrusion_prevention_control_c0_candidate_count=10",
"external_host_intrusion_prevention_control_c1_candidate_count=4",
"external_host_intrusion_prevention_control_p0_candidate_count=14",
"external_host_intrusion_prevention_control_host_alias_count=4",
"external_host_intrusion_prevention_control_sensor_alias_count=1",
"external_host_intrusion_prevention_control_required_owner_field_count=36",
"external_host_intrusion_prevention_control_reviewer_check_count=34",
"external_host_intrusion_prevention_control_outcome_lane_count=12",
"external_host_intrusion_prevention_control_blocked_action_count=82",
"external_host_intrusion_prevention_control_wazuh_event_required_candidate_count=7",
"external_host_intrusion_prevention_control_host_forensics_required_candidate_count=6",
"external_host_intrusion_prevention_control_config_diff_required_candidate_count=8",
"external_host_intrusion_prevention_control_owner_response_received_count=0",
"external_host_intrusion_prevention_control_owner_response_accepted_count=0",
"external_host_intrusion_prevention_control_evidence_ref_received_count=0",
"external_host_intrusion_prevention_control_evidence_ref_accepted_count=0",
"external_host_intrusion_prevention_control_prevention_control_accepted_count=0",
"external_host_intrusion_prevention_control_wazuh_active_response_enabled_count=0",
"external_host_intrusion_prevention_control_host_write_authorized_count=0",
"external_host_intrusion_prevention_control_firewall_change_authorized_count=0",
"external_host_intrusion_prevention_control_nginx_reload_authorized_count=0",
"external_host_intrusion_prevention_control_package_upgrade_authorized_count=0",
"external_host_intrusion_prevention_control_active_scan_authorized_count=0",
"external_host_intrusion_prevention_control_runtime_gate_count=0",
"external_host_intrusion_prevention_control_action_button_count=0",
"docker_compose_systemd_host_config_coverage_percent=68",
"ssh_firewall_network_access_coverage_percent=70",
"monitoring_alerting_observability_coverage_percent=74",
"host_write_authorized=false",
"ssh_write_authorized=false",
"firewall_change_authorized=false",
"nginx_reload_authorized=false",
"wazuh_active_response_authorized=false",
"package_upgrade_authorized=false",
"active_scan_authorized=false",
"runtime_execution_authorized=false",
"active_runtime_gate_count=0",
"action_buttons_allowed=false",
"not_authorization=true",
]:
assert_text_contains(
"iwooos_page.external_host_intrusion_prevention_control_boundary",
iwooos_projection_page,
text,
)
assert_text_contains(
"iwooos_page.high_value_config_control_coverage_testid",
iwooos_projection_page,
@@ -18293,12 +18528,12 @@ def validate(root: Path) -> None:
assert_text_contains(
"iwooos_page.high_value_config_control_coverage_docker_systemd_percent",
iwooos_projection_page,
"{ key: 'dockerSystemd', rank: 'P1-1', value: '64%'",
"{ key: 'dockerSystemd', rank: 'P1-1', value: '68%'",
)
assert_text_contains(
"iwooos_page.high_value_config_control_coverage_ssh_network_percent",
iwooos_projection_page,
"{ key: 'sshNetwork', rank: 'P1-2', value: '64%'",
"{ key: 'sshNetwork', rank: 'P1-2', value: '70%'",
)
assert_text_contains(
"iwooos_page.high_value_config_control_coverage_ai_provider_percent",
@@ -18323,7 +18558,7 @@ def validate(root: Path) -> None:
"high_value_config_control_coverage_c0_category_count=8",
"high_value_config_control_coverage_c1_category_count=4",
"high_value_config_control_coverage_average_percent=72",
"high_value_config_control_coverage_needs_live_evidence_count=9",
"high_value_config_control_coverage_needs_live_evidence_count=10",
"high_value_config_control_coverage_owner_response_required_count=14",
"high_value_config_control_coverage_owner_response_received_count=0",
"high_value_config_control_coverage_owner_response_accepted_count=0",
@@ -18338,6 +18573,9 @@ def validate(root: Path) -> None:
"secret_metadata_coverage_percent=70",
"gitea_workflow_runner_source_control_coverage_percent=74",
"public_admin_api_runtime_config_coverage_percent=66",
"docker_compose_systemd_host_config_coverage_percent=68",
"ssh_firewall_network_access_coverage_percent=70",
"monitoring_alerting_observability_coverage_percent=74",
"ai_provider_model_routing_coverage_percent=64",
"ai_provider_owner_response_acceptance_candidate_count=8",
"ai_provider_owner_response_acceptance_write_capable_candidate_count=5",
@@ -18603,7 +18841,7 @@ def validate(root: Path) -> None:
"monitoring_alerting_observability_inventory_reload_owner_accepted_count=0",
"monitoring_alerting_observability_inventory_receiver_owner_accepted_count=0",
"monitoring_alerting_observability_inventory_route_smoke_accepted_count=0",
"monitoring_alerting_observability_coverage_percent=72",
"monitoring_alerting_observability_coverage_percent=74",
"monitoring_owner_response_acceptance_reviewer_check_count=23",
"monitoring_owner_response_acceptance_outcome_lane_count=12",
"monitoring_owner_response_acceptance_blocked_action_count=34",
@@ -19106,12 +19344,12 @@ def validate(root: Path) -> None:
assert_text_contains(
"web_messages.zh-TW.iwooos.highValueConfigControlCoverage.items.sshNetwork.body",
web_messages_zh["iwooos"]["highValueConfigControlCoverage"]["items"]["sshNetwork"]["body"],
"14 個事故回讀候選、24 個 reviewer checks、10 條 outcome lanes、34 類 blocked action",
"目前成熟度 70%",
)
assert_text_contains(
"web_messages.en.iwooos.highValueConfigControlCoverage.items.sshNetwork.body",
web_messages_en["iwooos"]["highValueConfigControlCoverage"]["items"]["sshNetwork"]["body"],
"14 個事故回讀候選、24 個 reviewer checks、10 條 outcome lanes、34 類 blocked action",
"目前成熟度 70%",
)
assert_text_contains(
"web_messages.zh-TW.iwooos.highValueConfigControlCoverage.items.backupRestore.body",