mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 07:36:40 +00:00
fix: name matched risk inputs in policy block messages (#1471)
The auto-update, bulk-label, scheduler, and blueprint deploy block messages hardcoded "image(s) exceed <max_severity>", which is wrong under the risk-first policy model: a block can be driven by a known-exploited (KEV) or fixable Critical/High input while the severity threshold was never the trigger. In those cases the message named a severity ceiling the policy did not enforce. Route all four message paths through a shared summarizeBlockReasons helper (the same reason text the deploy-gate 409 response and the block dialog already use), so every surface names the inputs that actually matched. Falls back to a generic phrase when no reason was recorded.
This commit is contained in:
@@ -107,6 +107,24 @@ export function describeReason(reason: PolicyBlockReason): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* De-duplicated, human-readable summary of the inputs that actually matched
|
||||
* across a set of policy violations, joined with " + ". Used wherever a policy
|
||||
* block is reported to a user (the gate's 409 response, thrown gate errors, and
|
||||
* the deploy/auto-update block messages), so a KEV- or fixable-driven block
|
||||
* never reads as a severity-threshold block. Falls back to a generic phrase
|
||||
* when no reason was recorded (e.g. an image that could not be scanned).
|
||||
*/
|
||||
export function summarizeBlockReasons(
|
||||
violations: ReadonlyArray<{ reasons: readonly PolicyBlockReason[] }>,
|
||||
): string {
|
||||
const labels = new Set<string>();
|
||||
for (const v of violations) {
|
||||
for (const r of v.reasons) labels.add(describeReason(r));
|
||||
}
|
||||
return labels.size > 0 ? [...labels].join(' + ') : 'scan policy conditions';
|
||||
}
|
||||
|
||||
/** Compact descriptor of a policy's active inputs, for log and audit lines. */
|
||||
export function describePolicyInputs(inputs: PolicyRiskInputs): string {
|
||||
const parts: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user