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] Migrate to fields API #136163

Merged

Conversation

YulNaumenko
Copy link
Contributor

@YulNaumenko YulNaumenko commented Jul 12, 2022

The things were done under the current PR:

  1. Replaces _source usage with fields API for the next files queries:
    x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts
    x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts
    x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts
    Impact:
    current query is used by useTimelineLastEventTime and LastEventTime component.

  2. Extended CTI query with timestamp format definition and include_unmapped fields
    x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts, removed docValueFields usage. Added stored_fields: ['*'] as a bonus :-)

  3. Cleaned up unused plugin router registration in x-pack/plugins/timelines/server/plugin.ts and deleted file x-pack/plugins/timelines/server/routes/index.ts

  4. Removed docValueFields in favor of usage a new fields API in the next files related to this PR (those files changes is docValueFields cleanup only):
    x-pack/plugins/security_solution/public/cases/pages/index.tsx
    x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx
    x-pack/plugins/security_solution/public/common/components/last_event_time/index.tsx
    x-pack/plugins/security_solution/public/common/containers/events/last_event_time/index.ts
    x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.tsx
    x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_histogram.tsx
    x-pack/plugins/security_solution/public/hosts/pages/details/index.tsx
    x-pack/plugins/security_solution/public/hosts/pages/hosts.tsx
    x-pack/plugins/security_solution/public/network/pages/network.tsx
    x-pack/plugins/security_solution/public/timelines/components/side_panel/event_details/index.tsx
    x-pack/plugins/security_solution/public/timelines/components/side_panel/hooks/use_detail_panel.tsx
    x-pack/plugins/security_solution/public/timelines/components/side_panel/index.tsx
    x-pack/plugins/security_solution/public/timelines/components/timeline/eql_tab_content/index.tsx
    x-pack/plugins/security_solution/public/timelines/components/timeline/notes_tab_content/index.tsx
    x-pack/plugins/security_solution/public/timelines/components/timeline/pinned_tab_content/index.tsx
    x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/index.tsx
    x-pack/plugins/security_solution/public/timelines/containers/details/index.tsx
    x-pack/plugins/security_solution/public/timelines/containers/index.tsx
    x-pack/plugins/security_solution/public/users/pages/details/index.tsx
    x-pack/plugins/security_solution/public/users/pages/details/types.ts
    x-pack/plugins/security_solution/public/users/pages/users.tsx
    x-pack/plugins/timelines/common/search_strategy/timeline/index.ts
    x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx
    x-pack/plugins/timelines/public/components/t_grid/standalone/index.tsx
    x-pack/plugins/timelines/public/container/index.tsx
    x-pack/plugins/timelines/public/mock/t_grid.tsx

  5. Opened a follow up issue to clean up docValueFields across the rest of security_solution and timelines plugins.

  6. Removed function getDataFromSourceHits from x-pack/plugins/timelines/common/utils/field_formatters.ts, x-pack/plugins/security_solution/common/utils/field_formatters.ts and replaced it's usage with getDataFromFieldsHits. Still have this function duplicated but this will be changed by migrating to the new table soon.

  7. For x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts changed the threat.enrichments representation from string like JSON stringify to multiple TimelineEventsDetailsItem objects. This helped to unify this representation between table and details/flyout page.

  8. All the data without mappings (ecsFieldMap, technicalRuleFieldMap or experimentalRuleFieldMap) defined will be parsed now as a string objects array:

field: 'threat.enrichments.lazer',
    values: [
      '{"great.field":["grrrrr"]}',
      '{"great.field":["grrrrr_2"]}',
      '{"great.field":[{"wowoe":[{"fooooo":["grrrrr"]}],"astring":"cool","aNumber":1,"neat":true}]}',
    ],
    originalValue: [
      '{"great.field":["grrrrr"]}',
      '{"great.field":["grrrrr_2"]}',
      '{"great.field":[{"wowoe":[{"fooooo":["grrrrr"]}],"astring":"cool","aNumber":1,"neat":true}]}',
    ],
    isObjectArray: true,

