Skip to content

cisco_duo: fix 400 and 401 errors in Auth and Activity - #11670

Merged
chemamartinez merged 8 commits into
elastic:mainfrom
chemamartinez:cisco_duo-auth-activity-fixes
Nov 13, 2024
Merged

cisco_duo: fix 400 and 401 errors in Auth and Activity#11670
chemamartinez merged 8 commits into
elastic:mainfrom
chemamartinez:cisco_duo-auth-activity-fixes

Conversation

@chemamartinez

Copy link
Copy Markdown
Contributor

Proposed commit message

Cisco API documentation mentions that the Date header should be equal to the current timestamp. In the current CEL program, the previous execution's state.date is being captured and used in pagination and subsequent requests leading to possible 40103 errors. In a related issue users also observed the error 400: mintime must be within the past 180 days.

This PR:

  • For Auth and Activity, fixes 40103 by creating Date header during each CEL request.
  • For Auth and Activity, preemptively fixes the 400 error by checking duration between mintime and maxtime doesn't cross
    180d.
  • For Auth, enable it by default to avoid it getting disabled during upgrades.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Related issues

@chemamartinez chemamartinez added Integration:cisco_duo Cisco Duo bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Nov 8, 2024
@chemamartinez chemamartinez self-assigned this Nov 8, 2024
@chemamartinez
chemamartinez marked this pull request as ready for review November 8, 2024 09:25
@chemamartinez
chemamartinez requested a review from a team as a code owner November 8, 2024 09:25
@elasticmachine

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@chrisberkhout chrisberkhout left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after merge of #11640

Comment thread packages/cisco_duo/data_stream/activity/agent/stream/cel.yml.hbs Outdated
Comment on lines +38 to +41
string(int([
int(timestamp(int(state.mintime)/1000) + duration("4320h")),
int(now - duration("2m"))
].min()) * 1000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allocates an ephemeral array. Ideally we would not need to do this, but the expansion of code that would be required to not do this I think, on balance, would be worse. Maybe we need a min(a, b)/max(a, b) as well as the overloads that we currently have.

Comment thread packages/cisco_duo/data_stream/auth/agent/stream/cel.yml.hbs Outdated
@chemamartinez
chemamartinez requested a review from efd6 November 11, 2024 10:44
@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @chemamartinez

@chemamartinez
chemamartinez merged commit 3f7fbd6 into elastic:main Nov 13, 2024
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package cisco_duo - 2.2.3 containing this change is available at https://epr.elastic.co/package/cisco_duo/2.2.3/

harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
- For Auth and Activity, fixes 40103 by creating Date header during each CEL request.
- For Auth and Activity, preemptively fixes the 400 error by checking duration between mintime and maxtime doesn't cross
180d.
- For Auth, enable it by default to avoid it getting disabled during upgrades.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
…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
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
- For Auth and Activity, fixes 40103 by creating Date header during each CEL request.
- For Auth and Activity, preemptively fixes the 400 error by checking duration between mintime and maxtime doesn't cross
180d.
- For Auth, enable it by default to avoid it getting disabled during upgrades.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
…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
@chemamartinez
chemamartinez deleted the cisco_duo-auth-activity-fixes branch February 6, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:cisco_duo Cisco Duo Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

4 participants