mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-09-04 14:45:41 +00:00
feat(security): gate deploys on exploitation risk, not just severity (#1432)
Scan-policy deploy gates can now block on a known-exploited CVE (CISA KEV) and on a fixable Critical/High finding, in addition to an optional severity threshold. New policies default risk-first (KEV and fixable on, severity off); existing policies keep their severity-only behavior. CVSS stays captured for context but is never the sole basis for a block, and a finding whose exploitability cannot be confirmed is treated as risky rather than safe (incomplete scan detail fails closed on KEV/fixable inputs). The decision logic is shared between the pre-deploy gate and the informational post-scan banner via a pure helper, so the two never disagree. Block messages and the block dialog now name the conditions an image matched. Backend and frontend gates move together, the new inputs replicate across the fleet, and a blocking policy with no active input is rejected on both sides.
This commit is contained in:
@@ -420,6 +420,33 @@ describe('POST /api/fleet/sync/:resource stack_pattern ReDoS guard', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/fleet/sync/scan_policies risk-input validation', () => {
|
||||
const pushRows = (row: Record<string, unknown>) =>
|
||||
request(app)
|
||||
.post('/api/fleet/sync/scan_policies')
|
||||
.set('Authorization', nodeProxyAuthHeader)
|
||||
.send({ rows: [{ name: 'p', node_identity: '', stack_pattern: null, max_severity: 'CRITICAL', enabled: 1, ...row }] });
|
||||
|
||||
it('rejects a non-0/1 risk-input value', async () => {
|
||||
const res = await pushRows({ block_on_deploy: 1, block_on_kev: 2 });
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body.error).toMatch(/block_on_kev must be 0 or 1/);
|
||||
});
|
||||
|
||||
it('rejects a blocking policy with every input off', async () => {
|
||||
const res = await pushRows({ block_on_deploy: 1, block_on_severity: 0, block_on_kev: 0, block_on_fixable: 0 });
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body.error).toMatch(/at least one/i);
|
||||
});
|
||||
|
||||
it('passes validation for a legacy row that omits the risk-input fields', async () => {
|
||||
// A field-less blocking row defaults to severity-only and must not be
|
||||
// rejected by the new cross-field guard (the back-compat contract).
|
||||
const res = await pushRows({ block_on_deploy: 1 });
|
||||
expect(res.body.error ?? '').not.toMatch(/at least one|must be 0 or 1/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/fleet/role/demote', () => {
|
||||
it('returns 401 without auth', async () => {
|
||||
const res = await request(app).post('/api/fleet/role/demote').send({ confirm: true });
|
||||
|
||||
Reference in New Issue
Block a user