@YulNaumenko YulNaumenko self-assigned this Jul 12, 2022
@YulNaumenko YulNaumenko changed the title Security migrate to fields api pr [Security Solution] Migrate to fields API Jul 12, 2022
@YulNaumenko YulNaumenko added v8.4.0 release_note:skip Skip the PR/issue when compiling release notes labels Jul 12, 2022
@YulNaumenko YulNaumenko marked this pull request as ready for review July 12, 2022 03:11
@YulNaumenko YulNaumenko requested review from a team as code owners July 12, 2022 03:11
@YulNaumenko YulNaumenko requested review from vitaliidm and removed request for vitaliidm July 12, 2022 03:11
Copy link
Member

@MadameSheema MadameSheema left a comment

Choose a reason for hiding this comment

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

security-engineering-productivity LGTM!

Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

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

Approving new PR as old one was closed. Original review here. Thanks! 🙂

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #2 / EQL rules Detection rules, EQL Creates and enables a new EQL rule

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 3120 3118 -2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 5.2MB 5.2MB -1.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
timelines 259.0KB 258.9KB -101.0B

History

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

cc @YulNaumenko

Copy link
Contributor

@dhurley14 dhurley14 left a comment

Choose a reason for hiding this comment

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

Tested locally with rules + data views and everything looks good!

@YulNaumenko YulNaumenko merged commit 5c8eaa3 into elastic:main Jul 12, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 12, 2022
kibanamachine added a commit that referenced this pull request Nov 28, 2022
…tions to use parameters (#145889) (#146414)

# Backport

This will backport the following commits from `main` to `8.5`:
- [[Security Solution][Investigations][Timeline] - Update getExceptions
to use parameters
(#145889)](#145889)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-11-28T15:08:48Z","message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","backport","release_note:fix","Team:Threat
Hunting:Investigations","v8.5.0","v8.6.0","v8.7.0"],"number":145889,"url":"https://github.com/elastic/kibana/pull/145889","mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}},"sourceBranch":"main","suggestedTargetBranches":["8.5","8.6"],"targetPullRequestStates":[{"branch":"8.5","label":"v8.5.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145889","number":145889,"mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <[email protected]>
kibanamachine added a commit that referenced this pull request Nov 28, 2022
…tions to use parameters (#145889) (#146415)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Security Solution][Investigations][Timeline] - Update getExceptions
to use parameters
(#145889)](#145889)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-11-28T15:08:48Z","message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","backport","release_note:fix","Team:Threat
Hunting:Investigations","v8.5.0","v8.6.0","v8.7.0"],"number":145889,"url":"https://github.com/elastic/kibana/pull/145889","mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}},"sourceBranch":"main","suggestedTargetBranches":["8.5","8.6"],"targetPullRequestStates":[{"branch":"8.5","label":"v8.5.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145889","number":145889,"mergeCommit":{"message":"[Security
Solution][Investigations][Timeline] - Update getExceptions to use
parameters (#145889)\n\n## Summary\r\n\r\nFixes:
https://github.com/elastic/kibana/issues/136772\r\n\r\nThe issue was
introduced by a couple of
changes:\r\n\r\nFirst:\r\nhttps://github.com//pull/136163/files#diff-02d33a1ed6679f7775dc01941ca21b085d7c008ecffe5e029f5967407a5e5b13L23\r\nin
8.4.\r\n\r\nThe bug: A filter on the timeline UI relied on the
`exceptions_list`\r\nfield provided on `_source` to auto-generate a
filter when investigating\r\nin timeline labelled `Not Exceptions` which
would filter out the\r\nexceptions from the timeline. This PR resolves
that issue by pulling the\r\n`exceptions_list` field from
`kibana.alert.rule.parameters`.\r\n\r\nSecond:\r\nhttps://github.com//pull/133254/files#diff-0f69b69fd9cefef6ed04a048d7df86b7e385e816bdf17309212437dc3f69726cL74\r\n\r\nThe
filter actually stopped being passed to timeline entirely because
of\r\nthe above change.\r\n\r\nWith the fixes in
place:\r\n\r\n\r\nhttps://user-images.githubusercontent.com/17211684/203111748-7a0c2eb5-a46f-4f88-9d77-3628204625ac.mov","sha":"b32c8b9df89188cdcb149bd1d9494d3f99999ad6"}}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <[email protected]>
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:Threat Hunting:Investigations Security Solution Investigations Team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants