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] Add our first search strategy for all host query #75439

Merged
merged 17 commits into from
Aug 22, 2020

Conversation

XavierM
Copy link
Contributor

@XavierM XavierM commented Aug 19, 2020

Summary

Bringing our own search strategy for our security solution app, to refactor most of our graphQL / apollo query call to get our data.
We created our own security solution search strategy with a factory design to avoid creating multiple search strategies for every queries that we have in our plugin. We replace our first graphQL query by our first search strategy, it just makes sense ;).

@XavierM XavierM requested review from a team as code owners August 19, 2020 14:36
@XavierM XavierM self-assigned this Aug 19, 2020
@XavierM XavierM added release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.10.0 v8.0.0 labels Aug 19, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/siem (Team:SIEM)

@XavierM XavierM requested review from lukasolson and angorayc August 19, 2020 14:37
return this.searchInterceptor.search(request, options);
};
}) as ISearchGeneric;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lukasolson, not really proud of this cast, but I did not know how to stop the type bleeding on me :(.

Copy link
Member

Choose a reason for hiding this comment

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

I just played around again trying to get rid of this cast and it was fruitless, so I'm fine with this for now.

const [
loading,
{ hosts, totalCount, pageInfo, loadPage, id, inspect, isInspected, refetch },
] = useAllHost({ docValueFields, endDate, filterQuery, startDate, type });
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@XavierM XavierM requested a review from MadameSheema August 19, 2020 15:35
@elastic elastic deleted a comment from kibanamachine Aug 19, 2020
Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Took a look at this today and tried to play around to get rid of the as but wasn't successful. I wanted to chat about this with @lizozom before I gave it the LGTM but things are looking good so far.

return this.searchInterceptor.search(request, options);
};
}) as ISearchGeneric;
Copy link
Member

Choose a reason for hiding this comment

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

I just played around again trying to get rid of this cast and it was fruitless, so I'm fine with this for now.

src/plugins/data/server/search/types.ts Outdated Show resolved Hide resolved
@patrykkopycinski
Copy link
Contributor

@elasticmachine merge upstream

export type StrategyResponseType<T extends FactoryQueryTypes> = T extends 'host_all'
? HostsStrategyResponse
: T extends 'host_details'
? HostDetailsStrategyResponse
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider rename HostDetailsStrategyResponse into HostOverviewRequestResponse.
I think the response of host details would be more generic and may include more info than HostOverviewRequestResponse/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a big fan of the Overview naming but It makes sense to keep it the same to not confuse people so I will change it back.

TimerangeInput,
} from '..';

export type HostsQueries = 'host_all' | 'host_details';
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rename host_details into host_overview?
As in x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/index.ts line 72, the query for host details is actually host overview.

Or I'm also thinking about having an enum that contains all the queries we have in security app,
for example

enum SecuritySolutionQuries = {
  host = 'host',
  hostOverview = 'hostOverview'
}
type HostQueries = SecuritySolutionQuries.host | SecuritySolutionQuries.hostOverview

say the same query in host page is reused in network page in the future, we could do

type NetworkQueries = SecuritySolutionQuries... | SecuritySolutionQuries.hostOverview

Copy link
Contributor

Choose a reason for hiding this comment

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

and in x-pack/plugins/security_solution/public/hosts/containers/hosts/index.tsx Line 69
we could put the enum we defined as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right we should use an enum, but I still think we should create the enum of the queries in their respective folder and then combine them back the way we are doing it with FactoryQueryTypes

Copy link
Contributor

@patrykkopycinski patrykkopycinski left a comment

Choose a reason for hiding this comment

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

That's HUUGEE @XavierM 💪
I've pulled down the branch and gave it a try to implement a search strategy for the timeline and everything went smooth 🧈
Well done!

@elastic elastic deleted a comment from kibanamachine Aug 20, 2020
@XavierM
Copy link
Contributor Author

XavierM commented Aug 20, 2020

@elasticmachine merge upstream

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

LGTM, minor nits below.

Also wanted to mention our conversation today that I'm still not super excited about the prospect of sending the entire search request in requests after the initial request. I understand the use case, but for our default ES search strategy, we only need the ID. I think we can come up with a better mechanism for this, so I've scheduled a discussion.

}
searchSubscription$.unsubscribe();
} else if (response.isPartial && !response.isRunning) {
if (!didCancel) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe you have to check didCancel here (or above) since if the request is aborted, it should immediately hit the error case below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the didCancel is more about if the component gets unmount and the request comeback after the component has been unmounted like if you change the route on security solution app.

@XavierM
Copy link
Contributor Author

XavierM commented Aug 22, 2020

LGTM, minor nits below.

Also wanted to mention our conversation today that I'm still not super excited about the prospect of sending the entire search request in requests after the initial request. I understand the use case, but for our default ES search strategy, we only need the ID. I think we can come up with a better mechanism for this, so I've scheduled a discussion.

I do agree with you, that we can have a better mechanism and I will love to implement it in follow up PR. Thank you for being flexible with us. It is much appreciated!

@XavierM XavierM force-pushed the securiy-solution-search-strategy branch from a2c7e4e to 63cde69 Compare August 22, 2020 01:46
@patrykkopycinski
Copy link
Contributor

@elasticmachine merge upstream

@XavierM XavierM force-pushed the securiy-solution-search-strategy branch from 9a0b7fb to d70def0 Compare August 22, 2020 10:29
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
securitySolution 1918 +2 1916

async chunks size

id value diff baseline
securitySolution 7.2MB +238.0B 7.2MB

page load bundle size

id value diff baseline
data 1.4MB -12.0B 1.4MB
dataEnhanced 178.1KB +80.0B 178.0KB
total +68.0B

History

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

@XavierM XavierM merged commit 6dbc4be into elastic:master Aug 22, 2020
XavierM added a commit to XavierM/kibana that referenced this pull request Aug 22, 2020
…lastic#75439)

* add security solution search strategy on server side

* get security solution search strategy in the public app for all host

* fix types

* fix Check core API changes

* thank you cypress test

* Remove any by the right type IESearchRequest

Co-authored-by: Lukas Olson <[email protected]>

* add translation and filter error when we abort the query

* pr review

* fix translation

* review II

* fix merge issue

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Lukas Olson <[email protected]>
XavierM added a commit that referenced this pull request Aug 25, 2020
…75439) (#75720)

* add security solution search strategy on server side

* get security solution search strategy in the public app for all host

* fix types

* fix Check core API changes

* thank you cypress test

* Remove any by the right type IESearchRequest

Co-authored-by: Lukas Olson <[email protected]>

* add translation and filter error when we abort the query

* pr review

* fix translation

* review II

* fix merge issue

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Lukas Olson <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Lukas Olson <[email protected]>
@MindyRS MindyRS added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Sep 23, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:SIEM v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants