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] Fix IP/geo location in Top N Flow Table #149369

Merged
merged 4 commits into from
Jan 24, 2023

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Jan 23, 2023

Summary

I found a bug where the country flag was not showing in the top n table on the network page even though the IP address was valid. I've explained the problematic code inline.

Before

Screen Shot 2023-01-23 at 1 20 57 PM

After

Screen Shot 2023-01-23 at 5 06 44 PM

@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore v8.7.0 labels Jan 23, 2023
@@ -118,6 +118,7 @@ export const mockSearchStrategyResponse: IEsSearchResponse<unknown> = {
_id: 'dd4fa2d4bd-1526378075029582',
_score: 0,
fields: {
'@timestamp': ['2022-07-18T15:08:48.064Z'],
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 bug surfaced because some returned geo data included the timestamp. Adding this field here would break tests in main and proves the fix

result.location.top_geo.hits.hits.length > 0 && result.location.top_geo.hits.hits[0].fields
? {
geo: formatResponseObjectValues(
getOr(
'',
`${Object.keys(result.location.top_geo.hits.hits[0].fields)[0].split('.geo')[0]}.geo`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was very silly. If for some reason a non-geo field is in there (ahem, @timestamp), the code breaks. We are able to simply pass flowTarget from where the function is called.

Copy link
Member

Choose a reason for hiding this comment

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

Now, it looks ten times better 🤩

@stephmilovic stephmilovic changed the title [Security solution] Fix geo [Security solution] Fix IP/geo location in Top N Flow Table Jan 24, 2023
@stephmilovic stephmilovic marked this pull request as ready for review January 24, 2023 00:08
@stephmilovic stephmilovic requested a review from a team as a code owner January 24, 2023 00:08
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

@elasticmachine
Copy link
Contributor

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

result.location.top_geo.hits.hits.length > 0 && result.location.top_geo.hits.hits[0].fields
? {
geo: formatResponseObjectValues(
getOr(
'',
`${Object.keys(result.location.top_geo.hits.hits[0].fields)[0].split('.geo')[0]}.geo`,
Copy link
Member

Choose a reason for hiding this comment

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

Now, it looks ten times better 🤩

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #3 / Timelines Creates a timeline by clicking untitled timeline from bottom bar can be added notes

Metrics [docs]

✅ unchanged

History

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

@stephmilovic stephmilovic merged commit bd940e8 into elastic:main Jan 24, 2023
@stephmilovic stephmilovic deleted the fix_geo branch January 24, 2023 19:41
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants