Skip to content

Change WatchlistConfigClient to use internal Elasticsearch client instead of current user #265966

Merged
CAWilson94 merged 4 commits intoelastic:mainfrom
CAWilson94:wl-perms-bug
Apr 29, 2026
Merged

Change WatchlistConfigClient to use internal Elasticsearch client instead of current user #265966
CAWilson94 merged 4 commits intoelastic:mainfrom
CAWilson94:wl-perms-bug

Conversation

@CAWilson94
Copy link
Copy Markdown
Contributor

@CAWilson94 CAWilson94 commented Apr 28, 2026

Summary

This PR changes the create watchlist to use internalUser instead of currentUser for creating the internal watchlist index. Additionally, this PR removes the placeholder privileged user monitoring permissions checks from the watchlist management page as we only need access to the internal watchlist index and any indicies permissions, should be handled per user e.g. if a user requires access to the ml indicies, this is not the responsibility of watchlists specifically.

  • Added internalEsClient dependency to WatchlistConfigClientDeps for system index operations.
  • Updated WatchlistConfigClient to throw an error if internalEsClient is not provided.
  • Modified index creation logic to use internalEsClient instead of the regular esClient.
  • Adjusted related tests to mock the new internal client dependency.

Testing steps

Feature Flags:

xpack.securitySolution.enableExperimental:
  - entityAnalyticsWatchlistEnabled
  - securitySolution:entityStoreEnableV2
  - entityAnalyticsEntityStoreV2


uiSettings.overrides:
  securitySolution:entityStoreEnableV2: true
  1. Open a kibana instance
  2. Create a user with basic role - security all, no access to specific watchlist indicies.
  3. Login with that user and try to load up the entity analytics management page, go to watchlists tab
  4. Note that, the watchlists management table shows no permissions error messages
  5. Click create watchlist, ensure you can now create a watchlist without error messages

No data generation required for this.

- Added `internalEsClient` dependency to `WatchlistConfigClientDeps` for system index operations.
- Updated `WatchlistConfigClient` to throw an error if `internalEsClient` is not provided.
- Modified index creation logic to use `internalEsClient` instead of the regular `esClient`.
- Adjusted related tests to mock the new internal client dependency.
@CAWilson94 CAWilson94 requested a review from a team as a code owner April 28, 2026 08:44
@CAWilson94 CAWilson94 requested a review from tiansivive April 28, 2026 08:44
@CAWilson94 CAWilson94 added the ci:cloud-deploy Create or update a Cloud deployment label Apr 28, 2026
- Removed the `fetchWatchlistPrivileges` function from the entity analytics API as it is no longer needed.
- Deleted the `useWatchlistsPrivileges` hook, which was dependent on the removed function.
- Updated the `Watchlists` component to eliminate privilege checks and loading states related to watchlist privileges, simplifying the rendering logic.
- Adjusted Cypress tests to remove references to the now-deleted watchlist privileges API.
@CAWilson94 CAWilson94 self-assigned this Apr 28, 2026
@CAWilson94 CAWilson94 added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.4.0 Team:Entity Analytics Security Entity Analytics Team labels Apr 28, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/security-entity-analytics (Team:Entity Analytics)

Copy link
Copy Markdown
Contributor

@tiansivive tiansivive left a comment

Choose a reason for hiding this comment

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

I'm approving, but leaving a comment which I think we could discuss a bit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought about this when we were debugging, but I didnt want to get sidetracked.

I wonder if this is the best API?
I do like that the create endpoint can check and reject non-internal user clients, I'm just not sure that means we need to "duplicate" fields in the deps for basically the same thing 🤔
Ideally, I would say it's one esClient field and then we could try to check if it's internal or not?
Otherwise I suppose this approach is the best fallback option

@kibanamachine
Copy link
Copy Markdown
Contributor

kibanamachine commented Apr 29, 2026

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 9367 9366 -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 12.0MB 12.0MB -1.0KB

History

cc @CAWilson94

