本卡屬 FR-165(母卡見「母卡」欄),批 4。只改 jedi-detection 套件 repo。工具清單 API 每筆多一個布林
supports_profile_library,由既有的 param_schema 宣告算出來,不寫死工具名。不發版、不推 Nexus。
「掃描工具資源管理」的設定檔分頁現在列出全部九個檢測工具(OpenVAS、Nessus、SonarQube、ZAP、Nmap 都在),但真正吃設定檔庫的只有 CINC Auditor 與 GCB 兩個。決策者 2026-10-26 裁「沒有的就先隱藏」。要隱藏,前端得知道哪些工具有接設定檔庫;這件事後端早就有宣告(FR-059:工具的參數定義裡 profile 欄位帶 options_source: profile_library),只是工具清單 API 沒把它帶出來。這張卡把它帶出來,下一張 FE 卡照旗標過濾。之後 OpenSCAP 接上設定檔庫,seed 加宣告就自動出現,前端不用改。
~/Projects/Jedicogy/module/jedi-python-package/jedi-detection/jedi_detection/app/service/detection_tool_service.py:76-79 list_tools():回 self._domain.get_tools(enabled=True),在這裡補旗標
~/Projects/Jedicogy/module/jedi-python-package/jedi-detection/jedi_detection/app/service/detection_tool_service.py:57,66 建構子已注入 param_schema_domain_service(DetectionToolParamSchemaDomainService)
~/Projects/Jedicogy/module/jedi-python-package/jedi-detection/jedi_detection/domain/detection_tools/service/detection_tool_param_schema_domain_service.py:25 get_current_schema(detection_tool_id) -> entity 或 None
~/Projects/Jedicogy/module/jedi-python-package/jedi-detection/jedi_detection/app/service/detection_profile_extraction_service.py:683-704 _read_declaration():既有的「找帶 options_source=profile_library 那個欄位」寫法,照抄判斷式
~/Projects/Jedicogy/module/jedi-python-package/jedi-detection/jedi_detection/domain/detection_tools/entity/detection_tool_entity.py:6-31 DetectionToolEntity dataclass,加一個 Optional[bool] 欄
~/Projects/Jedicogy/module/jedi-python-package/jedi-detection/jedi_detection/api/serializers/detection_tool.py:5-30 DetectionToolResponse,加一個 fields.Boolean
DEV 實查(2026-10-26):config.detection_tool_param_schemas 現行版(is_current)帶 profile_library 的只有 inspec 與 gcb(各 version 2)。工具清單 API GET /api/1.0/detection-tools 回 9 筆、目前欄位:uid/code/name/description/connection_type/execution_target/config_field_schema/setup_guide/status/enabled/requires_credentials/requires_target_host/credential_group_schema。
profile_library 在套件內——_read_declaration 是唯一讀法,把「找帶 options_source == 'profile_library' 的欄位」這段抽成一支小的純函式(例如 common/profile_library_declaration.py 的 find_profile_library_field(param_schema) -> dict | None),_read_declaration 改呼叫它,list_tools 也呼叫它。不要在兩處各寫一次判斷式。DetectionToolEntity 加 supports_profile_library: Optional[bool] = None(mapper 不動,它不是 DB 欄)。list_tools():拿到 tools 後,一次查所有工具的現行 param schema(看 domain service/repo 有沒有 get_current_schemas(tool_ids) 批次方法;沒有就在 repo 加一支 list_current_by_tool_ids,WHERE detection_tool_id = ANY(:ids) AND is_current),逐筆設 tool.supports_profile_library = find_profile_library_field(schema.param_schema) is not None。不要 N+1(九支工具九次查詢)。沒有 schema 的工具=False。DetectionToolResponse 加 supports_profile_library = fields.Boolean()。其他呼叫 list_tools 的地方(Agent 管理頁、選單 store、工具插件頁)多一個欄位不受影響。get_tool(uid) 單筆要不要也帶:帶,同一支小函式算一次,免得兩個端點回的形狀不一樣。find_profile_library_field:有宣告回該欄、沒宣告回 None、param_schema 不是 list 回 None。list_tools 旗標:假兩支工具,一支現行 schema 帶宣告、一支沒有/沒 schema,斷言 True/False;突變驗證:把判斷式改成 != 要紅。pytest tests/ -k 'detection_tool' -q 既有測試不弄壞。pyproject.toml 的 jedi-detection pin 註解、path 行取消註解,poetry update jedi-detection)重啟後:curl -s -H 'Authorization: Bearer <t>' localhost:8000/api/1.0/detection-tools | python3 -c "import sys,json;[print(x['code'],x['supports_profile_library']) for x in json.load(sys.stdin)['data']]" → inspec/gcb True、其餘七支 False。path 改動不 commit,回寫寫明。~/Projects/Jedicogy/module/jedi-python-package/jedi-detection 下的檔與測試。不 bump 版號、不發版、不推 Nexus。主專案 pyproject.toml/poetry.lock 的 path 改動不 commit。