Skip to content

Conversation

@ShourieG
Copy link
Contributor

@ShourieG ShourieG commented Oct 4, 2024

Type of change

Please label this PR with one of the following labels, depending on the scope of your change:

  • Bug

Proposed commit message

  • WHAT: Added guardrails to various array accessors to prevent out-of-bounds errors and cleaned up some existing code .
  • WHY: Users were experiencing array out of bounds error while running the integration.

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

@ShourieG ShourieG added integration Label used for meta issues tracking each integration Integration:o365 Microsoft Office 365 bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Oct 4, 2024
@ShourieG ShourieG self-assigned this Oct 4, 2024
@ShourieG ShourieG marked this pull request as ready for review October 4, 2024 11:21
@ShourieG ShourieG requested a review from a team as a code owner October 4, 2024 11:21
@elasticmachine
Copy link

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

@ShourieG ShourieG requested a review from efd6 October 4, 2024 11:21
@ShourieG
Copy link
Contributor Author

ShourieG commented Oct 4, 2024

@kcreddy, addressed all the comments

@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

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.

There are also few more cases where arrays indices are being used, which could have checks:
content_type_state[0]
.filter(e, e.content_type == content_type)[0]

@ShourieG
Copy link
Contributor Author

ShourieG commented Oct 4, 2024

@kcreddy, I noticed that content_type_state already has a size check in place before entering the block, do we need another one here ?

@kcreddy
Copy link
Contributor

kcreddy commented Oct 7, 2024

@kcreddy, I noticed that content_type_state already has a size check in place before entering the block, do we need another one here ?

Don't think there is a check here: https://github.com/elastic/integrations/blob/main/packages/o365/data_stream/audit/agent/stream/cel.yml.hbs#L97

Also I think the issue with SDH is no check on .filter(e, e.content_type == content_type)[0] because the response state ended up with all of same content_type for some reason.

@ShourieG
Copy link
Contributor Author

ShourieG commented Oct 8, 2024

@kcreddy, I've added further checks as suggested

@ShourieG
Copy link
Contributor Author

ShourieG commented Oct 9, 2024

@efd6, addressed all PR suggestions

@ShourieG
Copy link
Contributor Author

@efd6, I've removed the extra spaces, if all looks good atm, could you approve ?

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

Some time soon, this should be refactored to remove the embedded handlebars templating that's in the CEL code and then be properly formatted.

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @ShourieG

@elastic-sonarqube
Copy link

@ShourieG ShourieG merged commit 2bf71d1 into elastic:main Oct 14, 2024
3 checks passed
@ShourieG ShourieG deleted the bugfix/o365 branch October 14, 2024 06:48
@elastic-vault-github-plugin-prod

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

harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
… prevent out-of-bounds errors and cleaned up some existing code (elastic#11329)

* Added guardrails to various array accessors to prevent out-of-bounds errors and cleaned up some existing code.

* updated changelog

* updated with PR suggestions

* added further array checks as suggested

* addressed PR suggestions

* removed additional spaces

* removed additional spaces
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
… prevent out-of-bounds errors and cleaned up some existing code (elastic#11329)

* Added guardrails to various array accessors to prevent out-of-bounds errors and cleaned up some existing code.

* updated changelog

* updated with PR suggestions

* added further array checks as suggested

* addressed PR suggestions

* removed additional spaces

* removed additional spaces
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:o365 Microsoft Office 365 integration Label used for meta issues tracking each integration Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants