Skip to content

o365: add fallback for missing startTime #8374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 3, 2023
Merged

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Nov 2, 2023

Proposed commit message

Improve clarity of CEL code:

  • make evaluation step clearly defined
  • remove redundant as macro use
  • use string for RFC 3339 timestamp formatting
  • use more vertical whitespace

Reduce repeated work:

  • hoist request query parsing out of struct.

Add fallback for case where request URL in response has no startTime.

Add mappings for missing fields:

  • o365.audit.AdditionalInfo
  • o365.audit.AppAccessContext

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.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

@efd6 efd6 added bug Something isn't working, use only for issues Team:Security-External Integrations Integration:o365 Microsoft Office 365 labels Nov 2, 2023
@efd6 efd6 self-assigned this Nov 2, 2023
@elasticmachine
Copy link

elasticmachine commented Nov 2, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-11-03T02:14:35.933+0000

  • Duration: 16 min 13 sec

Test stats 🧪

Test Results
Failed 0
Passed 25
Skipped 0
Total 25

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link

elasticmachine commented Nov 2, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (1/1) 💚
Files 100.0% (1/1) 💚
Classes 100.0% (1/1) 💚
Methods 100.0% (16/16) 💚 4.762
Lines 81.457% (738/906) 👎 -16.128
Conditionals 100.0% (0/0) 💚

@efd6 efd6 marked this pull request as ready for review November 2, 2023 21:31
@efd6 efd6 requested a review from a team as a code owner November 2, 2023 21:31
@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

efd6 added 5 commits November 3, 2023 08:08
* make evaluation step clearly defined
* remove redundant as macro use
* use string for RFC 3339 timestamp formatting
* use more vertical whitespace
These fields have been observed in the wild.
@efd6 efd6 changed the title o365: add fallback for missing startTimer o365: add fallback for missing startTime Nov 2, 2023
: has(reqQuery.startTime) ?
reqQuery.startTime[0]
:
string(now() - duration(state.base.list_contents_start_time))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could set the value from the cursor at this point. If that cursor value doesn't exist, then default to state.base.list_contents_start_time

So, something like this:

                                          reqQuery.endTime[0]
                                      : has(reqQuery.startTime) ?
                                          reqQuery.startTime[0]
                                      : has (state.cursor.content_types_state_as_list.filter(e, e.content_type == content_type)[0].content_created_at) ?
                                          state.cursor.content_types_state_as_list.filter(e, e.content_type == content_type)[0].content_created_at
                                      : 
                                          string(now() - duration(state.base.list_contents_start_time))

Copy link
Contributor Author

@efd6 efd6 Nov 3, 2023

Choose a reason for hiding this comment

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

Done. It's a pity the filter needs to be evaluated twice; I don't see a way to avoid this. However, I've got a change in mito that will allow us to use optional types and then this will be doable, along with not having to say has(x) && has(x.y) && has(x.y.z) && x.y.z == "foo", instead just x.?y.?z == "foo".

@efd6 efd6 requested a review from kcreddy November 3, 2023 02:21
Copy link
Contributor

@kcreddy kcreddy left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM 👍🏼

@efd6 efd6 merged commit 7d1faf9 into elastic:main Nov 3, 2023
@elasticmachine
Copy link

Package o365 - 1.25.1 containing this change is available at https://epr.elastic.co/search?package=o365

1 similar comment
@elasticmachine
Copy link

Package o365 - 1.25.1 containing this change is available at https://epr.elastic.co/search?package=o365

@efd6 efd6 deleted the s4002-o365 branch February 5, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, use only for issues Integration:o365 Microsoft Office 365
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants