[Cisco Duo] - Added fix for 400 and 401 errors in telephony v2 data stream - #11640
Conversation
|
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations) |
🚀 Benchmarks reportTo see the full report comment with |
| "maxtime": (int(now - duration("2m"))).as(mx, | ||
| mx < int(timestamp(int(state.mintime) / 1000) + duration("4320h")) ? string(mx * 1000) : string(int(timestamp(int(state.mintime) / 1000) + duration("4320h") - duration("2m")) * 1000) | ||
| ) |
There was a problem hiding this comment.
| "maxtime": (int(now - duration("2m"))).as(mx, | |
| mx < int(timestamp(int(state.mintime) / 1000) + duration("4320h")) ? string(mx * 1000) : string(int(timestamp(int(state.mintime) / 1000) + duration("4320h") - duration("2m")) * 1000) | |
| ) | |
| "maxtime":int(now - duration("2m"))).as(mx, | |
| mx < int(timestamp(state.mintime / 1000) + duration("4320h")) ? | |
| mx | |
| : | |
| int(timestamp(state.mintime / 1000) + duration("4320h") - duration("2m")) | |
| ) * 1000 |
Why is the 2m subtracted from the false branch?
There was a problem hiding this comment.
Since this PR is same as #11621, I am also addressing the comments.
@ShourieG, please make similar change if @efd6 agrees to the changes.
Why is the 2m subtracted from the false branch?
Makes sense. Addressed in edcac5a.
Did not remove the string( conversion due to reasons in #11640 (comment)
| @@ -31,114 +31,108 @@ program: | | |||
| state | |||
There was a problem hiding this comment.
What happens with the calculation below when this path is taken? I don't see a place where this would have mintime, but it's expected below. what am I missing?
There was a problem hiding this comment.
In the case of want_more: true i.e., pagination requests, since we are wrapping the state using .with, it should already contain the mintime from its non-pagination request.
| "mintime": state.?cursor.last_published.orValue(int(now - duration(state.initial_interval)) * 1000), | ||
| "maxtime": int(now - duration("2m")) * 1000, | ||
| "date": now.format(time_layout.RFC1123Z), | ||
| "mintime": string(state.?cursor.last_published.orValue(int(now - duration(state.initial_interval)) * 1000)), |
There was a problem hiding this comment.
| "mintime": string(state.?cursor.last_published.orValue(int(now - duration(state.initial_interval)) * 1000)), | |
| "mintime": state.?cursor.last_published.orValue(int(now - duration(state.initial_interval)) * 1000), |
There was a problem hiding this comment.
When string( is removed from state's mintime and maxtime, CEL gives compile time errors: failed to check program: failed compilation: ERROR: <input>:24:41: found no matching overload for 'trim_right' applied to 'int.(string)'\n | \"url_base\": state.url.trim_right(\"/\"),\n | ........................................^\nERROR: <input>:38:35: found no matching overload for '_+_' applied to '(int, string)'\n | state.integration_key + \":\" + (\n | ..................................^\nERROR: <input>:46:36: found no matching overload for 'bytes' applied to '(int)'\n | .hmac(\"sha1\", bytes(state.secret_key))\n | ...................................^ accessing config.
Essentially, I think whatever is the first value getting assigned inside state (in this case mintime) should be of type string. If not, the rest of the values, such as url, integration_key, etc. are also being treated as the datatype of first assigned value (in this case int). Not sure if this is because of adding dyn(in few places, because it wasn't the issue in current version of the code (which usesmintimeandmaxtimeasint`).
|
@chrisberkhout, I've updated the PR with suggestions made here: #11621 |
Thanks. Let's wait for that one to merge and then I'll take a final look at this one. |
💚 Build Succeeded
History
cc @ShourieG |
|
|
@chrisberkhout, could you take a final look at the PR since @kcreddy's PR has now been merged |
|
Package cisco_duo - 2.2.2 containing this change is available at https://epr.elastic.co/search?package=cisco_duo |
…tream (elastic#11640) * added fix in telephony_v2 data stream for 400 & 401 errors
…stic#12492) In an earlier version of the CEL code for `activity`[1] and `telephony_v2`[2], `cursor.last_published` was set to a UNIX timestamp value. This was changed to use RFC3339 formatted times in later PRs[3][4] (with the corresponding read-time parsing added in [5]). Users who didn't create a new policy may have the current parsing logic fail when it encounters an old UNIX timestamp value in `cursor.last_published`. This PR addresses that issue by renaming `cursor.last_published` to `cursor.last_response_ts`. That effectively clears the cursor so that obsolete values will not be seen. [1]: https://github.com/elastic/integrations/blob/2ea993/packages/cisco_duo/data_stream/activity/agent/stream/cel.yml.hbs#L111-L114 [2]: https://github.com/elastic/integrations/blob/2ea993/packages/cisco_duo/data_stream/telephony_v2/agent/stream/cel.yml.hbs#L112-L115 [3]: elastic#11640 [4]: elastic#11670 [5]: elastic#11772
…tream (elastic#11640) * added fix in telephony_v2 data stream for 400 & 401 errors
…stic#12492) In an earlier version of the CEL code for `activity`[1] and `telephony_v2`[2], `cursor.last_published` was set to a UNIX timestamp value. This was changed to use RFC3339 formatted times in later PRs[3][4] (with the corresponding read-time parsing added in [5]). Users who didn't create a new policy may have the current parsing logic fail when it encounters an old UNIX timestamp value in `cursor.last_published`. This PR addresses that issue by renaming `cursor.last_published` to `cursor.last_response_ts`. That effectively clears the cursor so that obsolete values will not be seen. [1]: https://github.com/elastic/integrations/blob/2ea993/packages/cisco_duo/data_stream/activity/agent/stream/cel.yml.hbs#L111-L114 [2]: https://github.com/elastic/integrations/blob/2ea993/packages/cisco_duo/data_stream/telephony_v2/agent/stream/cel.yml.hbs#L112-L115 [3]: elastic#11640 [4]: elastic#11670 [5]: elastic#11772




Type of change
Proposed commit message
Cisco API documentation mentions that the
Dateheader should be equal to the current timestamp. In the current CEL program, the previous execution'sstate.dateis being captured and used in pagination and subsequent requests leading to possible40103errors. In a related issue users also observed the error400:mintime must be within the past 180 days.This PR:
40103by creatingDateheader during each CEL request.400error by checkingdurationbetweenmintimeandmaxtimedoesn't cross180d, based on a similar issue & PR.Note:
2.2.0to2.2.2because this will only be merged after the PR mentioned above ismerged, and that already increments the version to
2.2.1.Checklist
changelog.ymlfile.Author's Checklist
How to test this PR locally
Related issues
Screenshots