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] Fix resolver isStart event bug #73357

Merged

Conversation

jonathan-buttner
Copy link
Contributor

This PR fixes a bug in the resolver backend where process start events were not correctly being identified because the comparison was not handling event.type being an array. This caused the backend to never return children.

isStart should now handle event.type as an array or a string. If it is an array is should only be of length 1 and be ['start'].

Our api_integration did not cover this because the resolver generator is creating process events with event.type === 'start'.

I switched it to be inline with how the endpoint defines process events where event.type will be an array and I added some more unit tests to make sure we handle both cases.

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 27, 2020
@jonathan-buttner jonathan-buttner requested review from a team as code owners July 27, 2020 21:13
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

const event = generator.generateEvent({ eventCategory: 'registry', extensions });
expect(descriptiveName(event)).toEqual({ subject: `HKLM/Windows/Software/abc` });
});
describe('Event descriptive names', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were just wrapped in a new describe block and indented

if (isLegacyEvent(event)) {
return event.event?.type === 'process_start' || event.event?.action === 'fork_event';
}

if (Array.isArray(event.event.type)) {
return event.event.type.length === 1 && event.event.type[0] === 'start';
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 https://www.elastic.co/guide/en/ecs/current/ecs-event.html The type entry doesn't say anything about start having to come first or the array needing to have a length of one. Should we check instead to see that it .includes start

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'll update it.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

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

History

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

if (isLegacyEvent(event)) {
return event.event?.type === 'process_start' || event.event?.action === 'fork_event';
}

if (Array.isArray(event.event.type)) {
return event.event.type.includes('start');
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary for this PR if you don't want to wait for CI all over again 😅 , but I would put start, process_start, for_event, etc... all in some kind of constants file. It'll help avoid spelling bugs in any future updates / refactors and also give us a central place to see all these terms.

Copy link
Contributor

@oatkiller oatkiller Jul 28, 2020

Choose a reason for hiding this comment

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

consider using typescript types and interfaces for that kind of thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point

@michaelolo24
Copy link
Contributor

Nice catch

@jonathan-buttner jonathan-buttner changed the title [Security Solution][Resolver] Fix resolver is start event bug [Security Solution][Resolver] Fix resolver isStart event bug Jul 28, 2020
@jonathan-buttner jonathan-buttner merged commit fb4ee91 into elastic:master Jul 28, 2020
@jonathan-buttner jonathan-buttner deleted the fix-resolver-children-bug branch July 28, 2020 13:56
jonathan-buttner added a commit to jonathan-buttner/kibana that referenced this pull request Jul 28, 2020
…#73357)

* Check if category is array

* Adding more tests and renaming to isStart

* Handling the case where start is not at the front
jonathan-buttner added a commit to jonathan-buttner/kibana that referenced this pull request Jul 28, 2020
…#73357)

* Check if category is array

* Adding more tests and renaming to isStart

* Handling the case where start is not at the front
jonathan-buttner added a commit that referenced this pull request Jul 28, 2020
…#73447)

* Check if category is array

* Adding more tests and renaming to isStart

* Handling the case where start is not at the front
jonathan-buttner added a commit that referenced this pull request Jul 28, 2020
…#73448)

* Check if category is array

* Adding more tests and renaming to isStart

* Handling the case where start is not at the front

Co-authored-by: Elastic Machine <[email protected]>
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.

7 participants