Skip to content

Comments

[Security Solution][THI] Create hook to fetch security default patterns and replace useTimelineFilters usage#226314

Merged
christineweng merged 3 commits intoelastic:mainfrom
christineweng:dp-fix-investigate-in-timeline
Jul 9, 2025
Merged

[Security Solution][THI] Create hook to fetch security default patterns and replace useTimelineFilters usage#226314
christineweng merged 3 commits intoelastic:mainfrom
christineweng:dp-fix-investigate-in-timeline

Conversation

@christineweng
Copy link
Contributor

@christineweng christineweng commented Jul 2, 2025

Summary

Ref: #225925, #226312

This PR creates a hook to return the id and index patterns of the security default data view. This is the default indices specified in advanced settings plus alert index. They are meant to be static across sessions, versus the SourcererScopeName.default is based on the data view selected in the data view picker.

Additionally, there are features that require security default patterns. It was previously done via useTimelineFilters, but it relies on the analyzer scope - when user changes the data view in analyzer, features like the prevalence table, ancestry correlations and entity analytic flyouts are impacted.

Changes inclue:

  • Created a useSecurityDefaultPatterns hook in data view manager
  • Removed selectedPatterns in useTimelineFilters
  • Replaced the index patterns with the security default patterns where applicable
  • Renamed some variables to be more explicit, and separate from the patterns return based on SourcererScopeName.default

Enable newDataViewPickerEnabled

After

Investigating an event always opens timeline with the default security data view. Opening a timeline from timelines page should have the specified data view

Screen.Recording.2025-07-02.at.5.07.55.PM.mov

Changing data view in analyzer does not change the results observed host table

Screen.Recording.2025-07-02.at.5.57.37.PM.mov

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

@christineweng christineweng self-assigned this Jul 2, 2025
@christineweng christineweng requested a review from a team as a code owner July 2, 2025 22:38
@christineweng christineweng requested a review from a team as a code owner July 2, 2025 22:38
@christineweng christineweng added the Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team label Jul 2, 2025
@christineweng christineweng requested a review from CAWilson94 July 2, 2025 22:38
@christineweng christineweng added backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.2.0 labels Jul 2, 2025
@elasticmachine
Copy link
Contributor

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

@christineweng christineweng changed the title [Security Solution] Create hook to fetch security default patterns and replace useTimelineFilters usage [Security Solution][THI] Create hook to fetch security default patterns and replace useTimelineFilters usage Jul 2, 2025
Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

Desk tested and everything seems to be working as expected!
I left a few comments on the code but those are a bit subjective and non blockers 😄
Great job fixing 2 bugs at the same time!

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this kind of a duplicate of this other hook?

@lgestc
Copy link
Contributor

lgestc commented Jul 7, 2025

is it not feasible to just useDataView() and respective props?

@christineweng
Copy link
Contributor Author

christineweng commented Jul 7, 2025

@PhilippeOberti @lgestc Thanks for the review! I'm not sure the comments are around the logic or the implementation, so I include both:

  • The timeline data view bug is due to the fact that it pulls the data view based on scope name. The scope name corresponds to the selection in that data view picker (in this case explore). So when we change the data view in explore, create_timeline uses another data view. timeline should always start with the default security data view, so we have to find a way to do this without needing a scope
const experimentalSelectedPatterns = useSelectedPatterns(DataViewManagerScopeName.default);
  • The implementation is then to have a separate hook to do that. All of our existing hooks receive a scope name as prop. each scope represents a data view picker (and they are subject to change from user interaction). To support both scope name and a specific data view, the prop type needs to be changed to DataViewManagerScopeName | string

From

