Skip to content
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

[Security Solution][Resolver] Handle disabled process collection #73592

Conversation

jonathan-buttner
Copy link
Contributor

@jonathan-buttner jonathan-buttner commented Jul 29, 2020

This PR allows resolver to gracefully handle events sent by the endpoint that do not have process.entity_id defined or it is set to an empty string.

Notable changes:

  • The backend will return a bad request if the entity_id is an empty string in the API requests
  • The resolver icon will only show if process.entity_id exists on the document and it is not an empty string
  • The backend only retrieves documents that have a non-empty string for entity_id
  • The backend removes any entity_ids in the queries that are empty strings

entity_id is an empty string
image

entity_id exists and is not an empty string
image

@jonathan-buttner jonathan-buttner added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Endpoint Data Visibility Team managing the endpoint resolver Feature:Endpoint Elastic Endpoint feature v7.9.0 labels Jul 29, 2020
@jonathan-buttner jonathan-buttner requested review from a team as code owners July 29, 2020 00:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-data-visibility-team (Team:Endpoint Data Visibility)

@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-app-team (Feature:Endpoint)

});

it('returns false if process.entity_id is an empty array', () => {
const data: Ecs = { _id: '1', agent: { type: ['endpoint'] } };
Copy link
Contributor

Choose a reason for hiding this comment

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

fyi, this is missing the empty array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks. I actually check that case below. Must be an accidental copy paste. I'll remove it.

});

it('excludes events that have an empty entity_id field', async () => {
// first lets get the _id of the document using the parent.process.entity_id
Copy link
Contributor

Choose a reason for hiding this comment

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

nothing to block over, but can't you set _id when you insert a document?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point. I'm using a helper function that inserts an array of documents so it's doing a bulk request. Later we can refactor it so it specifies the _id of the document so we don't have to do the search.

before(async () => {
// construct a tree with an origin and two direct children. One child will not have an entity_id. That child
// should not be returned by the backend.
origin = generator.generateEvent({ entityID: 'a' });
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add tests of this kind to the UI too eventually

ancestor2 = generator.generateEvent({
entityID: '2',
});
ancestor1 = generator.generateEvent({
Copy link
Contributor

Choose a reason for hiding this comment

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

having trouble following what ancestor1 is for. but i'm tired. maybe you can explain it to me next week :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it was more of a sanity check. The origin node in that test has its process.parent.entity_id set to ancestor1's process.entity_id, but the backend should be using the ancestry array to determine the ancestors if it exists. So since ancestor1 was not returned in the request we can be assured that the backend is properly using the ancestry array.

origin = generator.generateEvent({
entityID: 'a',
parentEntityID: ancestor1.process.entity_id,
ancestry: ['', ancestor2.process.entity_id],
Copy link
Contributor

Choose a reason for hiding this comment

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

you could just make the first one here ancestorNoEntityID.process.entity_id too. Took me a sec to figure that's what was being referenced. Nothing to restart CI over though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point. I added that late. I wanted to make sure that the backend wouldn't return the event even if ES actually did have a document with entity_id as an empty string

@jonathan-buttner
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
securitySolution 7.3MB +97.0B 7.3MB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jonathan-buttner jonathan-buttner merged commit 41c2967 into elastic:master Jul 29, 2020
@jonathan-buttner jonathan-buttner deleted the handle-disabled-process-collection-v2 branch July 29, 2020 04:01
jonathan-buttner added a commit to jonathan-buttner/kibana that referenced this pull request Jul 29, 2020
…stic#73592)

* Handling entity ids of empty string

* Tests for entity id being empty

* More comments

* entity test

* Renaming interface

* Removing unneeded test

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jonathan-buttner added a commit to jonathan-buttner/kibana that referenced this pull request Jul 29, 2020
…stic#73592)

* Handling entity ids of empty string

* Tests for entity id being empty

* More comments

* entity test

* Renaming interface

* Removing unneeded test

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jonathan-buttner added a commit that referenced this pull request Jul 29, 2020
) (#73619)

* Handling entity ids of empty string

* Tests for entity id being empty

* More comments

* entity test

* Renaming interface

* Removing unneeded test

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jonathan-buttner added a commit that referenced this pull request Jul 29, 2020
#73592) (#73620)

* [Security Solution][Resolver] Handle disabled process collection (#73592)

* Handling entity ids of empty string

* Tests for entity id being empty

* More comments

* entity test

* Renaming interface

* Removing unneeded test

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

* Fixing type error

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 29, 2020
* master: (126 commits)
  [ML] Disabling ML if license feature is disabled (elastic#73187)
  [ML] Fixing old _xpack style es endpoint paths (elastic#73667)
  [DOCS] [Lens] 7.9 docs refresh (elastic#72301)
  [ML] DF Analytics results: ensure `View` link is only enabled when job has successfully completed (elastic#73539)
  Set timeRange to default to trigger the error message (elastic#73629)
  [ML] Functional tests - stabilize DFA navigation and index pattern handling (elastic#73660)
  [ILM] Add links to "Snapshot and Restore" from ILM "wait for snapshot policy" (elastic#72473)
  [kbn-storybook] Update Storybook to 5.3.19 (elastic#73320)
  [Metrics UI] Fix hasData call to ensure it has data not just indices (elastic#72969)
  [Uptime] Use `service.name` to link from Uptime -> APM where available (elastic#73618)
  allow others to update `URL.revokeObjectURL` property if needed (elastic#73639)
  regen docs (elastic#73650)
  [Visualize] Fix inspector download filename issue when saving in-place (elastic#72605)
  [Data] Query Input String manager (elastic#72093)
  [Security Solutions] Add tooltips (elastic#73436)
  Do not render descriptionless actions within an EuiCard (elastic#73611)
  [Security Solution][Detections] Value Lists Modal supports multiple exports (elastic#73532)
  [Security Solution][Resolver] Handle disabled process collection (elastic#73592)
  [Security_Solution][Bug] Fix user name/domain to ECS structure (elastic#73530)
  [Security Solution][Exceptions] - Update rule.exceptions_list to include exception list list_id (elastic#73349)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Endpoint Elastic Endpoint feature release_note:skip Skip the PR/issue when compiling release notes Team:Endpoint Data Visibility Team managing the endpoint resolver v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants