本卡屬 FR-195(Agent 資安修正),第 1 批 F4。修 FR-186 掃描的 X1 F1、C5 F1、C5 F2(皆 3/3 票),嚴重度:中。
主控台存工具設定時有一條規矩:「祕密要送去哪」的欄位改了,密碼就得重填,免得舊密碼被送到新地方(FR-177 #232)。但程式判斷「哪些欄位算位址」是靠一份欄位名清單(base_url、host、port…),沒列到的就不算。結果改 ssh_port(密碼送到攻擊者開的 port)、換 ca_cert(信任攻擊者的憑證)、關掉 HTTPS 都不用重填密碼。把這幾個確定會改變連線對象的欄位補進清單。
b8b1158 重核過,仍然有效)guidant_agent/scan/app/secret_form.py:21 _ADDRESS_KEYS = frozenset({"base_url", "server_url", "endpoint", "server", "host", "port"});:36-39 pinned_keys 認「欄位標了 pinned」或「鍵名在 _ADDRESS_KEYS 且不是祕密欄」;:148 moved = any(fields.get(k) != base.get(k) for k in pinned_keys(schema))。config.detection_tools.config_field_schema,* 是祕密欄):inspec/gcb:ssh_username ssh_auth_method ssh_private_key* ssh_password* ssh_port ssh_use_sudo winrm_username winrm_password* winrm_port winrm_ssl winrm_self_signed;nmap/openscap:username auth_method private_key* password* ssh_port use_sudo;openvas:base_url username password* port ca_cert;sonarqube:base_url token*;zap:base_url api_key* ca_cert。一改就換連線對象、但不在清單裡的:ssh_port、winrm_port、winrm_ssl、winrm_self_signed、ca_cert。username、ssh_username、winrm_username)、認證方式、use_sudo 不加——既有測試 test/test_credential_store.py:204 test_put_unchanged_address_keeps_secret 明確保障「位址沒變、只改帳號名稱不用重填密碼」,這是刻意的行為,不要推翻。首腦試過「所有非祕密欄位都算」的做法,會讓這支與另外兩支測試變紅,所以不採用。guidant_agent/scan/app/secret_form.py
test/test_secret_store.py
test/test_tool_connection_identity.py
secret_form.py:21 _ADDRESS_KEYS 加五個鍵:ssh_port、winrm_port、winrm_ssl、winrm_self_signed、ca_cert。常數上方的註解改成現況一句:「改了就換連線對象或換信任對象的欄位:位址、連接埠、是否加密、信任哪張 CA」。:153 的錯誤訊息「位址改了,{name}要重填」改成「連線設定改了,{name}要重填」(現在不只位址)。validate()(:83)裡的 _coerce(:56)依欄位型別轉過,已存的值當初也是同一支整理過才存的。guidant_agent/console/api/ldap_routes.py:71),它的欄位是 server、port、encryption…,不含這五個新鍵,行為不變。在主控台改工具的 SSH/WinRM 連接埠、WinRM 的 HTTPS 開關或自簽開關、ZAP/OpenVAS 的 CA 憑證時,要把密碼/token/私鑰重填一次才能存。只改帳號名稱、或什麼都沒改按儲存,不受影響。畫面不用改:後端回的 400 訊息畫面本來就會顯示。
test/test_secret_store.py:112 test_pinned_keys_from_schema_flag_and_address_names 的 schema 裡補 {"key": "ssh_port"}、{"key": "ca_cert"} 並把預期結果跟著加上(這支在驗清單內容,清單變了它要跟著變)。test/test_tool_connection_identity.py 已有 #232 的測試,照同樣寫法加三支:只改 ssh_port、只換 ca_cert、只改 winrm_ssl → 沒重填祕密回 400。test/test_credential_store.py:204 那支(只改帳號名稱不用重填)必須維持綠、不准改它。
🔴 不要 poetry install、不要動共用環境、不要改 pyproject.toml。Agent 主線釘 jedi-agent-protocol==0.6.1,這版還沒推上 Nexus,共用環境裡是 0.6.0,直接跑會 ImportError(KIND_SCAN_RESULT)。用下面的 PYTHONPATH 指到套件 repo 主資料夾就是對的版本。首腦 2026-11-11 在主線 b8b1158(FR-193 rootless 已合回)用這行跑全量:2554 passed、1 skipped、0 failed,約 3 分鐘;工作區裡跑守衛:109 passed,12 秒。