export const useDataView = (dataViewManagerScope: DataViewManagerScopeName): 
{ dataView: DataView; status: SharedDataViewSelectionState['status'] } => {
  ...

To:

export const useDataView = (dataViewManagerScope: DataViewManagerScopeName | string ):
 { dataView: DataView; status: SharedDataViewSelectionState['status'] } => {
  ...

I personally think it's a overkill and requires more validation later on. We do store the default data view id in data view manager redux, just not the patterns. We could store the patterns in redux as well, this is how sourcerer works (it stores the entire default data view in redux).

const { id: oldDataViewId, patternList: oldSelectedPatterns } = useSelector(
    sourcererSelectors.defaultDataView
  ) ?? { id: '', patternList: [] };

Let me know if I miss something, happy to discuss live as well

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #26 / serverless observability UI - feature flags ES Query rule - consumers only logs privileges navigates to the rules page

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 7785 7786 +1

Async chunks

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

id before after diff
securitySolution 9.8MB 9.8MB +1.5KB

History

cc @christineweng

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

Thanks for making all the changes @christineweng , code LGTM!

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

Thank you!

This is interesting, I wasn't even aware that flyouts are using the security data view instead of the selected one.

@christineweng christineweng enabled auto-merge (squash) July 9, 2025 16:14
@christineweng christineweng merged commit 73e1264 into elastic:main Jul 9, 2025
12 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

https://github.com/elastic/kibana/actions/runs/16176864777

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 9, 2025
…ns and replace useTimelineFilters usage (elastic#226314)

## Summary

Ref: elastic#225925,
elastic#226312

This PR creates a hook to return the id and index patterns of the
security default data view. This is the default indices specified in
advanced settings plus alert index. They are meant to be static across
sessions, versus the `SourcererScopeName.default` is based on the data
view selected in the data view picker.

Additionally, there are features that require security default patterns.
It was previously done via `useTimelineFilters`, but it relies on the
analyzer scope - when user changes the data view in analyzer, features
like the prevalence table, ancestry correlations and entity analytic
flyouts are impacted.

Changes inclue:
- Created a `useSecurityDefaultPatterns` hook in data view manager
- Removed `selectedPatterns` in `useTimelineFilters`
- Replaced the index patterns with the security default patterns where
applicable
- Renamed some variables to be more explicit, and separate from the
patterns return based on `SourcererScopeName.default`

Enable `newDataViewPickerEnabled`

### After

Investigating an event always opens timeline with the default security
data view. Opening a timeline from timelines page should have the
specified data view

https://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894

Changing data view in analyzer does not change the results observed host
table

https://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 73e1264)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.19 Backport failed because of merge conflicts
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 226314

Questions ?

Please refer to the Backport tool documentation

@christineweng
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

christineweng added a commit to christineweng/kibana that referenced this pull request Jul 9, 2025
…ns and replace useTimelineFilters usage (elastic#226314)

## Summary

Ref: elastic#225925,
elastic#226312

This PR creates a hook to return the id and index patterns of the
security default data view. This is the default indices specified in
advanced settings plus alert index. They are meant to be static across
sessions, versus the `SourcererScopeName.default` is based on the data
view selected in the data view picker.

Additionally, there are features that require security default patterns.
It was previously done via `useTimelineFilters`, but it relies on the
analyzer scope - when user changes the data view in analyzer, features
like the prevalence table, ancestry correlations and entity analytic
flyouts are impacted.

Changes inclue:
- Created a `useSecurityDefaultPatterns` hook in data view manager
- Removed `selectedPatterns` in `useTimelineFilters`
- Replaced the index patterns with the security default patterns where
applicable
- Renamed some variables to be more explicit, and separate from the
patterns return based on `SourcererScopeName.default`

Enable `newDataViewPickerEnabled`

### After

Investigating an event always opens timeline with the default security
data view. Opening a timeline from timelines page should have the
specified data view

https://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894

Changing data view in analyzer does not change the results observed host
table

https://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 73e1264)

# Conflicts:
#	x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/visualizations_section.test.tsx
kibanamachine added a commit that referenced this pull request Jul 9, 2025
…patterns and replace useTimelineFilters usage (#226314) (#227307)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Security Solution][THI] Create hook to fetch security default
patterns and replace useTimelineFilters usage
(#226314)](#226314)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT
[{"author":{"name":"christineweng","email":"18648970+christineweng@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-07-09T18:07:31Z","message":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters usage (#226314)\n\n## Summary\n\nRef:
https://github.com/elastic/kibana/issues/225925,\nhttps://github.com/elastic/kibana/issues/226312\n\nThis
PR creates a hook to return the id and index patterns of the\nsecurity
default data view. This is the default indices specified in\nadvanced
settings plus alert index. They are meant to be static across\nsessions,
versus the `SourcererScopeName.default` is based on the data\nview
selected in the data view picker.\n\nAdditionally, there are features
that require security default patterns.\nIt was previously done via
`useTimelineFilters`, but it relies on the\nanalyzer scope - when user
changes the data view in analyzer, features\nlike the prevalence table,
ancestry correlations and entity analytic\nflyouts are
impacted.\n\nChanges inclue:\n- Created a `useSecurityDefaultPatterns`
hook in data view manager\n- Removed `selectedPatterns` in
`useTimelineFilters`\n- Replaced the index patterns with the security
default patterns where\napplicable\n- Renamed some variables to be more
explicit, and separate from the\npatterns return based on
`SourcererScopeName.default`\n\nEnable `newDataViewPickerEnabled`\n\n###
After\n\nInvestigating an event always opens timeline with the default
security\ndata view. Opening a timeline from timelines page should have
the\nspecified data
view\n\n\nhttps://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894\n\n\nChanging
data view in analyzer does not change the results observed
host\ntable\n\n\n\nhttps://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f\n\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"73e1264cb1516606cf4b01501a8a6f6665af9cf4","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat
Hunting:Investigations","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters
usage","number":226314,"url":"https://github.com/elastic/kibana/pull/226314","mergeCommit":{"message":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters usage (#226314)\n\n## Summary\n\nRef:
https://github.com/elastic/kibana/issues/225925,\nhttps://github.com/elastic/kibana/issues/226312\n\nThis
PR creates a hook to return the id and index patterns of the\nsecurity
default data view. This is the default indices specified in\nadvanced
settings plus alert index. They are meant to be static across\nsessions,
versus the `SourcererScopeName.default` is based on the data\nview
selected in the data view picker.\n\nAdditionally, there are features
that require security default patterns.\nIt was previously done via
`useTimelineFilters`, but it relies on the\nanalyzer scope - when user
changes the data view in analyzer, features\nlike the prevalence table,
ancestry correlations and entity analytic\nflyouts are
impacted.\n\nChanges inclue:\n- Created a `useSecurityDefaultPatterns`
hook in data view manager\n- Removed `selectedPatterns` in
`useTimelineFilters`\n- Replaced the index patterns with the security
default patterns where\napplicable\n- Renamed some variables to be more
explicit, and separate from the\npatterns return based on
`SourcererScopeName.default`\n\nEnable `newDataViewPickerEnabled`\n\n###
After\n\nInvestigating an event always opens timeline with the default
security\ndata view. Opening a timeline from timelines page should have
the\nspecified data
view\n\n\nhttps://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894\n\n\nChanging
data view in analyzer does not change the results observed
host\ntable\n\n\n\nhttps://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f\n\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"73e1264cb1516606cf4b01501a8a6f6665af9cf4"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/226314","number":226314,"mergeCommit":{"message":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters usage (#226314)\n\n## Summary\n\nRef:
https://github.com/elastic/kibana/issues/225925,\nhttps://github.com/elastic/kibana/issues/226312\n\nThis
PR creates a hook to return the id and index patterns of the\nsecurity
default data view. This is the default indices specified in\nadvanced
settings plus alert index. They are meant to be static across\nsessions,
versus the `SourcererScopeName.default` is based on the data\nview
selected in the data view picker.\n\nAdditionally, there are features
that require security default patterns.\nIt was previously done via
`useTimelineFilters`, but it relies on the\nanalyzer scope - when user
changes the data view in analyzer, features\nlike the prevalence table,
ancestry correlations and entity analytic\nflyouts are
impacted.\n\nChanges inclue:\n- Created a `useSecurityDefaultPatterns`
hook in data view manager\n- Removed `selectedPatterns` in
`useTimelineFilters`\n- Replaced the index patterns with the security
default patterns where\napplicable\n- Renamed some variables to be more
explicit, and separate from the\npatterns return based on
`SourcererScopeName.default`\n\nEnable `newDataViewPickerEnabled`\n\n###
After\n\nInvestigating an event always opens timeline with the default
security\ndata view. Opening a timeline from timelines page should have
the\nspecified data
view\n\n\nhttps://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894\n\n\nChanging
data view in analyzer does not change the results observed
host\ntable\n\n\n\nhttps://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f\n\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"73e1264cb1516606cf4b01501a8a6f6665af9cf4"}}]}]
BACKPORT-->

Co-authored-by: christineweng <18648970+christineweng@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 11, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @christineweng

christineweng added a commit that referenced this pull request Jul 11, 2025
… patterns and replace useTimelineFilters usage (#226314) (#227313)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Security Solution][THI] Create hook to fetch security default
patterns and replace useTimelineFilters usage
(#226314)](#226314)

<!--- Backport version: 10.0.1 -->

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

<!--BACKPORT
[{"author":{"name":"christineweng","email":"18648970+christineweng@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-07-09T18:07:31Z","message":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters usage (#226314)\n\n## Summary\n\nRef:
https://github.com/elastic/kibana/issues/225925,\nhttps://github.com/elastic/kibana/issues/226312\n\nThis
PR creates a hook to return the id and index patterns of the\nsecurity
default data view. This is the default indices specified in\nadvanced
settings plus alert index. They are meant to be static across\nsessions,
versus the `SourcererScopeName.default` is based on the data\nview
selected in the data view picker.\n\nAdditionally, there are features
that require security default patterns.\nIt was previously done via
`useTimelineFilters`, but it relies on the\nanalyzer scope - when user
changes the data view in analyzer, features\nlike the prevalence table,
ancestry correlations and entity analytic\nflyouts are
impacted.\n\nChanges inclue:\n- Created a `useSecurityDefaultPatterns`
hook in data view manager\n- Removed `selectedPatterns` in
`useTimelineFilters`\n- Replaced the index patterns with the security
default patterns where\napplicable\n- Renamed some variables to be more
explicit, and separate from the\npatterns return based on
`SourcererScopeName.default`\n\nEnable `newDataViewPickerEnabled`\n\n###
After\n\nInvestigating an event always opens timeline with the default
security\ndata view. Opening a timeline from timelines page should have
the\nspecified data
view\n\n\nhttps://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894\n\n\nChanging
data view in analyzer does not change the results observed
host\ntable\n\n\n\nhttps://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f\n\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"73e1264cb1516606cf4b01501a8a6f6665af9cf4","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat
Hunting:Investigations","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters
usage","number":226314,"url":"https://github.com/elastic/kibana/pull/226314","mergeCommit":{"message":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters usage (#226314)\n\n## Summary\n\nRef:
https://github.com/elastic/kibana/issues/225925,\nhttps://github.com/elastic/kibana/issues/226312\n\nThis
PR creates a hook to return the id and index patterns of the\nsecurity
default data view. This is the default indices specified in\nadvanced
settings plus alert index. They are meant to be static across\nsessions,
versus the `SourcererScopeName.default` is based on the data\nview
selected in the data view picker.\n\nAdditionally, there are features
that require security default patterns.\nIt was previously done via
`useTimelineFilters`, but it relies on the\nanalyzer scope - when user
changes the data view in analyzer, features\nlike the prevalence table,
ancestry correlations and entity analytic\nflyouts are
impacted.\n\nChanges inclue:\n- Created a `useSecurityDefaultPatterns`
hook in data view manager\n- Removed `selectedPatterns` in
`useTimelineFilters`\n- Replaced the index patterns with the security
default patterns where\napplicable\n- Renamed some variables to be more
explicit, and separate from the\npatterns return based on
`SourcererScopeName.default`\n\nEnable `newDataViewPickerEnabled`\n\n###
After\n\nInvestigating an event always opens timeline with the default
security\ndata view. Opening a timeline from timelines page should have
the\nspecified data
view\n\n\nhttps://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894\n\n\nChanging
data view in analyzer does not change the results observed
host\ntable\n\n\n\nhttps://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f\n\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"73e1264cb1516606cf4b01501a8a6f6665af9cf4"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/227307","number":227307,"state":"OPEN"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/226314","number":226314,"mergeCommit":{"message":"[Security
Solution][THI] Create hook to fetch security default patterns and
replace useTimelineFilters usage (#226314)\n\n## Summary\n\nRef:
https://github.com/elastic/kibana/issues/225925,\nhttps://github.com/elastic/kibana/issues/226312\n\nThis
PR creates a hook to return the id and index patterns of the\nsecurity
default data view. This is the default indices specified in\nadvanced
settings plus alert index. They are meant to be static across\nsessions,
versus the `SourcererScopeName.default` is based on the data\nview
selected in the data view picker.\n\nAdditionally, there are features
that require security default patterns.\nIt was previously done via
`useTimelineFilters`, but it relies on the\nanalyzer scope - when user
changes the data view in analyzer, features\nlike the prevalence table,
ancestry correlations and entity analytic\nflyouts are
impacted.\n\nChanges inclue:\n- Created a `useSecurityDefaultPatterns`
hook in data view manager\n- Removed `selectedPatterns` in
`useTimelineFilters`\n- Replaced the index patterns with the security
default patterns where\napplicable\n- Renamed some variables to be more
explicit, and separate from the\npatterns return based on
`SourcererScopeName.default`\n\nEnable `newDataViewPickerEnabled`\n\n###
After\n\nInvestigating an event always opens timeline with the default
security\ndata view. Opening a timeline from timelines page should have
the\nspecified data
view\n\n\nhttps://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894\n\n\nChanging
data view in analyzer does not change the results observed
host\ntable\n\n\n\nhttps://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f\n\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"73e1264cb1516606cf4b01501a8a6f6665af9cf4"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Brad White <Ikuni17@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 11, 2025
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
…ns and replace useTimelineFilters usage (elastic#226314)

## Summary

Ref: elastic#225925,
elastic#226312

This PR creates a hook to return the id and index patterns of the
security default data view. This is the default indices specified in
advanced settings plus alert index. They are meant to be static across
sessions, versus the `SourcererScopeName.default` is based on the data
view selected in the data view picker.

Additionally, there are features that require security default patterns.
It was previously done via `useTimelineFilters`, but it relies on the
analyzer scope - when user changes the data view in analyzer, features
like the prevalence table, ancestry correlations and entity analytic
flyouts are impacted.

Changes inclue:
- Created a `useSecurityDefaultPatterns` hook in data view manager
- Removed `selectedPatterns` in `useTimelineFilters`
- Replaced the index patterns with the security default patterns where
applicable
- Renamed some variables to be more explicit, and separate from the
patterns return based on `SourcererScopeName.default`

Enable `newDataViewPickerEnabled`

### After

Investigating an event always opens timeline with the default security
data view. Opening a timeline from timelines page should have the
specified data view


https://github.com/user-attachments/assets/5ea88e6e-0266-4b6b-802e-5c299c03b894


Changing data view in analyzer does not change the results observed host
table



https://github.com/user-attachments/assets/33646b24-8235-4740-975f-a423f2dcfd3f





### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:fix Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v8.19.0 v9.1.0 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants