Skip to content

Cloudtrail add actor and target #12685

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 10 commits into from
Mar 28, 2025

Conversation

romulets
Copy link
Member

This is a re-open of #11245, that had to be closed because a full commit history rewrite in the integration main.

Background

Elastic Cloud Security Team has been focusing, this past year, on Cloud Detection and Response (CDR). One of the first steps towards the CDR vision is to enhance investigation workflows for the Cloud Security use-case in SIEM.

As part of enhancing investigation workflows it's necessary to be able to correlate events and entities. Meaning, if an alert is triggered on the ec2 instance i-000000000, it is of great value to easily be able to search all the events related to that entity, across multiple indices, with one query. Therefore we are working on extracting entities and enabling them to be correlated.

What is an entity?

An "entity" in our context refers to any discrete component within an IT environment that can be uniquely identified and monitored. This broad term encompasses both managed and unmanaged elements.

The term "entity" is broader than the current set of available fields under related. Although ip, user and hosts can be identities, there is a lack of space to represent messaging queues, load balancers, storage systems, databases and others. Therefore the proposal to add a new field.

The proposed structure

There are two fields being added on this PR:

  • actor.entity.id captures entities that started the event, the actors
  • target.entity.id captures entities that were affected by the event. Being that created, updated, listed. We try to do as much as possible with the data present in the event.

Decisions made on the Painless Script

Structure

The painless script turned very large. There are essentially three parts to it:

  • Definition of helper functions. They are meant to facilitate the handling of the collections (related, actor and target).
  • Definition of enriching functions per AWS service. Even though there is no defined structure to requestParameters and repsonseElements, there is, usually a somewhat coherent structure per AWS service. I believe such separation brings better reading, creates a better headspace once working in a specific service and also breaks down the huge if else chain present in the previous state of the code
  • Calling functions and setting fields.

Why TreeSet as datastructure to hold related, actor, target.

There are two properties that this script must have:

  • Values must be unique
  • Values must be sorted (for testability and consistency on production)

Previously I had ensured both properties on "post processing", at the end of the script. Now it's ensured by the data structure itself.

I have not performance tested myself, but the usage of TreeSet should improve the time complexity of the algorithm, since we sort data on add, and previously we had to sort afterwards. I couldn't find a reliable source for time complexity of TreeSet.add vs Collections.sort - and honestly, the size of the list is so small that might not even matter.

Amount of tests

The testing was essential to me to validate what I was doing, to verify each output. And I would like to keep the tests for future reference and ensuring we are not changing anything by mistake. But the tests are starting to get slow. Specially if you compare with other integrations, such as okta.

@romulets romulets requested a review from a team as a code owner February 10, 2025 12:25
@romulets romulets requested review from a team as code owners February 27, 2025 07:44
@romulets romulets force-pushed the cloudtrail-add-origin-and-target branch 2 times, most recently from 7d7e716 to d73751c Compare February 28, 2025 10:37
@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

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.

Approving change in packages/aws/docs/cloudtrail.md as codeowner.

@romulets romulets linked an issue Mar 7, 2025 that may be closed by this pull request
@romulets romulets requested a review from andrewkroh March 12, 2025 13:52
Copy link

@andrewkroh andrewkroh added Integration:aws AWS Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations] labels Mar 13, 2025
@agithomas
Copy link
Contributor

For the pipeline segment, do you still want to keep it? This may be irrelevant following the change mentioned here. Please re-check

@elasticmachine
Copy link

elasticmachine commented Mar 25, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

History

Copy link
Contributor

@agithomas agithomas left a comment

Choose a reason for hiding this comment

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

LGTM!

@romulets romulets merged commit 23044d9 into elastic:main Mar 28, 2025
5 checks passed
@elastic-vault-github-plugin-prod

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

flexitrev pushed a commit that referenced this pull request Mar 28, 2025
* Add Cloudtrail Actor and Target

* Update toggle description

* Fix accountId typo

* Add versioning

* Fix ec2 events without complete response elements

* Improve error handling

* Improve error handling (add tag to the document on error)

* Use onBehalfOf in case of arn is not available in the user identity section

* Bump manifest version
flexitrev pushed a commit that referenced this pull request Mar 28, 2025
* Add Cloudtrail Actor and Target

* Update toggle description

* Fix accountId typo

* Add versioning

* Fix ec2 events without complete response elements

* Improve error handling

* Improve error handling (add tag to the document on error)

* Use onBehalfOf in case of arn is not available in the user identity section

* Bump manifest version
flexitrev added a commit that referenced this pull request Mar 28, 2025
* Add Cloudtrail Actor and Target

* Update toggle description

* Fix accountId typo

* Add versioning

* Fix ec2 events without complete response elements

* Improve error handling

* Improve error handling (add tag to the document on error)

* Use onBehalfOf in case of arn is not available in the user identity section

* Bump manifest version

<!-- Type of change
Please label this PR with one of the following labels, depending on the scope of your change:
- Bug
- Enhancement
- Breaking change
- Deprecation
-->

## Proposed commit message

<!-- Mandatory
Explain here the changes you made on the PR.

Please explain:

- WHAT: patterns used, algorithms implemented, design architecture, message processing, etc.
- WHY:  the rationale/motivation for the changes

This text will be pasted into the squash dialog when the change is committed and will be
a long term historical record of the change to help future contributors understand the
change, please help them by making it clear and comprehensive, they may be you.

If the commit title is adequate to describe both of these things, The text here may be omitted
or replaced with "See title". The title of the PR will be used as the commit message title when
the merge is made and the "See title" marker will be removed if present.

The text here and the PR title will be subject to the PR review process.
-->

## Checklist

- [ ] I have reviewed [tips for building integrations](https://github.com/elastic/integrations/blob/main/docs/tips_for_building_integrations.md) 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](https://github.com/elastic/elastic-package/blob/master/docs/howto/stack_version_support.md#when-to-update-the-condition).
- [ ] I have verified that any added dashboard complies with Kibana's [Dashboard good practices](https://docs.elastic.dev/ux-guidelines/data-viz/dashboard-good-practices)

## Author's Checklist

<!-- Recommended
Add a checklist of things that are required to be reviewed in order to have the PR approved
-->
- [ ]

## How to test this PR locally

<!-- Recommended
Explain here how this PR will be tested by the reviewer: commands, dependencies, steps, etc.
-->

## Related issues

<!-- Recommended
Link related issues below. Insert the issue link or reference after the word "Closes" if merging this should automatically close it.

- Closes #123
- Relates #123
- Requires #123
- Supersedes #123
-->
-

## Screenshots

<!-- Optional
Add here screenshots presenting:
- Kibana UI forms presenting configuration options exposed by the integration
- dashboards with collected metrics or logs
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Integration:aws AWS Team:Obs-InfraObs Observability Infrastructure Monitoring team [elastic/obs-infraobs-integrations]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aws.cloudtrail]: Failure executing script to set 'related.entity'
5 participants