@CAWilson94 CAWilson94 merged commit 48b4667 into elastic:main Apr 29, 2026
27 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.4

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
9.4

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 29, 2026
…nt instead of current user (#265966) (#266437)

# Backport

This will backport the following commits from `main` to `9.4`:
- [Change WatchlistConfigClient to use internal Elasticsearch client
instead of current user
(#265966)](#265966)

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

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

<!--BACKPORT [{"author":{"name":"Charlotte Alexandra
Wilson","email":"CAWilson94@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-29T15:27:00Z","message":"Change
WatchlistConfigClient to use internal Elasticsearch client instead of
current user (#265966)\n\n### Summary\n\nThis PR changes the create
watchlist to use internalUser instead of\ncurrentUser for creating the
internal watchlist index. Additionally,\nthis PR removes the placeholder
privileged user monitoring permissions\nchecks from the watchlist
management page as we only need access to the\ninternal watchlist index
and any indicies permissions, should be handled\nper user e.g. if a user
requires access to the ml indicies, this is not\nthe responsibility of
watchlists specifically.\n\n- Added `internalEsClient` dependency to
`WatchlistConfigClientDeps` for\nsystem index operations.\n- Updated
`WatchlistConfigClient` to throw an error if\n`internalEsClient` is not
provided.\n- Modified index creation logic to use `internalEsClient`
instead of the\nregular `esClient`.\n- Adjusted related tests to mock
the new internal client dependency.\n\n#### Testing steps\nFeature
Flags: \n```\nxpack.securitySolution.enableExperimental:\n -
entityAnalyticsWatchlistEnabled\n -
securitySolution:entityStoreEnableV2\n -
entityAnalyticsEntityStoreV2\n\n\nuiSettings.overrides:\n
securitySolution:entityStoreEnableV2: true\n```\n\n1. Open a kibana
instance \n2. Create a user with basic role - security all, no access to
specific\nwatchlist indicies.\n3. Login with that user and try to load
up the entity analytics\nmanagement page, go to watchlists tab\n4. Note
that, the watchlists management table shows no permissions
error\nmessages\n5. Click create watchlist, ensure you can now create a
watchlist without\nerror messages\n\nNo data generation required for
this.","sha":"48b46672d404a11a60177c3f5fcbced8711bfa64","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","ci:cloud-deploy","Team:Entity
Analytics","backport:version","v9.4.0","v9.5.0"],"title":"Change
WatchlistConfigClient to use internal Elasticsearch client instead of
current user
","number":265966,"url":"https://github.com/elastic/kibana/pull/265966","mergeCommit":{"message":"Change
WatchlistConfigClient to use internal Elasticsearch client instead of
current user (#265966)\n\n### Summary\n\nThis PR changes the create
watchlist to use internalUser instead of\ncurrentUser for creating the
internal watchlist index. Additionally,\nthis PR removes the placeholder
privileged user monitoring permissions\nchecks from the watchlist
management page as we only need access to the\ninternal watchlist index
and any indicies permissions, should be handled\nper user e.g. if a user
requires access to the ml indicies, this is not\nthe responsibility of
watchlists specifically.\n\n- Added `internalEsClient` dependency to
`WatchlistConfigClientDeps` for\nsystem index operations.\n- Updated
`WatchlistConfigClient` to throw an error if\n`internalEsClient` is not
provided.\n- Modified index creation logic to use `internalEsClient`
instead of the\nregular `esClient`.\n- Adjusted related tests to mock
the new internal client dependency.\n\n#### Testing steps\nFeature
Flags: \n```\nxpack.securitySolution.enableExperimental:\n -
entityAnalyticsWatchlistEnabled\n -
securitySolution:entityStoreEnableV2\n -
entityAnalyticsEntityStoreV2\n\n\nuiSettings.overrides:\n
securitySolution:entityStoreEnableV2: true\n```\n\n1. Open a kibana
instance \n2. Create a user with basic role - security all, no access to
specific\nwatchlist indicies.\n3. Login with that user and try to load
up the entity analytics\nmanagement page, go to watchlists tab\n4. Note
that, the watchlists management table shows no permissions
error\nmessages\n5. Click create watchlist, ensure you can now create a
watchlist without\nerror messages\n\nNo data generation required for
this.","sha":"48b46672d404a11a60177c3f5fcbced8711bfa64"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265966","number":265966,"mergeCommit":{"message":"Change
WatchlistConfigClient to use internal Elasticsearch client instead of
current user (#265966)\n\n### Summary\n\nThis PR changes the create
watchlist to use internalUser instead of\ncurrentUser for creating the
internal watchlist index. Additionally,\nthis PR removes the placeholder
privileged user monitoring permissions\nchecks from the watchlist
management page as we only need access to the\ninternal watchlist index
and any indicies permissions, should be handled\nper user e.g. if a user
requires access to the ml indicies, this is not\nthe responsibility of
watchlists specifically.\n\n- Added `internalEsClient` dependency to
`WatchlistConfigClientDeps` for\nsystem index operations.\n- Updated
`WatchlistConfigClient` to throw an error if\n`internalEsClient` is not
provided.\n- Modified index creation logic to use `internalEsClient`
instead of the\nregular `esClient`.\n- Adjusted related tests to mock
the new internal client dependency.\n\n#### Testing steps\nFeature
Flags: \n```\nxpack.securitySolution.enableExperimental:\n -
entityAnalyticsWatchlistEnabled\n -
securitySolution:entityStoreEnableV2\n -
entityAnalyticsEntityStoreV2\n\n\nuiSettings.overrides:\n
securitySolution:entityStoreEnableV2: true\n```\n\n1. Open a kibana
instance \n2. Create a user with basic role - security all, no access to
specific\nwatchlist indicies.\n3. Login with that user and try to load
up the entity analytics\nmanagement page, go to watchlists tab\n4. Note
that, the watchlists management table shows no permissions
error\nmessages\n5. Click create watchlist, ensure you can now create a
watchlist without\nerror messages\n\nNo data generation required for
this.","sha":"48b46672d404a11a60177c3f5fcbced8711bfa64"}}]}] BACKPORT-->

Co-authored-by: Charlotte Alexandra Wilson <CAWilson94@users.noreply.github.com>
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 ci:cloud-deploy Create or update a Cloud deployment release_note:skip Skip the PR/issue when compiling release notes Team:Entity Analytics Security Entity Analytics Team v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants