Skip to content

[9.4] Change WatchlistConfigClient to use internal Elasticsearch client instead of current user (#265966)#266437

Merged
kibanamachine merged 1 commit intoelastic:9.4from
kibanamachine:backport/9.4/pr-265966
Apr 29, 2026
Merged

[9.4] Change WatchlistConfigClient to use internal Elasticsearch client instead of current user (#265966)#266437
kibanamachine merged 1 commit intoelastic:9.4from
kibanamachine:backport/9.4/pr-265966

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.4:

Questions ?

Please refer to the Backport tool documentation

…tead of current user (elastic#265966)

### 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.

(cherry picked from commit 48b4667)
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.

🟢 Low

In create, the check for internalEsClient occurs after the saved object is already persisted (lines 97-101), so when internalEsClient is missing, the method throws but leaves an orphaned watchlist config in an inconsistent state. Move the validation before the soClient.create call.

🤖 Copy this AI Prompt to have your agent fix this:
In file x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/watchlists/management/watchlist_config.ts around line 93:

In `create`, the check for `internalEsClient` occurs after the saved object is already persisted (lines 97-101), so when `internalEsClient` is missing, the method throws but leaves an orphaned watchlist config in an inconsistent state. Move the validation before the `soClient.create` call.

Evidence trail:
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/watchlists/management/watchlist_config.ts lines 97-113 at REVIEWED_COMMIT: soClient.create at lines 97-101, internalEsClient check at lines 103-105, createOrUpdateIndex at lines 107-114.

@kibanamachine
Copy link
Copy Markdown
Contributor Author

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 9434 9433 -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

cc @CAWilson94

@kibanamachine kibanamachine merged commit ccbd690 into elastic:9.4 Apr 29, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants