fix(iwooos): correlate canonical ansible candidates

This commit is contained in:
ogt
2026-07-15 11:36:38 +08:00
parent 5a12ff535c
commit 849b0c6d23
2 changed files with 22 additions and 1 deletions

View File

@@ -1959,7 +1959,25 @@ class IwoooSSecurityAssetControlPlaneService:
NULLIF(route.incident_id::text, ''),
NULLIF(route.input ->> 'incident_id', '')
) IS NOT NULL
AND NULLIF(route.input ->> 'catalog_id', '') IS NOT NULL)
AND (
NULLIF(route.input ->> 'catalog_id', '') IS NOT NULL
OR EXISTS (
SELECT 1
FROM jsonb_array_elements(
CASE
WHEN jsonb_typeof(
route.input -> 'executor_candidates'
) = 'array'
THEN route.input -> 'executor_candidates'
ELSE '[]'::jsonb
END
) candidate(candidate_payload)
WHERE NULLIF(
candidate.candidate_payload ->> 'catalog_id',
''
) IS NOT NULL
)
))
AS correlated_controlled_route_count_24h,
(SELECT count(*) FROM incident_evidence verifier
WHERE verifier.collected_at >= NOW() - INTERVAL '24 hours'

View File

@@ -744,6 +744,9 @@ def test_service_bounds_source_concurrency_for_database_budget(monkeypatch) -> N
)
assert "correlated_controlled_route_count_24h" in siem_query
assert "ansible_candidate_matched" in siem_query
assert "jsonb_array_elements" in siem_query
assert "executor_candidates" in siem_query
assert "candidate_payload ->> 'catalog_id'" in siem_query
assert "independent_verifier_pass_count_24h" in siem_query
assert "all_postconditions_passed" in siem_query
assert "executor_returncode_trusted" in siem_query