SSP 元件清冊(Components)
功能群:專案管理|上層見 系統安全計畫編輯器(本頁=其 Tab「元件·授權·資產」的元件子區)
事實基準:2026-07-06 從 FE / BE code 掃出;表結構對
db_schema.json、endpoint 對routes.json、欄位對 route 組裝碼 + mapper 逐條核
1. 功能描述
元件清冊是 SSP
系統實作(system-implementation)底下的
components
維護區:登錄構成這套受評系統的元件——軟體、硬體、服務、政策、流程等。對應
OSCAL SSP 的 system-implementation.components,掛在
ssp_system_implementations(首次新增時
get_or_create 自動建父)。每個元件可標
component_type(15
選)、狀態、關聯的利用授權(leveraged_authorization_uid,來源同頁「利用授權」子區),以及協定
/ Port / 安全機制等擴充屬性。
掛在 SSP 編輯器
Tab「元件·授權·資產」的第一子區(元件 → 授權 →
資產),三子區共用同一個 Vue
元件(SspComponentsLeveragedInventoryTab.vue)。與 SSP
其餘子區共用可編輯 gate(manager + AP=planning),凍結後唯讀。
主要使用者:專案 manager(寫)、專案任一參與者(讀)。
角色速覽(完整定義見 _overview §3):
| 角色 | 一句話 |
|---|---|
| manager | 專案經理 — 唯一能增改刪元件者(需 AP=planning) |
| 參與者 | auditor / reviewer / viewer — 可讀不可寫 |
1.1 功能總覽(本頁全部功能)
| # | 功能 | 說明 | 位置 | 詳述 |
|---|---|---|---|---|
| 1 | 元件清單 | 此 SSP 全部元件(DataTable,不分 type) | 元件區 | §5 |
| 2 | 新增 / 編輯元件 | title + 15 選 type + 狀態 + 利用授權 + 協定/Port/安全機制(9 欄) | Dialog | UC-SC-01 |
| 3 | 關聯利用授權 | Dropdown 選同頁「利用授權」子區的項目(存 props) |
Dialog | UC-SC-01 / §12 |
| 4 | 刪除元件 | 移除一筆(元件 uuid 被資產 M2M 軟參照,見 §12) | 每列 | §6.2 |
UC(§2)展開 UC-SC-01(新增/編輯元件),涵蓋 15 型別、必填雙檢(title/type)、props 擴充欄、編輯 not-found 四個關鍵分支;清單顯示屬純顯示見 §5。
2. Use Case
角色速覽(同 §1)。流程圖視覺慣例:菱形 = 判斷、橘底 = 例外/擋下、紅框 = 錯誤(標 error code)、綠框 = 成功終點、虛線 = 可選路徑。
UC-SC-01 新增 / 編輯元件
| 項目 | 內容 |
|---|---|
| 角色 | 專案 manager |
| 前置條件 | 已載入 living SSP;AP=planning |
| 產出 / 後置條件 | 寫 oscal.ssp_components(掛
ssp_system_implementations,首次
get_or_create);核心欄
type/title/description/purpose/status_state +
props(protocol/port_ranges/security_auth/leveraged-authorization-uid);回傳
DTO + enrich nickname |
3. 權限矩陣
| 操作 | FE 判定 | BE 強制 | BE 檢查位置 |
|---|---|---|---|
| 讀清單 | 參與者即可 | require_participant |
app/oscal/service/ssp_components_app_service.py:55(list_items) |
| 新增 / 編輯 / 刪除 | readonly prop(非 manager / AP 非 planning
隱藏鈕) |
require_manager(manager + AP 可編輯,否則
GRC_403051 / GRC_412028) |
同檔 add_item:63 / update_item:86 /
delete_item:105 |
route 層僅
@jwt_required(),且收 rawrequest.get_json()、無 marshmallow schema 驗證(ssp_components_route.py:50,69);角色守門與欄位處理都在 app service。
4. 狀態機與前置條件
承接 SSP 可編輯 gate(見 SSP 編輯器
§4):AP=planning 且 manager
才可寫,凍結後唯讀。額外前置:system_implementation
不存在時,新增第一筆元件會
get_or_create_system_implementation
自動建立(ssp_components_app_service.py:66)。
5. UI 設計
版面骨架與區塊職責(一張元件 DataTable + 新增/編輯 Dialog;彩色區塊可點跳本頁小節錨點,API 僅標代表性):
📸 截圖待補(亮色模式):元件 DataTable + 新增/編輯 Dialog
sspcomp-list.png。
一張 DataTable(此 SSP 全部元件,不分 type)+「新增元件」開
Dialog。DataTable
欄位:類型(Tag,COMPONENT_TYPE_SEVERITY 上色)/
名稱 / 描述(兩行截斷)/ 狀態 / 利用授權(Chip
leveraged_authorization_title——⚠️ 見 §12)/
協定(props.protocol)/
安全機制(props.security_auth)/ 動作(編輯 + 刪除)。
Dialog
欄位(SspComponentsLeveragedInventoryTab.vue 元件
Dialog):
| # | i18n label | 型別 | 必填 | 列舉 / 來源 | 儲存 | 備註 |
|---|---|---|---|---|---|---|
| 1 | col_title 名稱 |
InputText | 是 | — | title |
空 → FE toast warn(無 BE 守門,見 §12) |
| 2 | col_component_type 類型 |
Dropdown | 是 | 15 type(見下) | type |
FE 預設 system;BE 預設 software(FE
恆送、少命中) |
| 3 | col_description 描述 |
Textarea | 否 | — | description |
|
| 4 | 用途 | Textarea | 否 | — | purpose |
|
| 5 | col_status 狀態 |
Dropdown(showClear) |
否 | 5 值:operational / under-development /
under-major-modification / disposition /
other |
status_state |
FE 預設 operational |
| 6 | col_leveraged_auth 利用授權 |
Dropdown(showClear、filter) |
否 | 同頁「利用授權」子區項目(leveragedAuthOptions,label=title、value=uid) |
props['leveraged-authorization-uid'] |
軟參照,非核心欄 |
| 7 | col_protocol 協定 |
InputText | 否 | — | props['protocol'] |
|
| 8 | Port | InputText | 否 | — | props['port_ranges'] |
|
| 9 | col_security_auth 安全機制 |
InputText | 否 | — | props['security_auth'] |
15
component_type(componentTypeOptions,i18n
ssp_excel_import.component_type.*):this-system
/ system / service /
interconnection / hardware /
software / network / policy /
physical / process-procedure /
plan / guidance / standard /
validation / other。
狀態呈現:無 socket,寫入後 loadAll
重載;readonly 隱藏新增/編輯/刪除鈕。
6. API 規格
Envelope:成功 {"status": true, "data": …}、失敗
{"error_code": "…", "msg": "…"}。
6.1 總清單
| 分類 | Method + Path | 說明 | 完整規格 |
|---|---|---|---|
| 元件 | GET / POST /ssp/{ssp_uid}/components |
列出(全 type)/ 新增 | §6.2 |
| 元件 | PUT / DELETE /ssp/{ssp_uid}/components/{item_uid} |
編輯 / 刪除 | §6.2 |
| picker | GET /ssp/{ssp_uid}/leveraged |
利用授權 dropdown 來源(同頁子區) | 利用授權 |
6.2 核心 endpoint
[POST] /ssp/{ssp_uid}/components
新增元件。Request(route 收 raw JSON,無 schema;欄位由 service
add_item 取用):
{
"title": "Web 應用伺服器",
"component_type": "software",
"description": "對外服務主機",
"purpose": "承載受評應用",
"status": "operational",
"leveraged_authorization_uid": null,
"protocol": "HTTPS",
"port_ranges": "443",
"security_auth": "TLS 1.3 + mTLS"
}| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
| title | string | 是* | → title(*FE 端擋空,BE 無守門) |
| component_type | string | 是* | 15 type 之一 → type(BE 缺省
software) |
| description | string | 否 | → description |
| purpose | string | 否 | → purpose |
| status | string | 否 | 5 值之一 → status_state |
| leveraged_authorization_uid | string|null | 否 | 關聯利用授權 uid →
props['leveraged-authorization-uid'](軟參照) |
| protocol / port_ranges / security_auth | string | 否 | → props['protocol'] / props['port_ranges']
/ props['security_auth'] |
出處:app/oscal/service/ssp_components_app_service.py:61-82、mapper
app/module_frame/service/module_frame_components_service.py:_build_props:164-181
[GET] /ssp/{ssp_uid}/components
Response data(陣列,_to_dict +
enrich):
| 欄位 | 型別 | 說明 |
|---|---|---|
| uid | string | 元件 uuid(改刪用;被資產 M2M 軟參照) |
| component_type | string | ← type |
| title / description / purpose | string|null | ← 同名核心欄 |
| status | string|null | ← status_state |
| leveraged_authorization_uid | string|null | ← props['leveraged-authorization-uid'] |
| props | object|null | reshape 回 FE 的
{protocol, port_ranges, security_auth}(只含有值鍵) |
| created_user / updated_user | string|null | login_name(+ enrich *_name nickname) |
⚠️ 無
leveraged_authorization_title:BE DTO 只回leveraged_authorization_uid,DataTable 的「利用授權」Chip 綁leveraged_authorization_title(FE 未貼),實際恆顯示「—」(見 §12)。出處:module_frame_components_service.py:_to_dict:131-146
[PUT] /ssp/{ssp_uid}/components/{item_uid}
編輯。只更新 payload
帶到的鍵(component_type/title/description/purpose/status
+ props 非破壞性合併);item_uid 不存在於此 SSP →
GRC_404034。出處:ssp_components_app_service.py:84-101
7. 前端檔案地圖(compliance-manager-fe/)
| 檔案 | 角色 |
|---|---|
src/components/grc/ssp/SspComponentsLeveragedInventoryTab.vue |
本子區(元件 / 授權 / 資產三表同元件;元件 DataTable + Dialog + 15 type/狀態/LA/props 欄) |
src/service/SspService.js |
getSspComponents / createSspComponent /
updateSspComponent / deleteSspComponent |
8. 後端檔案地圖(本頁核心鏈路)
| 鏈路 | Route | App Service | 底層 |
|---|---|---|---|
| 元件 CRUD | api/oscal/routes/ssp/ssp_components_route.py(raw
JSON、無 schema) |
SspComponentsAppService(require_participant
讀 / require_manager 寫;經
SspPermissionChecker) |
oscal.ssp_components(掛
ssp_system_implementations);純 mapping 共用
ModuleFrameComponentsService(_to_dict /
_build_props,單一真相) |
DDD 提醒:mapping 共用範本版 helper。⚠️ SSP 版
add_item無同名去重、MF 版有(MODULE_FRAME_COMPONENT_NAME_EXISTED)——public method 各自實作,勿誤認行為相同(見 §12)。
9. DB
9.1 資料表總清單(本頁讀寫的全部表)
| 表 | 讀寫 | 說明 | 詳述 |
|---|---|---|---|
| oscal.ssp_components | 讀 / 寫 | 元件本體(掛 system-implementation) | §9.3 |
| oscal.ssp_system_implementations | 讀 / 首次新增自動建 | containment 父 | GAI-SD-03 |
9.2 ER 圖
元件隸屬 ssp_system_implementations(containment),元件
uuid 被
ssp_inventory_items.implemented_components 軟參照,見 SSP 編輯器 §9.2 ER;本頁不另繪。
9.3 核心表欄位(取自 DEV DB dump,含 DB comment)
oscal.ssp_components
| 欄位 | 型別 | 說明 |
|---|---|---|
| system_implementation_id | bigint | containment FK(結構必填) |
| uuid | uuid | [必填] 元件身分(對外 uid;by-component 以此軟參照) |
| type | text | [必填] component.type(15 值,如
software/hardware/service/this-system) ←
component_type |
| title / description | text | [必填] 名稱 / 說明 |
| purpose | text | [選填] 用途 |
| status_state | varchar(40) | [必填] under-development / operational / under-major-modification /
disposition / other ← status |
| status_remarks | text | [選填](本頁 UI 未用) |
| responsible_roles | jsonb | [選填](本頁 UI 未用) |
| protocols | jsonb | [選填] OSCAL protocol[]——本頁 UI 的協定/Port 走
props,非此欄 |
| props | jsonb | [選填] [{name,value}];本頁保留鍵 protocol
/ port_ranges / security_auth /
leveraged-authorization-uid |
⚠️ schema 註:以
db_schema.json為準(tbls.md版曾 drift 寫成ssp_id/component_type/leveraged_authorization_uid欄,皆錯)。本表 無leveraged_authorization_uid欄(在props)、無tenant_id/is_active;協定/Port 亦不落protocolsOSCAL 欄而在props。
10. 頁面邏輯與資料對應
loadAll 一次 Promise.all 拉元件 / 利用授權
/ 資產 / 資訊系統 menu / 設備 menu;元件 raw 存
components。欄位對應:
| 畫面元素 | FE state | API 欄位 → DB |
|---|---|---|
| 類型 | compEditing.component_type |
component_type → type |
| 名稱 / 描述 / 用途 | compEditing.title / .description /
.purpose |
同名核心欄 |
| 狀態 | compEditing.status |
status → status_state |
| 利用授權 | compEditing.leveraged_authorization_uid |
同名 → props['leveraged-authorization-uid'] |
| 協定 / Port / 安全機制 | compEditing.protocol / .port_ranges /
.security_auth |
→ props['protocol'] / ['port_ranges'] /
['security_auth'] |
儲存流程:saveComponent 先 client 檢查
title.trim() + component_type(缺 → toast warn
不送)→ POST/PUT → loadAll 重載。LA
使用計數:FE laReferenceCounts 由
component.leveraged_authorization_uid
反查授權被幾個元件引用。錯誤對應:GRC_404034(元件不存在)/
GRC_403051 / GRC_412028 → toast。
11. 背景行為與外部依賴
| 類型 | 內容 |
|---|---|
| socket | 無(loadAll 重載) |
| 依賴 | 同頁「利用授權」子區(GET /leveraged)供元件的利用授權
dropdown |
| 共用 | 同一元件 / mapping 被 module-frame
範本編輯復用(apiBase='module-frame');⚠️ add
去重行為兩端不同 |
12. 邊界情況與已知坑
- DataTable「利用授權」Chip 恆空:欄位綁
data.leveraged_authorization_title,但 BE_to_dict只回leveraged_authorization_uid、loadAll未把授權 title join 回元件——leveraged_authorization_title永遠 undefined,Chip 恆顯示「—」。要顯示需 FE 用leveragedAuthOptionsmap uid→title 或 BE enrich(follow-up)。 - title 必填只有 FE 擋、BE
無守門:
saveComponentclient 檢查 title/type;但 route 收 raw JSON、serviceadd_item用payload.get('title') or ''——直接打 API 送空 title 不會被拒(無等價 error code)。 - SSP 版新增無同名去重、MF
版有:
ModuleFrameComponentsService.add_item有 case-insensitive 同名 ConflictError;SspComponentsAppService.add_item沒有——SSP scope 可建同名元件。 - component_type 預設 FE/BE 不同:FE
startAddComponent預設system、BEadd_item缺省software;因 FE 恆送component_type,BE 預設幾乎不觸發,但直打 API 不帶此欄時會落software。 - 協定/Port/利用授權皆走
props、非核心欄:
props['protocol']/['port_ranges']/['security_auth']/['leveraged-authorization-uid']是產品擴充;DB 的protocolsOSCAL jsonb 欄本頁不寫。改鍵名要同步 mapper_PROP_KEYS/_PROP_LEVERAGED。 - 元件 uuid 被資產 M2M
軟參照:
ssp_inventory_items.implemented_components以component-uuid軟參照元件(無 FK);刪元件不會連動清資產側關聯,留意孤兒參照。 - SSP 寫入無 phase guard(BE):唯讀由 FE 鎖;凍結後直接打 API 仍會改 living SSP——同 SSP 編輯器 §12。