[imperva_cloud_waf] Tolerate no separator in log files - #12497
Conversation
|
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations) |
🚀 Benchmarks reportTo see the full report comment with |
💚 Build Succeeded
|
|
|
Package imperva_cloud_waf - 1.5.1 containing this change is available at https://epr.elastic.co/package/imperva_cloud_waf/1.5.1/ |
efd6
left a comment
There was a problem hiding this comment.
Do we have a test instance for this (or a repro for the bug)?
I'd like to test this alternative:
diff --git a/packages/imperva_cloud_waf/data_stream/event/agent/stream/cel.yml.hbs b/packages/imperva_cloud_waf/data_stream/event/agent/stream/cel.yml.hbs
index b41d294a5d..fea7c770b0 100644
--- a/packages/imperva_cloud_waf/data_stream/event/agent/stream/cel.yml.hbs
+++ b/packages/imperva_cloud_waf/data_stream/event/agent/stream/cel.yml.hbs
@@ -30,7 +30,7 @@ program: |
"worklist": (
has(state.cursor) && has(state.cursor.log_file) && state.cursor.log_file != null
?
- string(body).split(state.cursor.log_file)[1].split("\n").filter(x,x!="").map(x,{"filename":x})
+ string(body).split(state.cursor.log_file)[1].split("\n").map(x,x!="",{"filename":x})
:
string(body).split("\n").map(x,{"filename":x})
),
@@ -45,7 +45,9 @@ program: |
"Authorization": ["Basic "+string(base64(state.user + ":" + state.password))],
}
}).do_request().as(resp, bytes(resp.Body).as(body, {
- "events": string(body).split("|==|")[1].split("\n").filter(x,x!="").map(x,{"message":x}),
+ "events": string(body).as(body,
+ body.split("|==|")[?1].orValue(body).split("\n").map(x,x!="",{"message":x})
+ ),
"cursor": {
"log_file": (
has(state.cursor) && has(state.cursor.log_file) && state.cursor.log_file != null
It could be tested with the system test by modifying the response data to have only the header (removing the separator and data lines), then asserting it runs error-free and returns no events. We don't have the data from the live system, just the error message. Based on the code I think that the failed access of index Your version looks nicer, except that the |
We currently have no system test. So I don't think this is possible this way, though I can temporarily set up a CEL input test.
You are right. |
Make the CEL program tolerate log files that don't contain a
header/events separator (`|==|`).
The existing CEL program can fail with the error:
failed evaluation: failed eval: ERROR: <input>:19:35: index out of
bounds: 1 | ).as(v, v.next < size(v.worklist) ? |.................
.................^
With this change, it will not fail, but no events will be returned.
Make the CEL program tolerate log files that don't contain a
header/events separator (`|==|`).
The existing CEL program can fail with the error:
failed evaluation: failed eval: ERROR: <input>:19:35: index out of
bounds: 1 | ).as(v, v.next < size(v.worklist) ? |.................
.................^
With this change, it will not fail, but no events will be returned.




Proposed commit message
Discussion
The observed error is for the index
1. The use ofv.worklist[v.next]will never cause that, because those uses are all surrounded by the conditionv.next < size(v.worklist), so it must be the access followingsplit("|==|").Log file structure documentation.
Checklist
changelog.ymlfile.Screenshots
Here's a screenshot showing the problem: