From 93fd0f9a715ec754cedcdc6fba717edaea361680 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 15 Jun 2026 04:42:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(awooop):=20=E7=A7=BB=E9=99=A4=20tenants=20p?= =?UTF-8?q?ublic=20api=20=E5=85=A7=E9=83=A8=E6=8E=A7=E5=88=B6=E9=8D=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/services/platform_operator_service.py | 20 +++++-------------- .../test_awooop_tenant_asset_inventory.py | 10 +++++++++- .../security-mirror-progress-guard.py | 11 +++++++++- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/api/src/services/platform_operator_service.py b/apps/api/src/services/platform_operator_service.py index 0df65eb6..9d9eb789 100644 --- a/apps/api/src/services/platform_operator_service.py +++ b/apps/api/src/services/platform_operator_service.py @@ -876,21 +876,11 @@ def build_tenant_asset_inventory(tenants: list[Mapping[str, Any]]) -> dict[str, "public_routes": public_routes, "source_repos": source_repos, "boundaries": [ - "read_only_inventory_only=true", - "repo_owner_namespace_redacted=true", - "public_product_identity_redacted=true", - "raw_repository_namespace_visible=false", - "public_api_raw_repo_namespace_allowed=false", - "public_api_raw_project_slug_allowed=false", - "owner_response_received_count=0", - "owner_response_accepted_count=0", - "runtime_execution_authorized=false", - "active_runtime_gate_count=0", - "action_buttons_allowed=false", - "repo_creation_authorized=false", - "refs_sync_authorized=false", - "workflow_modification_authorized=false", - "public_route_change_authorized=false", + "只讀資產台帳;不修改租戶、路由、主機或專案庫。", + "公開回應只顯示產品代號、範圍代號與繁中管控狀態;不揭露原始負責人、命名空間或完整專案庫名稱。", + "負責人回覆尚未接受;候選範圍不得視為已核准。", + "執行期閘門維持關閉;不啟動掃描、修復、部署或主機操作。", + "未取得正式決策前,不建立專案庫、不同步分支或標籤、不修改工作流程或公開路由。", ], } diff --git a/apps/api/tests/test_awooop_tenant_asset_inventory.py b/apps/api/tests/test_awooop_tenant_asset_inventory.py index 43a04ffa..ff20d6df 100644 --- a/apps/api/tests/test_awooop_tenant_asset_inventory.py +++ b/apps/api/tests/test_awooop_tenant_asset_inventory.py @@ -14,6 +14,12 @@ FORBIDDEN_PUBLIC_MARKERS = [ "AWOOOI / " + "AwoooP / " + "IwoooS", "Tsen" + "Yang Website", "Bitan " + "Pharmacy", + "repo_owner_namespace_redacted=true", + "raw_repository_namespace_visible=false", + "public_api_raw_repo_namespace_allowed=false", + "read_only_inventory_only=true", + "runtime_execution_authorized=false", + "action_buttons_allowed=false", ] @@ -93,6 +99,8 @@ def test_tenant_asset_inventory_merges_products_routes_and_repos() -> None: assert "blocked_waiting_" not in inventory_payload assert "observe_scope_review" not in inventory_payload assert all(marker not in inventory_payload for marker in FORBIDDEN_PUBLIC_MARKERS) + assert "只讀資產台帳" in " ".join(inventory["boundaries"]) + assert all("=" not in boundary for boundary in inventory["boundaries"]) assert {item["risk"] for item in inventory["source_repos"]}.issubset( {"high", "medium", "low", "unknown"} ) @@ -135,5 +143,5 @@ def test_tenant_response_model_keeps_asset_inventory_contract() -> None: response_payload = response.model_dump_json() assert "owenhytsai" not in response_payload assert "nexu-io" not in response_payload - assert all(marker not in response_payload for marker in FORBIDDEN_PUBLIC_MARKERS[:3]) + assert all(marker not in response_payload for marker in FORBIDDEN_PUBLIC_MARKERS) assert response.asset_inventory.source_repos[0].source_namespace_redacted is True diff --git a/scripts/security/security-mirror-progress-guard.py b/scripts/security/security-mirror-progress-guard.py index 6b1731d4..88979548 100755 --- a/scripts/security/security-mirror-progress-guard.py +++ b/scripts/security/security-mirror-progress-guard.py @@ -11858,13 +11858,22 @@ def validate(root: Path) -> None: for text in [ "source_scope_id", "source_namespace_redacted", + "只讀資產台帳;不修改租戶、路由、主機或專案庫。", + "公開回應只顯示產品代號、範圍代號與繁中管控狀態", + "執行期閘門維持關閉", + ]: + assert_text_contains("platform_operator_service.source_namespace_redaction", platform_operator_service, text) + for text in [ "repo_owner_namespace_redacted=true", "raw_repository_namespace_visible=false", "public_api_raw_repo_namespace_allowed=false", "public_product_identity_redacted=true", + "read_only_inventory_only=true", + "runtime_execution_authorized=false", + "action_buttons_allowed=false", "public_api_raw_project_slug_allowed=false", ]: - assert_text_contains("platform_operator_service.source_namespace_redaction", platform_operator_service, text) + assert_text_not_contains("platform_operator_service.raw_boundary_key_leak", platform_operator_service, text) for text in ["source_scope_id", "source_namespace_redacted"]: assert_text_contains("tenants_api_contract.source_namespace_redaction", tenants_api_contract, text) tenant_global_assets_messages_zh = json.dumps(