imperva_cloud_waf: fix CEL type guard for events field access - #19013
Conversation
|
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations) |
4c3db41 to
51a2f08
Compare
chrisberkhout
left a comment
There was a problem hiding this comment.
The commit message seems to contradict itself:
On the success path events is always a list, so the check is normally safe.
However, when ..., v.events can be a list at the point of the guard.
The change of checking the type of the events makes sense.
| } | ||
| ) | ||
| ).as(v, has(v.?events.error) ? | ||
| ).as(v, has(v.?events) && type(v.events) == map && has(v.?events.error) ? |
There was a problem hiding this comment.
I think the optional syntax is redundant. Checking field presence should be enough.
| ).as(v, has(v.?events) && type(v.events) == map && has(v.?events.error) ? | |
| ).as(v, has(v.events) && type(v.events) == map && has(v.events.error) ? |
There was a problem hiding this comment.
I think (tested) this test can be reduced to type(v.?events.orValue(null)) == map; if it's absent, the type is null, if it present then the type gets made concrete and we can compare to the literal type.
This comment has been minimized.
This comment has been minimized.
TL;DR
Remediation
Investigation detailsRoot CauseThe sample event was changed to:
with:
Static validation rejects those fields for this package/event. Evidence
Source: Verification
Follow-upAfter updating Note 🔒 Integrity filter blocked 2 itemsThe following items were blocked because they don't meet the GitHub integrity level.
To allow these resources, lower tools:
github:
min-integrity: approved # merged | approved | unapproved | noneWhat is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
chrisberkhout
left a comment
There was a problem hiding this comment.
CEL change looks good.
For a second I wondered if I was wrong about removing the optional syntax on the latter part of the condition, but that seems fine:
mito -data <(echo '{"events": []}') <(echo 'type(state.?events.orValue(null)) == map && has(state.events.error)')
mito -data <(echo '{"events": {"error": {}}}') <(echo 'type(state.?events.orValue(null)) == map && has(state.events.error)')
mito -data <(echo '{"events": null}') <(echo 'type(state.?events.orValue(null)) == map && has(state.events.error)')
false
true
false
The build error is:
test case failed: one or more errors found in document: [0] field "source.geo.location.coordinates" is undefined, could be a multifield
[1] field "source.geo.location.type" is undefined, could be a multifield
Thanks for checking, exactly, regenerating |
💚 Build Succeeded
History
|
|
Package imperva_cloud_waf - 1.13.2 containing this change is available at https://epr.elastic.co/package/imperva_cloud_waf/1.13.2/ |
…c#19013) imperva_cloud_waf: fix CEL type guard for events field access The guard has(v.?events.error) at the outer .as(v, ...) expression is intended to detect error responses, where events is a map {"error": {...}}. When the worklist has multiple entries, the worklist-continuation branch returns state wholesale, carrying the previous iteration's list-valued events into v. CEL then attempts string-key field access (.error) on that list and throws "unsupported index type 'string' in list", cycling the input unit HEALTHY→DEGRADED on every poll and halting ingestion entirely. This is triggered in practice when the Imperva API delivers non-WAF event types (e.g. Client-Side Protection SIEM events) alongside WAF logs through the same endpoint, as the additional log volume increases the likelihood of a multi-file worklist. Add an explicit type check before the field access so that .error is only accessed when v.events is actually a map.
Proposed commit message
Checklist
changelog.ymlfile.