@huawei-iac-tools/landingzone-workbench 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +85 -2
- package/cordis.patch.yml +21 -0
- package/knowledge/account-qualification.md +128 -0
- package/knowledge/blueprints/_base/blueprint.json +481 -0
- package/knowledge/blueprints/_base/defaults.json +127 -0
- package/knowledge/blueprints/foundation-lz/blueprint.json +43 -0
- package/knowledge/blueprints/foundation-lz/defaults.json +47 -0
- package/knowledge/blueprints/full-lz/blueprint.json +11 -0
- package/knowledge/blueprints/full-lz/defaults.json +8 -0
- package/knowledge/config.json +43 -0
- package/knowledge/error-rules.json +14 -0
- package/knowledge/ic-policies.json +21 -0
- package/knowledge/modules/account-structure.md +101 -0
- package/knowledge/modules/compliance/config-rms.md +212 -0
- package/knowledge/modules/compliance/cts.md +179 -0
- package/knowledge/modules/compliance/obs-lts.md +155 -0
- package/knowledge/modules/ic-policies.json +21 -0
- package/knowledge/modules/identity-center.md +603 -0
- package/knowledge/modules/module-layers.md +169 -0
- package/knowledge/modules/network/er.md +222 -0
- package/knowledge/modules/network/nat-eip.md +123 -0
- package/knowledge/modules/network/ram-share.md +92 -0
- package/knowledge/modules/network/vpc-subnet.md +142 -0
- package/knowledge/modules/organization-security/scp.md +122 -0
- package/knowledge/modules/organizations.md +212 -0
- package/knowledge/modules/recommended-config.md +157 -0
- package/knowledge/modules/recommended-rules.json +175 -0
- package/knowledge/modules/scp-policies.json +111 -0
- package/knowledge/modules/security/aad.md +94 -0
- package/knowledge/modules/security/cfw.md +105 -0
- package/knowledge/modules/security/waf.md +110 -0
- package/knowledge/param-mappings.json +133 -0
- package/knowledge/prompts.md +83 -0
- package/knowledge/resource-types.json +1162 -0
- package/knowledge/scp-policies.json +111 -0
- package/knowledge/state-machine.md +33 -0
- package/lib/client.js +21 -0
- package/lib/index.js +28592 -0
- package/lib/types/account-role.d.ts +19 -0
- package/lib/types/account-scope.d.ts +10 -0
- package/lib/types/agency.d.ts +38 -0
- package/lib/types/client/DropdownSelect.d.ts +49 -0
- package/lib/types/client/LoginGate.d.ts +20 -0
- package/lib/types/client/PanelIcon.d.ts +11 -0
- package/lib/types/client/WorkbenchShell.d.ts +21 -0
- package/lib/types/client/account-role.d.ts +15 -0
- package/lib/types/client/credential-status.d.ts +15 -0
- package/lib/types/client/huawei-mark.d.ts +37 -0
- package/lib/types/client/index.d.ts +26 -0
- package/lib/types/client/layout-ref.d.ts +23 -0
- package/lib/types/client/pages/ConfigPage/AdviceCard.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/AuditBar.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/ChangeSummaryCard.d.ts +22 -0
- package/lib/types/client/pages/ConfigPage/ChangesCard.d.ts +27 -0
- package/lib/types/client/pages/ConfigPage/ComplianceDetail.d.ts +25 -0
- package/lib/types/client/pages/ConfigPage/ComplianceSummaryCard.d.ts +31 -0
- package/lib/types/client/pages/ConfigPage/FindingsCard.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/GlossaryDrawer.d.ts +17 -0
- package/lib/types/client/pages/ConfigPage/OrgComplianceDetail.d.ts +15 -0
- package/lib/types/client/pages/ConfigPage/Pager.d.ts +32 -0
- package/lib/types/client/pages/ConfigPage/ResourceDrawer.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/ResourcesTable.d.ts +35 -0
- package/lib/types/client/pages/ConfigPage/RollupPanel.d.ts +17 -0
- package/lib/types/client/pages/ConfigPage/RuleDetailDrawer.d.ts +23 -0
- package/lib/types/client/pages/ConfigPage/StatusCards.d.ts +26 -0
- package/lib/types/client/pages/ConfigPage/UncoveredDialog.d.ts +22 -0
- package/lib/types/client/pages/ConfigPage/config-api.d.ts +101 -0
- package/lib/types/client/pages/ConfigPage/config-store.d.ts +57 -0
- package/lib/types/client/pages/ConfigPage/index.d.ts +21 -0
- package/lib/types/client/pages/ConfigPage/paging.d.ts +46 -0
- package/lib/types/client/pages/ConfigPage/scope-options.d.ts +51 -0
- package/lib/types/client/pages/CostPage/AccountAllocation.d.ts +24 -0
- package/lib/types/client/pages/CostPage/AccountBars.d.ts +20 -0
- package/lib/types/client/pages/CostPage/AccountColumns.d.ts +24 -0
- package/lib/types/client/pages/CostPage/AccountDonut.d.ts +18 -0
- package/lib/types/client/pages/CostPage/AccountSwitcher.d.ts +25 -0
- package/lib/types/client/pages/CostPage/AdviceCard.d.ts +43 -0
- package/lib/types/client/pages/CostPage/AdviceFindings.d.ts +43 -0
- package/lib/types/client/pages/CostPage/BillingPanels.d.ts +23 -0
- package/lib/types/client/pages/CostPage/BudgetCard.d.ts +36 -0
- package/lib/types/client/pages/CostPage/GlossaryDrawer.d.ts +16 -0
- package/lib/types/client/pages/CostPage/KpiRow.d.ts +23 -0
- package/lib/types/client/pages/CostPage/MarkdownBlock.d.ts +16 -0
- package/lib/types/client/pages/CostPage/ReportView.d.ts +17 -0
- package/lib/types/client/pages/CostPage/ResourceColumns.d.ts +19 -0
- package/lib/types/client/pages/CostPage/ResourceDonut.d.ts +18 -0
- package/lib/types/client/pages/CostPage/ResourcesCard.d.ts +40 -0
- package/lib/types/client/pages/CostPage/RuleDetailDrawer.d.ts +23 -0
- package/lib/types/client/pages/CostPage/SavingView.d.ts +38 -0
- package/lib/types/client/pages/CostPage/ServiceDonut.d.ts +17 -0
- package/lib/types/client/pages/CostPage/TrendChart.d.ts +24 -0
- package/lib/types/client/pages/CostPage/budget-input.d.ts +30 -0
- package/lib/types/client/pages/CostPage/cost-api.d.ts +266 -0
- package/lib/types/client/pages/CostPage/cost-store.d.ts +25 -0
- package/lib/types/client/pages/CostPage/format.d.ts +37 -0
- package/lib/types/client/pages/CostPage/index.d.ts +34 -0
- package/lib/types/client/pages/CostPage/trend-fold.d.ts +32 -0
- package/lib/types/client/pages/CostPage/useEcharts.d.ts +70 -0
- package/lib/types/client/pages/OrgStructurePage/AccountStatsCard.d.ts +22 -0
- package/lib/types/client/pages/OrgStructurePage/CoreAccountsCard.d.ts +18 -0
- package/lib/types/client/pages/OrgStructurePage/CreateAccountDialog.d.ts +28 -0
- package/lib/types/client/pages/OrgStructurePage/ManageUsersDialog.d.ts +28 -0
- package/lib/types/client/pages/OrgStructurePage/MemberAccountsTable.d.ts +32 -0
- package/lib/types/client/pages/OrgStructurePage/MoveAccountDialog.d.ts +29 -0
- package/lib/types/client/pages/OrgStructurePage/OrgGlossaryDrawer.d.ts +13 -0
- package/lib/types/client/pages/OrgStructurePage/OrgTreeCard.d.ts +31 -0
- package/lib/types/client/pages/OrgStructurePage/index.d.ts +21 -0
- package/lib/types/client/pages/OrgStructurePage/org-api.d.ts +166 -0
- package/lib/types/client/pages/OverviewPage/AnchorRow.d.ts +24 -0
- package/lib/types/client/pages/OverviewPage/AttentionList.d.ts +29 -0
- package/lib/types/client/pages/OverviewPage/OverviewCharts.d.ts +79 -0
- package/lib/types/client/pages/OverviewPage/OverviewGlossaryDrawer.d.ts +15 -0
- package/lib/types/client/pages/OverviewPage/index.d.ts +22 -0
- package/lib/types/client/pages/OverviewPage/overview-api.d.ts +115 -0
- package/lib/types/client/pages/ResourcePage/AccountResourceList.d.ts +21 -0
- package/lib/types/client/pages/ResourcePage/components/GlossaryDrawer.d.ts +20 -0
- package/lib/types/client/pages/ResourcePage/components/MetricCards.d.ts +19 -0
- package/lib/types/client/pages/ResourcePage/components/MultiSelect.d.ts +27 -0
- package/lib/types/client/pages/ResourcePage/components/PanelPager.d.ts +26 -0
- package/lib/types/client/pages/ResourcePage/components/RankBars.d.ts +25 -0
- package/lib/types/client/pages/ResourcePage/components/ScopeSelect.d.ts +27 -0
- package/lib/types/client/pages/ResourcePage/components/SourceConfigModal.d.ts +21 -0
- package/lib/types/client/pages/ResourcePage/components/SyncControls.d.ts +18 -0
- package/lib/types/client/pages/ResourcePage/components/TrendChart.d.ts +14 -0
- package/lib/types/client/pages/ResourcePage/components/useColumnWidths.d.ts +12 -0
- package/lib/types/client/pages/ResourcePage/format.d.ts +9 -0
- package/lib/types/client/pages/ResourcePage/index.d.ts +20 -0
- package/lib/types/client/pages/ResourcePage/summary-api.d.ts +205 -0
- package/lib/types/client/pages/SetupPage/AskPanel.d.ts +21 -0
- package/lib/types/client/pages/SetupPage/ChatEmbed.d.ts +40 -0
- package/lib/types/client/pages/SetupPage/ChatTab.d.ts +17 -0
- package/lib/types/client/pages/SetupPage/FormTab.d.ts +12 -0
- package/lib/types/client/pages/SetupPage/FormTabV2.d.ts +14 -0
- package/lib/types/client/pages/SetupPage/ProgressTreeView.d.ts +15 -0
- package/lib/types/client/pages/SetupPage/StageFlow.d.ts +16 -0
- package/lib/types/client/pages/SetupPage/index.d.ts +10 -0
- package/lib/types/client/pages/SetupPage/progress-types.d.ts +36 -0
- package/lib/types/client/pages/SetupPage/session-binding.d.ts +38 -0
- package/lib/types/client/pages/SetupPage/session-store.d.ts +57 -0
- package/lib/types/client/pages/SetupPage/sessions-ref.d.ts +5 -0
- package/lib/types/client/pages/SetupPage/setup-replan.d.ts +13 -0
- package/lib/types/client/pages/SetupPage/wb-api.d.ts +192 -0
- package/lib/types/client/pages/list-preview.d.ts +36 -0
- package/lib/types/client/permission-mode.d.ts +53 -0
- package/lib/types/client/store.d.ts +22 -0
- package/lib/types/collect.d.ts +78 -0
- package/lib/types/config/account-scope.d.ts +61 -0
- package/lib/types/config/advice-findings.d.ts +31 -0
- package/lib/types/config/advice-prompt.d.ts +60 -0
- package/lib/types/config/advice.d.ts +116 -0
- package/lib/types/config/cts.d.ts +30 -0
- package/lib/types/config/evidence/rules.d.ts +31 -0
- package/lib/types/config/evidence/types.d.ts +103 -0
- package/lib/types/config/failure-note.d.ts +46 -0
- package/lib/types/config/fingerprint-cache.d.ts +45 -0
- package/lib/types/config/identity.d.ts +67 -0
- package/lib/types/config/query.d.ts +49 -0
- package/lib/types/config/rms.d.ts +412 -0
- package/lib/types/config/routes.d.ts +32 -0
- package/lib/types/config/types.d.ts +785 -0
- package/lib/types/config/views.d.ts +158 -0
- package/lib/types/cost/accounts.d.ts +29 -0
- package/lib/types/cost/advice-findings.d.ts +77 -0
- package/lib/types/cost/advice-model.d.ts +19 -0
- package/lib/types/cost/advice-prompt.d.ts +73 -0
- package/lib/types/cost/advice-subagent-types.d.ts +6 -0
- package/lib/types/cost/advice-subagent.d.ts +116 -0
- package/lib/types/cost/advice-types.d.ts +63 -0
- package/lib/types/cost/advice.d.ts +125 -0
- package/lib/types/cost/aggregate.d.ts +157 -0
- package/lib/types/cost/assume.d.ts +43 -0
- package/lib/types/cost/bss.d.ts +166 -0
- package/lib/types/cost/budget-overview.d.ts +38 -0
- package/lib/types/cost/budget.d.ts +56 -0
- package/lib/types/cost/cache.d.ts +58 -0
- package/lib/types/cost/caliber.d.ts +40 -0
- package/lib/types/cost/console-links.d.ts +27 -0
- package/lib/types/cost/credentials.d.ts +38 -0
- package/lib/types/cost/data-window.d.ts +38 -0
- package/lib/types/cost/evidence/catalog.d.ts +35 -0
- package/lib/types/cost/evidence/index.d.ts +70 -0
- package/lib/types/cost/evidence/inventory.d.ts +44 -0
- package/lib/types/cost/evidence/pricing.d.ts +72 -0
- package/lib/types/cost/evidence/projects.d.ts +18 -0
- package/lib/types/cost/evidence/rules.d.ts +66 -0
- package/lib/types/cost/evidence/state.d.ts +38 -0
- package/lib/types/cost/evidence/thresholds.d.ts +68 -0
- package/lib/types/cost/evidence/types.d.ts +288 -0
- package/lib/types/cost/evidence/utilization.d.ts +37 -0
- package/lib/types/cost/history.d.ts +36 -0
- package/lib/types/cost/ledger.d.ts +97 -0
- package/lib/types/cost/normalize.d.ts +37 -0
- package/lib/types/cost/period-projection.d.ts +57 -0
- package/lib/types/cost/plan-check.d.ts +102 -0
- package/lib/types/cost/plan-db.d.ts +73 -0
- package/lib/types/cost/plan-types.d.ts +183 -0
- package/lib/types/cost/plan.d.ts +63 -0
- package/lib/types/cost/quote.d.ts +45 -0
- package/lib/types/cost/report.d.ts +136 -0
- package/lib/types/cost/resources.d.ts +108 -0
- package/lib/types/cost/routes.d.ts +38 -0
- package/lib/types/cost/scope.d.ts +42 -0
- package/lib/types/cost/types.d.ts +335 -0
- package/lib/types/cost/unit-prices-derive.d.ts +19 -0
- package/lib/types/cost/unit-prices.d.ts +23 -0
- package/lib/types/db.d.ts +228 -0
- package/lib/types/host-log.d.ts +7 -0
- package/lib/types/http.d.ts +42 -0
- package/lib/types/index.d.ts +30 -0
- package/lib/types/inventory.d.ts +286 -0
- package/lib/types/obs.d.ts +16 -0
- package/lib/types/org/aggregate.d.ts +36 -0
- package/lib/types/org/churn.d.ts +10 -0
- package/lib/types/org/orgs.d.ts +258 -0
- package/lib/types/org/routes.d.ts +28 -0
- package/lib/types/org-types.d.ts +156 -0
- package/lib/types/per-service.d.ts +39 -0
- package/lib/types/setup/blueprint-loader.d.ts +81 -0
- package/lib/types/setup/caller.d.ts +105 -0
- package/lib/types/setup/engine.d.ts +41 -0
- package/lib/types/setup/form-store.d.ts +13 -0
- package/lib/types/setup/nodes/n1-check.d.ts +14 -0
- package/lib/types/setup/nodes/n10-governance.d.ts +6 -0
- package/lib/types/setup/nodes/n11-infra.d.ts +6 -0
- package/lib/types/setup/nodes/n12-reconcile.d.ts +6 -0
- package/lib/types/setup/nodes/n2-region.d.ts +6 -0
- package/lib/types/setup/nodes/n3-blueprint.d.ts +6 -0
- package/lib/types/setup/nodes/n4-modules.d.ts +6 -0
- package/lib/types/setup/nodes/n5-details.d.ts +6 -0
- package/lib/types/setup/nodes/n6-plan.d.ts +6 -0
- package/lib/types/setup/nodes/n7-verify.d.ts +6 -0
- package/lib/types/setup/nodes/n8-approve.d.ts +6 -0
- package/lib/types/setup/nodes/n9-buildmode.d.ts +6 -0
- package/lib/types/setup/plan-state.d.ts +10 -0
- package/lib/types/setup/prompt-loader.d.ts +16 -0
- package/lib/types/setup/routes.d.ts +22 -0
- package/lib/types/setup/session-notify.d.ts +30 -0
- package/lib/types/setup/tools.d.ts +19 -0
- package/lib/types/setup/types.d.ts +157 -0
- package/lib/types/sse-bus.d.ts +23 -0
- package/lib/types/tools/config-facts.d.ts +16 -0
- package/lib/types/tools/cost-facts.d.ts +10 -0
- package/lib/types/tools/register.d.ts +18 -0
- package/lib/types/wb-conventions.d.ts +140 -0
- package/package.json +77 -4
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type SyncChannel } from './inventory.ts';
|
|
2
|
+
/** 同步进度事件(SSE 广播载荷)。 */
|
|
3
|
+
export interface SyncProgress {
|
|
4
|
+
readonly phase: 'counts' | 'types' | 'direct' | 'db' | 'done' | 'error';
|
|
5
|
+
readonly detail?: string;
|
|
6
|
+
readonly at: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SyncStats {
|
|
9
|
+
/** 本轮通道(运行时探测):aggregator=组织聚合,per-service=逐服务采集(子账号)。 */
|
|
10
|
+
readonly channel: SyncChannel;
|
|
11
|
+
/** 逐服务采集统计(channel=per-service 时携带):分母覆盖的类型与失败清单。 */
|
|
12
|
+
readonly per_service?: {
|
|
13
|
+
readonly collected: readonly {
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly count: number;
|
|
16
|
+
}[];
|
|
17
|
+
readonly failed: readonly {
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly regions: number;
|
|
20
|
+
readonly error: string;
|
|
21
|
+
}[];
|
|
22
|
+
/** 本轮 403 提炼出的权限码(去重排序)——「复制权限策略模板」的直接数据源。 */
|
|
23
|
+
readonly perm_codes: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
readonly total: number;
|
|
26
|
+
readonly managed: number;
|
|
27
|
+
readonly unmanaged: number;
|
|
28
|
+
/** 云上清单指纹(聚合器模式同步成功后回存;刷新探测比对用)。 */
|
|
29
|
+
readonly fingerprint?: {
|
|
30
|
+
readonly total: number;
|
|
31
|
+
readonly maxUpdated: string;
|
|
32
|
+
};
|
|
33
|
+
/** 回存指纹时的本地源代数(数据源变更会 +1 → 刷新探测判"变",走全量)。 */
|
|
34
|
+
readonly sources_generation?: number;
|
|
35
|
+
readonly drifted: number;
|
|
36
|
+
readonly tf_files: number;
|
|
37
|
+
readonly tf_entries: number;
|
|
38
|
+
readonly types_pulled: number;
|
|
39
|
+
readonly ep_total: number;
|
|
40
|
+
readonly ep_attributed: number;
|
|
41
|
+
readonly account_id: string;
|
|
42
|
+
readonly account_name: string;
|
|
43
|
+
readonly accounts: readonly {
|
|
44
|
+
readonly account_id: string;
|
|
45
|
+
readonly account_name: string;
|
|
46
|
+
readonly total: number;
|
|
47
|
+
readonly managed: number;
|
|
48
|
+
}[];
|
|
49
|
+
readonly warnings: readonly string[];
|
|
50
|
+
readonly per_source?: readonly {
|
|
51
|
+
readonly source: string;
|
|
52
|
+
readonly kind: string;
|
|
53
|
+
readonly entries: number;
|
|
54
|
+
readonly skipped?: boolean;
|
|
55
|
+
}[];
|
|
56
|
+
}
|
|
57
|
+
export declare function isSyncRunning(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 触发一轮同步。进度经 onProgress 回调(路由层转 SSE);完成后 run 落
|
|
60
|
+
* sync_runs(status=ok/error),快照写 metric_snapshots(当天覆盖)。
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* 刷新探测(方案A+/v2):云上指纹 **与** 本地源代数都与上次成功同步一致 → 'unchanged'。
|
|
64
|
+
* 源代数是 2026-11-10 修复补的第二要素:数据源 add/delete/toggle 会 bump——只看云上
|
|
65
|
+
* 的话,删掉本地 tfstate 源后云上没变,探测会错误地跳过全量,managed 不重算。
|
|
66
|
+
* 探测失败/非聚合器数据源 → 'unknown'(调用方照常跑全量,错误走既有 run 记录通道,
|
|
67
|
+
* 不静默假装"无变化")。busy 由路由层先行拦截,这里不重复判。
|
|
68
|
+
*/
|
|
69
|
+
export declare function probeSyncNeeded(): Promise<'unchanged' | 'changed' | 'unknown'>;
|
|
70
|
+
export declare function runResourceSync(trigger: 'manual' | 'auto', onProgress: (p: SyncProgress) => void): Promise<{
|
|
71
|
+
runId: number;
|
|
72
|
+
stats: SyncStats;
|
|
73
|
+
}>;
|
|
74
|
+
/** 进行中重复触发。 */
|
|
75
|
+
export declare class SyncBusyError extends Error {
|
|
76
|
+
constructor();
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=collect.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 视角决策:把"用户选的视角"和"这份凭据真正读得到什么"合成一个结论。
|
|
3
|
+
*
|
|
4
|
+
* 这一层存在的理由是一条云上事实:**Config 按 domain 授权**。一个 AK/SK 只能
|
|
5
|
+
* 读它自己那个 domain 的 Config 资源,跨 domain 一律 403 `RMS.00010006`
|
|
6
|
+
* (实测;见 `config/rms.ts` 的错误分类)。于是页面上的"视角"不是一个 UI 选项,
|
|
7
|
+
* 而是一个必须由凭据身份裁决的问题:
|
|
8
|
+
*
|
|
9
|
+
* · 主账号(或 Config 服务的委托管理员)→ 组织视角可用,聚合器读得动;
|
|
10
|
+
* · 成员账号 → 只读得到自己,组织视角物理上不可得,必须自动落到「本账号」。
|
|
11
|
+
*
|
|
12
|
+
* 早先这里是硬编码的"空串 = 组织视角、非空 = assume 到那个账号",从不问身份,
|
|
13
|
+
* 所以子账号登录后整页被一句 403 挡住。本模块就是那个缺失的判断,且刻意做成
|
|
14
|
+
* **纯函数**:所有分支都能在测试里覆盖,不需要云。
|
|
15
|
+
*
|
|
16
|
+
* 安全边界(与资源页 `doc/SUBACCOUNT-LOGIN-RESOURCE-PAGE.md` §4.3 同一条):
|
|
17
|
+
* 成员身份下请求任何别的账号,一律**服务端**收敛到本账号 —— 不依赖前端自觉,
|
|
18
|
+
* 也不依赖"数据库里只存了自己"这种假设。
|
|
19
|
+
*
|
|
20
|
+
* @module @huaweidevtools/landingzone-workbench/config/account-scope
|
|
21
|
+
*/
|
|
22
|
+
import type { ConfigChannel, ConfigScope } from './types.ts';
|
|
23
|
+
/** 决策需要知道的身份信息(只取判断用的那几项,便于测试构造)。 */
|
|
24
|
+
export interface ScopeIdentity {
|
|
25
|
+
/** 凭据自己属于哪个账号;null = 身份未解析(无凭据/IAM 不可达)。 */
|
|
26
|
+
readonly ownId: string | null;
|
|
27
|
+
readonly ownName: string | null;
|
|
28
|
+
/** 组织管理账号;成员凭据下通常解析不到,null。 */
|
|
29
|
+
readonly mainId: string | null;
|
|
30
|
+
/** 组织视角能不能给。 */
|
|
31
|
+
readonly channel: ConfigChannel;
|
|
32
|
+
}
|
|
33
|
+
/** 决策结果。 */
|
|
34
|
+
export interface ScopeDecision {
|
|
35
|
+
/** 生效的账号 domainId;空串 = 组织视角。 */
|
|
36
|
+
readonly accountId: string;
|
|
37
|
+
/** 生效的视角。 */
|
|
38
|
+
readonly scope: ConfigScope;
|
|
39
|
+
readonly channel: ConfigChannel;
|
|
40
|
+
/** 用户的请求被改写过(请求了组织视角或别的账号,最后用的是本账号)。 */
|
|
41
|
+
readonly clamped: boolean;
|
|
42
|
+
/** 需要原样显示给用户的说明(不改写时不出现)。 */
|
|
43
|
+
readonly note?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 裁决视角。
|
|
47
|
+
*
|
|
48
|
+
* @param requested 页面传来的 `?account=`(未校验的原文;空串 = 组织视角)。
|
|
49
|
+
* @param identity 当前凭据的身份与通道。
|
|
50
|
+
*/
|
|
51
|
+
export declare function decideScope(requested: string, identity: ScopeIdentity): ScopeDecision;
|
|
52
|
+
/**
|
|
53
|
+
* 视角初值:页面拿到 `scope_default` 之后该把下拉设成什么。
|
|
54
|
+
*
|
|
55
|
+
* 单独抽出来是为了让"默认停在组织视角"这件事只在一处定义 —— 前端写死 `''`
|
|
56
|
+
* 正是这次 bug 的一半(成员身份下它等于主动要一份拿不到的数据)。
|
|
57
|
+
*
|
|
58
|
+
* @returns `''` = 组织视角;domainId = 那个账号;undefined = 服务端没给(维持现状)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function initialScopeFor(scopeDefault: string | null | undefined): string | undefined;
|
|
61
|
+
//# sourceMappingURL=account-scope.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 发现 → 建议:把规则算好的东西喂给模型,并**守住数字**。
|
|
3
|
+
*
|
|
4
|
+
* 与费用侧 `cost/advice-findings.ts` 同一套路,但这里的模型职责更窄:
|
|
5
|
+
* · 不写 summary(结论句由宿主按覆盖面写,模型写不出"覆盖 5/28"这种口径);
|
|
6
|
+
* · 不写 evidence / measure(都是宿主算的,且口径容易混);
|
|
7
|
+
* · 只写三段人话:这条为什么成立(机制)、动它有什么副作用、具体怎么做。
|
|
8
|
+
*
|
|
9
|
+
* 这么切是因为旧卡片的三处硬伤全都出在"模型转述数字"上:
|
|
10
|
+
* 「25 个未覆盖账号」(实为 23)、「主账号 0 条规则」(实为 28)、
|
|
11
|
+
* 「120 个不合规资源」(实为组织 167 / 主账号 21)。数字不收归宿主,就会继续漂。
|
|
12
|
+
*
|
|
13
|
+
* @module @huaweidevtools/landingzone-workbench/config/advice-findings
|
|
14
|
+
*/
|
|
15
|
+
import type { ConfigAdviceItem, ConfigNarration } from './advice.ts';
|
|
16
|
+
import type { ConfigFinding, ConfigFindingsResult } from './evidence/types.ts';
|
|
17
|
+
/** 给模型看的事实(每条都带 finding_ref,模型只能引它)。 */
|
|
18
|
+
export declare function buildConfigAdviceFacts(result: ConfigFindingsResult): Record<string, unknown>;
|
|
19
|
+
/** 一条发现 → 一条模板建议(模型挂了也能看)。 */
|
|
20
|
+
export declare function templateConfigItem(finding: ConfigFinding): ConfigAdviceItem;
|
|
21
|
+
/**
|
|
22
|
+
* 合并:模型只改三段人话,其余一律来自发现;模型没提到的发现按模板补上。
|
|
23
|
+
*
|
|
24
|
+
* 为什么要补:模型会挑它觉得重要的 3–4 条。漏掉「23 个账号未纳入聚合器」
|
|
25
|
+
* 是事故(那是所有数字的前提),漏掉「操作状态不可用」无所谓 —— 但"哪条重要"
|
|
26
|
+
* 不该由它单独决定,所以全量都出现,只是排列由宿主定。
|
|
27
|
+
*/
|
|
28
|
+
export declare function mergeConfigAdvice(narration: readonly ConfigNarration[] | null, result: ConfigFindingsResult): readonly ConfigAdviceItem[];
|
|
29
|
+
/** 脚注:**一行**说清"哪些没进待办数"。 */
|
|
30
|
+
export declare function configFootnote(result: ConfigFindingsResult): string;
|
|
31
|
+
//# sourceMappingURL=advice-findings.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「配置审计分析建议」的结构化输出契约与 prompt(宿主侧)。
|
|
3
|
+
*
|
|
4
|
+
* 这一版的核心变化:**模型不再拥有任何数字**。
|
|
5
|
+
*
|
|
6
|
+
* 旧版让模型按 severity / evidence / action / next_step 写条目,并要求它"引用
|
|
7
|
+
* 上面出现过的数字"。结果就是页面上的三处硬伤:「25 个未覆盖账号」(实为 23)、
|
|
8
|
+
* 「主账号 0 条规则」(实为 28)、「120 个不合规资源」(实为 167/21)。
|
|
9
|
+
* 现在规则引擎先把每条算到具体对象(账号 / 规则 / 资源),模型改成只回答:
|
|
10
|
+
* ① 这条为什么成立(机制) ② 动它有什么副作用 ③ 具体怎么做。
|
|
11
|
+
*
|
|
12
|
+
* @module @huaweidevtools/landingzone-workbench/config/advice-prompt
|
|
13
|
+
*/
|
|
14
|
+
/** 结构化输出的 JSON Schema(ObjectJsonSchema 子集)。 */
|
|
15
|
+
export declare const CONFIG_ADVICE_OUTPUT_SCHEMA: {
|
|
16
|
+
readonly type: "object";
|
|
17
|
+
readonly additionalProperties: false;
|
|
18
|
+
readonly required: readonly ["items"];
|
|
19
|
+
readonly properties: {
|
|
20
|
+
readonly items: {
|
|
21
|
+
readonly type: "array";
|
|
22
|
+
readonly items: {
|
|
23
|
+
readonly type: "object";
|
|
24
|
+
readonly additionalProperties: false;
|
|
25
|
+
readonly required: readonly ["finding_ref", "title", "action", "reason", "risk_note"];
|
|
26
|
+
readonly properties: {
|
|
27
|
+
/** 必须原样取自 facts.findings[].finding_ref。 */
|
|
28
|
+
readonly finding_ref: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
};
|
|
31
|
+
/** 这条的人话标题(不超过 26 字)。 */
|
|
32
|
+
readonly title: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
};
|
|
35
|
+
/** 具体怎么做(含控制台路径)。 */
|
|
36
|
+
readonly action: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
};
|
|
39
|
+
/** 为什么这算问题(机制,不超过 60 字)。 */
|
|
40
|
+
readonly reason: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
};
|
|
43
|
+
/** 副作用与要留意的点。 */
|
|
44
|
+
readonly risk_note: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** 生成解读的 prompt。facts 是 `buildConfigAdviceFacts()` 的产物。 */
|
|
53
|
+
export declare function buildConfigAdvicePrompt(input: {
|
|
54
|
+
readonly accountId: string;
|
|
55
|
+
readonly accountName: string | null;
|
|
56
|
+
readonly facts: unknown;
|
|
57
|
+
/** 可引用的发现键(模型只能从这里选)。 */
|
|
58
|
+
readonly findingRefs: readonly string[];
|
|
59
|
+
}): string;
|
|
60
|
+
//# sourceMappingURL=advice-prompt.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ConfigFindingLayer, ConfigFindingsResult, ConfigSubject } from './evidence/types.ts';
|
|
2
|
+
import type { ConfigFindingTargets } from './types.ts';
|
|
3
|
+
/** 严重度。 */
|
|
4
|
+
export type ConfigAdviceSeverity = 'high' | 'medium' | 'low';
|
|
5
|
+
/** 一条解读建议。 */
|
|
6
|
+
export interface ConfigAdviceItem {
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly severity: ConfigAdviceSeverity;
|
|
9
|
+
readonly evidence: string;
|
|
10
|
+
readonly action: string;
|
|
11
|
+
readonly next_step: string;
|
|
12
|
+
/**
|
|
13
|
+
* 对应哪一条规则发现(`C1`…)。新版由宿主回填,老存档没有。
|
|
14
|
+
*
|
|
15
|
+
* 这是"数字归谁管"的分界线:模型只表达"我在说哪一条",衡量口径与
|
|
16
|
+
* 证据数字一律由宿主按 finding 回填(见 `config/advice-findings.ts`)。
|
|
17
|
+
*/
|
|
18
|
+
readonly finding_ref?: string | null;
|
|
19
|
+
/** 量化口径(`5 / 28 个账号`)。 */
|
|
20
|
+
readonly measure?: string;
|
|
21
|
+
/** 口径说明:全量 / 抽样 N / 仅主账号。 */
|
|
22
|
+
readonly scope_note?: string;
|
|
23
|
+
/** 机制:这条为什么会成为一个问题。 */
|
|
24
|
+
readonly reason?: string;
|
|
25
|
+
/** 副作用。 */
|
|
26
|
+
readonly risk_note?: string;
|
|
27
|
+
/** 对象标签:账号 / 规则 / 资源。 */
|
|
28
|
+
readonly subject_label?: string;
|
|
29
|
+
readonly subject_count?: number;
|
|
30
|
+
/** 这条落在哪一层(可立即执行 / 需先补数据 / 无法判定)。 */
|
|
31
|
+
readonly layer?: ConfigFindingLayer;
|
|
32
|
+
/** 具体对象(展开可看)。 */
|
|
33
|
+
readonly subjects?: readonly ConfigSubject[];
|
|
34
|
+
/**
|
|
35
|
+
* 「可执行对象清单」:哪条规则命中了哪些资源、哪个账号该开什么。
|
|
36
|
+
*
|
|
37
|
+
* 与 `subjects` 的区别:subjects 是粗粒度的一行(账号级),targets 才是"具体动谁"
|
|
38
|
+
* —— 规则名 + 资源 id + 区域 + 所属账号。卡片标题要一行、展开区要名单,粒度不同。
|
|
39
|
+
*/
|
|
40
|
+
readonly targets?: ConfigFindingTargets;
|
|
41
|
+
}
|
|
42
|
+
/** 存档记录。 */
|
|
43
|
+
export interface ConfigAdviceRecord {
|
|
44
|
+
/** 视角:空串 = 组织视角。 */
|
|
45
|
+
readonly account_id: string;
|
|
46
|
+
readonly generated_at: string;
|
|
47
|
+
/** 生成时用的模型(provider/model),便于排查"换了模型结果不一样"。 */
|
|
48
|
+
readonly model: string | null;
|
|
49
|
+
readonly summary: string;
|
|
50
|
+
readonly items: readonly ConfigAdviceItem[];
|
|
51
|
+
readonly footnote: string | null;
|
|
52
|
+
/** 生成时的事实指纹:页面用它判断"数据变了,这份建议可能过期"。 */
|
|
53
|
+
readonly fingerprint: string;
|
|
54
|
+
/**
|
|
55
|
+
* 生成时算出的**规则发现**(新版记录有,老存档没有)。
|
|
56
|
+
*
|
|
57
|
+
* 与 items 分开存:items 是模型的叙述,findings 是宿主算的事实。
|
|
58
|
+
* 卡片按 findings 渲染对象清单,数字永远来自它。
|
|
59
|
+
*/
|
|
60
|
+
readonly findings?: ConfigFindingsResult | null;
|
|
61
|
+
}
|
|
62
|
+
/** 给页面的视图(附带"是否过期")。 */
|
|
63
|
+
export interface ConfigAdviceView {
|
|
64
|
+
readonly account_id: string;
|
|
65
|
+
readonly generated_at: string;
|
|
66
|
+
readonly model: string | null;
|
|
67
|
+
readonly summary: string;
|
|
68
|
+
readonly items: readonly ConfigAdviceItem[];
|
|
69
|
+
readonly footnote: string | null;
|
|
70
|
+
/** 当前事实的指纹,与存档里的不同即为过期。 */
|
|
71
|
+
readonly stale: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** 最近一次失败的原因(与成功的存档分开存,免得一次失败抹掉已有建议)。 */
|
|
74
|
+
export interface ConfigAdviceError {
|
|
75
|
+
readonly at: string;
|
|
76
|
+
readonly message: string;
|
|
77
|
+
}
|
|
78
|
+
/** 存档目录(按登录账号隔离,2026-11-20 用户定稿——与 SQLite 同一逻辑)。 */
|
|
79
|
+
export declare function adviceDir(): Promise<string>;
|
|
80
|
+
/** 存档路径。 */
|
|
81
|
+
export declare function advicePath(accountId?: string | null): Promise<string>;
|
|
82
|
+
/** 错误记录路径。 */
|
|
83
|
+
export declare function adviceErrorPath(accountId?: string | null): Promise<string>;
|
|
84
|
+
/**
|
|
85
|
+
* 取数的指纹。
|
|
86
|
+
*
|
|
87
|
+
* 只用"结论层"的数字(总数、覆盖、合规计数、治理计数),不含逐条资源行 ——
|
|
88
|
+
* 否则任何一次资源变动都会让建议永久显示"已过期",那样的过期提示没人会看。
|
|
89
|
+
*/
|
|
90
|
+
export declare function fingerprintOf(facts: Record<string, unknown>): string;
|
|
91
|
+
/** 模型对某一条发现的叙述(不含任何数字)。 */
|
|
92
|
+
export interface ConfigNarration {
|
|
93
|
+
readonly finding_ref: string;
|
|
94
|
+
readonly title: string;
|
|
95
|
+
readonly action: string;
|
|
96
|
+
readonly reason: string;
|
|
97
|
+
readonly risk_note: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 解析模型输出:只认 `items[].finding_ref` 与三段人话。
|
|
101
|
+
*
|
|
102
|
+
* 与费用侧的差别:这里的模型**不产出 summary**(结论句由宿主写),
|
|
103
|
+
* 也不产出 evidence(证据数字由宿主回填)—— 少一处能漂的地方。
|
|
104
|
+
*/
|
|
105
|
+
export declare function parseConfigNarration(raw: unknown): readonly ConfigNarration[] | null;
|
|
106
|
+
/** 读存档(不存在或读坏 → null)。 */
|
|
107
|
+
export declare function readAdvice(accountId?: string | null): Promise<ConfigAdviceRecord | null>;
|
|
108
|
+
/** 写存档。 */
|
|
109
|
+
export declare function writeAdvice(record: ConfigAdviceRecord): Promise<ConfigAdviceRecord>;
|
|
110
|
+
/** 读最近一次失败。 */
|
|
111
|
+
export declare function readAdviceError(accountId?: string | null): Promise<ConfigAdviceError | null>;
|
|
112
|
+
/** 记一次失败(不抹掉已有存档)。 */
|
|
113
|
+
export declare function recordAdviceError(accountId: string | null | undefined, message: string): Promise<ConfigAdviceError>;
|
|
114
|
+
/** 清掉失败记录(成功后调)。 */
|
|
115
|
+
export declare function clearAdviceError(accountId?: string | null): Promise<void>;
|
|
116
|
+
//# sourceMappingURL=advice.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ConfigCapability, ConfigResourceTracesView } from './types.ts';
|
|
2
|
+
export interface TracesOptions {
|
|
3
|
+
readonly accountId: string;
|
|
4
|
+
readonly accountName?: string | null;
|
|
5
|
+
readonly resourceId: string;
|
|
6
|
+
readonly regionId: string;
|
|
7
|
+
readonly limit?: number;
|
|
8
|
+
/** 资源名(仅在没有 id 命中时用于兜底,结果会被标成 `name`)。 */
|
|
9
|
+
readonly resourceName?: string | null;
|
|
10
|
+
/** 关联对象 id(挂载它的 ECS、企业项目…),用于归因。 */
|
|
11
|
+
readonly relatedIds?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 查某个资源的云审计记录 —— **按"能认回来"的强度依次尝试**。
|
|
15
|
+
*
|
|
16
|
+
* 1. `resource_id` = 该资源(最准);
|
|
17
|
+
* 2. 记不住就退一层:用它的**关联对象**(挂载它的 ECS、它所属的企业项目)去查。
|
|
18
|
+
* 关系变更、企业项目迁移、批量改标签这类操作,云审计只把 id 记在其中一个对象上,
|
|
19
|
+
* 直接查盘是空的 —— 但"谁把那台机器迁走了"照样能查到;
|
|
20
|
+
* 3. 最后才退到按名字查,并明确标注"可能不是同一个对象"。
|
|
21
|
+
*
|
|
22
|
+
* 每一档都会在结果里带 `match`,页面必须显示出来:**猜的东西要写得像猜的**。
|
|
23
|
+
*
|
|
24
|
+
* @returns 失败时带能力状态(页面显示原因,不显示空列表)。
|
|
25
|
+
*/
|
|
26
|
+
export declare function computeResourceTraces(options: TracesOptions): Promise<{
|
|
27
|
+
view: ConfigResourceTracesView | null;
|
|
28
|
+
capability?: ConfigCapability;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=cts.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置审计的规则引擎(纯函数)。
|
|
3
|
+
*
|
|
4
|
+
* 输入是 `buildConfigFacts()` 的产物(页面左侧「审计发现」用的是同一份事实),
|
|
5
|
+
* 输出是**落到对象上的发现**:23 个账号、8 条规则、167 个不合规资源 —— 而不是
|
|
6
|
+
* "有 120 个资源待处置"这种复述。
|
|
7
|
+
*
|
|
8
|
+
* 三条硬规矩(都是从页面现有数字打架的地方反推出来的):
|
|
9
|
+
* 1. **口径必须写在脸上**。主账号 28 条规则与组织 140 条规则是两个口径,
|
|
10
|
+
* 混在一句话里就会出现"主账号 0 条、成员账号 28 条"这种错。
|
|
11
|
+
* 2. **抽样不进待办数**。治理三项取的是"最近 200 个资源",不是全量。
|
|
12
|
+
* 3. **没有判据就不下结论**。操作状态在组织视角恒为空、未覆盖账号没有合规数据,
|
|
13
|
+
* 这两类只能是"无法判定",不能算成"合规"。
|
|
14
|
+
*
|
|
15
|
+
* @module @huaweidevtools/landingzone-workbench/config/evidence/rules
|
|
16
|
+
*/
|
|
17
|
+
import { type ConfigFindingsResult } from './types.ts';
|
|
18
|
+
/** 评估参数。 */
|
|
19
|
+
export interface EvaluateOptions {
|
|
20
|
+
readonly accountId?: string | null;
|
|
21
|
+
readonly accountName?: string | null;
|
|
22
|
+
/** 组织视角用聚合器里的账号数;账号视角不知道。 */
|
|
23
|
+
readonly agencyName: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 跑规则。
|
|
27
|
+
*
|
|
28
|
+
* @param facts `buildConfigFacts()` 的产物。
|
|
29
|
+
*/
|
|
30
|
+
export declare function evaluateConfigFindings(facts: Record<string, unknown>, options: EvaluateOptions): ConfigFindingsResult;
|
|
31
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置审计「发现」的类型(**纯类型 + 常量**,浏览器与宿主共用)。
|
|
3
|
+
*
|
|
4
|
+
* 与费用侧 `cost/evidence/types.ts` 同一套思路:先把每条结论算到**具体对象**上
|
|
5
|
+
* (账号 / 规则 / 资源),再由宿主决定数字与严重度,模型只负责叙述。
|
|
6
|
+
*
|
|
7
|
+
* 为什么单独一个文件:卡片要 import 它,而采集逻辑要碰华为云接口。
|
|
8
|
+
*
|
|
9
|
+
* @module @huaweidevtools/landingzone-workbench/config/evidence/types
|
|
10
|
+
*/
|
|
11
|
+
import type { ConfigFindingTargets } from '../types.ts';
|
|
12
|
+
/** 规则编号:一条发现为什么成立。 */
|
|
13
|
+
export type ConfigFindingKind =
|
|
14
|
+
/** 组织里有账号没有任何资源数据(不在聚合器里)。 */
|
|
15
|
+
'accounts_uncovered'
|
|
16
|
+
/** 不合规资源(按账号聚,账号视角按规则聚)。 */
|
|
17
|
+
| 'non_compliant'
|
|
18
|
+
/** 账号在聚合器里,但一条合规规则都没配。 */
|
|
19
|
+
| 'no_rules'
|
|
20
|
+
/** 资源记录器没开 / 被冻结。 */
|
|
21
|
+
| 'recorder_issue'
|
|
22
|
+
/** 资源没有任何标签(抽样口径)。 */
|
|
23
|
+
| 'untagged'
|
|
24
|
+
/** 资源挂在默认企业项目(抽样口径)。 */
|
|
25
|
+
| 'default_ep'
|
|
26
|
+
/** 操作状态在组织视角恒为空。 */
|
|
27
|
+
| 'state_unavailable';
|
|
28
|
+
/**
|
|
29
|
+
* 一条发现落在哪一层 —— 决定它进不进「待办数」。
|
|
30
|
+
*
|
|
31
|
+
* 与费用页同一语义:
|
|
32
|
+
* certain 现在就能动手,结论不受数据缺口影响;
|
|
33
|
+
* needs_data 结论依赖抽样,要精确必须先补数据(或点「精确模式」);
|
|
34
|
+
* undecided 连判据都没有。
|
|
35
|
+
*/
|
|
36
|
+
export type ConfigFindingLayer = 'certain' | 'needs_data' | 'undecided';
|
|
37
|
+
/** 层的人话。 */
|
|
38
|
+
export declare const CONFIG_LAYER_LABEL: Readonly<Record<ConfigFindingLayer, string>>;
|
|
39
|
+
/** 层的优先级:能动手的在前,抽样的其次,判不了的最后。 */
|
|
40
|
+
export declare const CONFIG_LAYER_PRIORITY: readonly ConfigFindingLayer[];
|
|
41
|
+
/** 一个具体的对象(账号 / 规则 / 资源)。 */
|
|
42
|
+
export interface ConfigSubject {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly kind: 'account' | 'rule' | 'resource';
|
|
46
|
+
/** 一行现状(例如"聚合器里 0 个资源")。 */
|
|
47
|
+
readonly detail: string;
|
|
48
|
+
}
|
|
49
|
+
/** 一条发现。 */
|
|
50
|
+
export interface ConfigFinding {
|
|
51
|
+
readonly kind: ConfigFindingKind;
|
|
52
|
+
readonly layer: ConfigFindingLayer;
|
|
53
|
+
/** 引用键(模型只能引它,宿主据此回填)。 */
|
|
54
|
+
readonly ref: string;
|
|
55
|
+
readonly title: string;
|
|
56
|
+
readonly severity: 'high' | 'medium' | 'low';
|
|
57
|
+
/** 量化:`5 / 28 个账号`、`167 个资源 / 140 条规则`。 */
|
|
58
|
+
readonly measure: string;
|
|
59
|
+
/** 人话证据(含上下文数字)。 */
|
|
60
|
+
readonly evidence: string;
|
|
61
|
+
/** 口径:全量 / 抽样 N / 仅主账号 —— 不写清楚就会被当成全组织。 */
|
|
62
|
+
readonly scope_note: string;
|
|
63
|
+
/** 该做什么(含控制台路径)。 */
|
|
64
|
+
readonly action: string;
|
|
65
|
+
/** 对象标签:`账号` / `规则` / `资源`。 */
|
|
66
|
+
readonly subject_label: string;
|
|
67
|
+
readonly subject_count: number;
|
|
68
|
+
readonly subjects: readonly ConfigSubject[];
|
|
69
|
+
/**
|
|
70
|
+
* 可执行对象清单:把"772 个资源"变成"哪条规则、哪几个资源 id"。
|
|
71
|
+
*
|
|
72
|
+
* 为什么与 `subjects` 并存而不是替换:`subjects` 是粗粒度的一行(账号 / 规则 / 资源),
|
|
73
|
+
* 用于卡片标题;`targets` 是"具体该动谁",用于展开区。两者粒度不同,合并会逼着一方将就。
|
|
74
|
+
*/
|
|
75
|
+
readonly targets?: ConfigFindingTargets;
|
|
76
|
+
}
|
|
77
|
+
/** 一句宿主写的结论(卡片顶部)。 */
|
|
78
|
+
export interface ConfigHeadline {
|
|
79
|
+
readonly text: string;
|
|
80
|
+
}
|
|
81
|
+
/** 一份完整的发现结果。 */
|
|
82
|
+
export interface ConfigFindingsResult {
|
|
83
|
+
readonly generated_at: string;
|
|
84
|
+
readonly scope: 'organization' | 'account';
|
|
85
|
+
readonly account_id: string | null;
|
|
86
|
+
readonly account_name: string | null;
|
|
87
|
+
/** 宿主写的一句话结论:先讲"覆盖了谁、没覆盖谁"。 */
|
|
88
|
+
readonly headline: string;
|
|
89
|
+
readonly coverage: {
|
|
90
|
+
readonly covered: number;
|
|
91
|
+
readonly active_total: number;
|
|
92
|
+
readonly org_total: number;
|
|
93
|
+
readonly aggregator: string | null;
|
|
94
|
+
};
|
|
95
|
+
readonly findings: readonly ConfigFinding[];
|
|
96
|
+
readonly counts: Readonly<Record<ConfigFindingLayer, number>>;
|
|
97
|
+
/** 进「待办数」的条数 = certain 层。 */
|
|
98
|
+
readonly todo_count: number;
|
|
99
|
+
readonly notes: readonly string[];
|
|
100
|
+
}
|
|
101
|
+
/** 一个对象的动作说明(卡片展开用;与 finding.action 区分:这里是逐对象的)。 */
|
|
102
|
+
export declare function subjectAction(finding: ConfigFinding, subject: ConfigSubject, agencyHint: string): string;
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把 `RMS.00010006` 翻成"下一步该做什么"。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要单独一层:同一个错误码在三种情形下含义完全不同,而它们的下一步也
|
|
5
|
+
* 完全不同 ——
|
|
6
|
+
*
|
|
7
|
+
* 1. **凭据是成员账号,却去读别人的 domain**:换视角(或换凭据),加策略没用;
|
|
8
|
+
* 2. **凭据就是那个 domain,但没有 Config 只读权限**:去 IAM 加策略;
|
|
9
|
+
* 3. **凭据是管理账号,但那台环境没开聚合器委托**:去 Organizations/Config 配委托。
|
|
10
|
+
*
|
|
11
|
+
* `rms.ts` 的 `classifyRmsError` 只看到响应体,不知道"是谁在请求谁",所以它只能
|
|
12
|
+
* 给一句中性的原文。真正的判断需要调用侧的两个 domain —— 这就是本模块的输入。
|
|
13
|
+
*
|
|
14
|
+
* 这次线上看到的"主账号凭据无权读取该账号的资源"正是把 1 当成 3 的后果:用户
|
|
15
|
+
* 明明是子账号登录,却被指去查主账号的权限,于是"明明切了账号还报错"。
|
|
16
|
+
*
|
|
17
|
+
* @module @huaweidevtools/landingzone-workbench/config/failure-note
|
|
18
|
+
*/
|
|
19
|
+
import type { ConfigCapability } from './types.ts';
|
|
20
|
+
/** 调用方(当前凭据所属账号)。 */
|
|
21
|
+
export interface CallerView {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
}
|
|
25
|
+
/** 目标(这次请求想读的账号;名称可能是 null —— 聚合器只给 domain_id)。 */
|
|
26
|
+
export interface TargetView {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly name: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** 解释一次失败所需的上下文。 */
|
|
31
|
+
export interface FailureContext {
|
|
32
|
+
/** 在读什么,例如「组织资源聚合器」「该账号的资源清单」。 */
|
|
33
|
+
readonly what: string;
|
|
34
|
+
readonly caller: CallerView | null;
|
|
35
|
+
readonly target: TargetView | null;
|
|
36
|
+
}
|
|
37
|
+
/** 这条能力状态是不是"跨 domain 被拒"。 */
|
|
38
|
+
export declare function isScopeDenied(capability: ConfigCapability | undefined): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 把一个跨 domain 的拒绝改写成可执行的说明。
|
|
41
|
+
*
|
|
42
|
+
* 不改写别的失败(网络/5xx/接口未发布):那些原因在原文里已经说清楚了,
|
|
43
|
+
* 再加一层只会把真话盖住。
|
|
44
|
+
*/
|
|
45
|
+
export declare function explainFailure(capability: ConfigCapability, context: FailureContext): ConfigCapability;
|
|
46
|
+
//# sourceMappingURL=failure-note.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按**凭据指纹**分键的进程内缓存。
|
|
3
|
+
*
|
|
4
|
+
* 为什么非得分键(这是本文件存在的唯一理由):
|
|
5
|
+
*
|
|
6
|
+
* DSH 的账号 chip 换凭据不重启进程。一份不带指纹的缓存会在换凭据之后继续
|
|
7
|
+
* 命中上一份身份算出来的结论 —— 最典型的是"主账号 ID":成员凭据登录后仍拿
|
|
8
|
+
* 主账号的 domain 去发请求,于是每个请求都 403 `RMS.00010006`,而页面看起来
|
|
9
|
+
* 像是"权限没配"。费用域的账号名单已经因为同一件事踩过一次(见
|
|
10
|
+
* `cost/accounts.ts` 里 `akFingerprint` 的注释:成员凭据的 401 被缓存,
|
|
11
|
+
* 换回主账号后页面仍报"签名被拒绝"),配置域当时没跟上。
|
|
12
|
+
*
|
|
13
|
+
* 指纹本身是 AK 的 sha256 截断(不落原始 AK、不进日志),由
|
|
14
|
+
* `cost/accounts.ts` 的 `akFingerprint` 统一计算 —— 两个域用同一套口径,
|
|
15
|
+
* 就不会出现"这里认为换了、那里认为没换"。
|
|
16
|
+
*
|
|
17
|
+
* @module @huaweidevtools/landingzone-workbench/config/fingerprint-cache
|
|
18
|
+
*/
|
|
19
|
+
/** 一份按指纹分键的单条目缓存(同一时刻只保留最新指纹的值)。 */
|
|
20
|
+
export interface FingerprintCache<T> {
|
|
21
|
+
/** 指纹一致且未过期时给值;否则 undefined(当作未命中)。 */
|
|
22
|
+
readonly get: (fingerprint: string) => T | undefined;
|
|
23
|
+
/** 写入并把它当作"当前指纹"。 */
|
|
24
|
+
readonly set: (fingerprint: string, value: T) => void;
|
|
25
|
+
/** 清空(刷新按钮用;换凭据不需要它 —— 指纹不一致天然就是未命中)。 */
|
|
26
|
+
readonly clear: () => void;
|
|
27
|
+
}
|
|
28
|
+
/** 构造参数。 */
|
|
29
|
+
export interface FingerprintCacheOptions {
|
|
30
|
+
/**
|
|
31
|
+
* 有效期(毫秒)。`Number.POSITIVE_INFINITY` = 不过期(服务目录这类几乎不
|
|
32
|
+
* 随账号变、但也不能跨身份复用的映射用它)。缺省 30 分钟。
|
|
33
|
+
*/
|
|
34
|
+
readonly ttlMs?: number;
|
|
35
|
+
/** 时钟注入(只给测试用;生产走 Date.now)。 */
|
|
36
|
+
readonly now?: () => number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 建一份缓存。
|
|
40
|
+
*
|
|
41
|
+
* 只保留一条记录而不是 Map:这些缓存的值都"跟着当前身份走",同时持有多个
|
|
42
|
+
* 身份的副本没有收益,反而会让"刷新"变成一件说不清的事。
|
|
43
|
+
*/
|
|
44
|
+
export declare function createFingerprintCache<T>(options?: FingerprintCacheOptions): FingerprintCache<T>;
|
|
45
|
+
//# sourceMappingURL=fingerprint-cache.d.ts.map
|