[Entity Analytics][Privmon] Fix Privileged user monitoring index sync in non-default spaces#230420
Merged
hop-dev merged 7 commits intoelastic:mainfrom Aug 5, 2025
Merged
Conversation
hop-dev
commented
Aug 4, 2025
| const apiKey = await generateAPIKey(request, deps); | ||
|
|
||
| const soClient = core.savedObjects.getScopedClient(request, { | ||
| const soClient = core.savedObjects.getUnsafeInternalClient({ |
Contributor
Author
There was a problem hiding this comment.
this isn't the fix just a nicer way of getting a client
hop-dev
commented
Aug 4, 2025
...y/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/auth/api_key.ts
Show resolved
Hide resolved
Contributor
|
Pinging @elastic/security-entity-analytics (Team:Entity Analytics) |
Contributor
|
@elasticmachine merge upstream |
jaredburgettelastic
previously requested changes
Aug 5, 2025
Contributor
jaredburgettelastic
left a comment
There was a problem hiding this comment.
I haven't diagnosed exactly why, but local testing didn't pass on this PR yet for me 🤔
Index sync fails entirely, and here is the error log I'm seeing
[2025-08-04T19:04:36.984-05:00][ERROR][plugins.securitySolution] [Privileged Monitoring Engine][namespace: default] Error initializing privilege monitoring engine: Error: Namespace cannot be specified by the caller when the spaces extension is enabled. Spaces currently determines the namespace.
machadoum
approved these changes
Aug 5, 2025
Member
Contributor
💚 Build Succeeded
Metrics [docs]
History
cc @hop-dev |
Contributor
Author
|
@elasticmachine merge upstream |
Contributor
|
Starting backport for target branches: 9.1 https://github.com/elastic/kibana/actions/runs/16749491143 |
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Aug 5, 2025
…stic#230420) ## Summary Closes [elastic#13399](elastic/security-team#13399) Fixes a bug where syncing privileged users from an index failed in spaces other than "default". The issue was that we could not find the API key saved object, this is because we weren't specifying the namespace when we searched for it. ### Test Steps - create a space "space2" - switch to space2 - enable privileged usr monitoring advanced setting - create an index to sync users from: ``` # create index with correct mapping PUT /my-custom-index { "mappings" : { "properties": { "user.name": { "type": "keyword" } } } } # add a user POST /_bulk { "index": { "_index": "my-custom-index" } } { "user": { "name": "tiago" } } ``` - add a document to skip the onboarding screen ``` POST /logs-test-hello/_doc { "message" : "sup" } ``` - go to privileged user monitoring onbaording - select your index to sync - (it should work and load the users) (cherry picked from commit 6f9d1a3)
Contributor
💚 All backports created successfully
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
Aug 5, 2025
#230420) (#230563) # Backport This will backport the following commits from `main` to `9.1`: - [[Entity Analytics][Privmon] Fix index sync in non-default spaces (#230420)](#230420) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Mark Hopkin","email":"mark.hopkin@elastic.co"},"sourceCommit":{"committedDate":"2025-08-05T12:04:06Z","message":"[Entity Analytics][Privmon] Fix index sync in non-default spaces (#230420)\n\n## Summary\n\nCloses [#13399](https://github.com/elastic/security-team/issues/13399)\n\nFixes a bug where syncing privileged users from an index failed in\nspaces other than \"default\".\n\nThe issue was that we could not find the API key saved object, this is\nbecause we weren't specifying the namespace when we searched for it.\n\n### Test Steps\n\n- create a space \"space2\"\n- switch to space2\n- enable privileged usr monitoring advanced setting\n- create an index to sync users from:\n\n```\n# create index with correct mapping\nPUT /my-custom-index\n{\n \"mappings\" : {\n \"properties\": {\n \"user.name\": {\n \"type\": \"keyword\"\n }\n }\n }\n}\n\n# add a user\nPOST /_bulk\n{ \"index\": { \"_index\": \"my-custom-index\" } }\n{ \"user\": { \"name\": \"tiago\" } }\n```\n\n- add a document to skip the onboarding screen\n\n```\nPOST /logs-test-hello/_doc\n{\n \"message\" : \"sup\"\n}\n```\n- go to privileged user monitoring onbaording\n- select your index to sync\n- (it should work and load the users)","sha":"6f9d1a3a323f939f1471c41bad856449f8f55ffd","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","backport:prev-minor","Team:Entity Analytics","v9.2.0"],"title":"[Entity Analytics][Privmon] Fix index sync in non-default spaces","number":230420,"url":"https://github.com/elastic/kibana/pull/230420","mergeCommit":{"message":"[Entity Analytics][Privmon] Fix index sync in non-default spaces (#230420)\n\n## Summary\n\nCloses [#13399](https://github.com/elastic/security-team/issues/13399)\n\nFixes a bug where syncing privileged users from an index failed in\nspaces other than \"default\".\n\nThe issue was that we could not find the API key saved object, this is\nbecause we weren't specifying the namespace when we searched for it.\n\n### Test Steps\n\n- create a space \"space2\"\n- switch to space2\n- enable privileged usr monitoring advanced setting\n- create an index to sync users from:\n\n```\n# create index with correct mapping\nPUT /my-custom-index\n{\n \"mappings\" : {\n \"properties\": {\n \"user.name\": {\n \"type\": \"keyword\"\n }\n }\n }\n}\n\n# add a user\nPOST /_bulk\n{ \"index\": { \"_index\": \"my-custom-index\" } }\n{ \"user\": { \"name\": \"tiago\" } }\n```\n\n- add a document to skip the onboarding screen\n\n```\nPOST /logs-test-hello/_doc\n{\n \"message\" : \"sup\"\n}\n```\n- go to privileged user monitoring onbaording\n- select your index to sync\n- (it should work and load the users)","sha":"6f9d1a3a323f939f1471c41bad856449f8f55ffd"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/230420","number":230420,"mergeCommit":{"message":"[Entity Analytics][Privmon] Fix index sync in non-default spaces (#230420)\n\n## Summary\n\nCloses [#13399](https://github.com/elastic/security-team/issues/13399)\n\nFixes a bug where syncing privileged users from an index failed in\nspaces other than \"default\".\n\nThe issue was that we could not find the API key saved object, this is\nbecause we weren't specifying the namespace when we searched for it.\n\n### Test Steps\n\n- create a space \"space2\"\n- switch to space2\n- enable privileged usr monitoring advanced setting\n- create an index to sync users from:\n\n```\n# create index with correct mapping\nPUT /my-custom-index\n{\n \"mappings\" : {\n \"properties\": {\n \"user.name\": {\n \"type\": \"keyword\"\n }\n }\n }\n}\n\n# add a user\nPOST /_bulk\n{ \"index\": { \"_index\": \"my-custom-index\" } }\n{ \"user\": { \"name\": \"tiago\" } }\n```\n\n- add a document to skip the onboarding screen\n\n```\nPOST /logs-test-hello/_doc\n{\n \"message\" : \"sup\"\n}\n```\n- go to privileged user monitoring onbaording\n- select your index to sync\n- (it should work and load the users)","sha":"6f9d1a3a323f939f1471c41bad856449f8f55ffd"}}]}] BACKPORT--> Co-authored-by: Mark Hopkin <mark.hopkin@elastic.co>
delanni
pushed a commit
to delanni/kibana
that referenced
this pull request
Aug 5, 2025
…stic#230420) ## Summary Closes [elastic#13399](elastic/security-team#13399) Fixes a bug where syncing privileged users from an index failed in spaces other than "default". The issue was that we could not find the API key saved object, this is because we weren't specifying the namespace when we searched for it. ### Test Steps - create a space "space2" - switch to space2 - enable privileged usr monitoring advanced setting - create an index to sync users from: ``` # create index with correct mapping PUT /my-custom-index { "mappings" : { "properties": { "user.name": { "type": "keyword" } } } } # add a user POST /_bulk { "index": { "_index": "my-custom-index" } } { "user": { "name": "tiago" } } ``` - add a document to skip the onboarding screen ``` POST /logs-test-hello/_doc { "message" : "sup" } ``` - go to privileged user monitoring onbaording - select your index to sync - (it should work and load the users)
NicholasPeretti
pushed a commit
to NicholasPeretti/kibana
that referenced
this pull request
Aug 18, 2025
…stic#230420) ## Summary Closes [elastic#13399](elastic/security-team#13399) Fixes a bug where syncing privileged users from an index failed in spaces other than "default". The issue was that we could not find the API key saved object, this is because we weren't specifying the namespace when we searched for it. ### Test Steps - create a space "space2" - switch to space2 - enable privileged usr monitoring advanced setting - create an index to sync users from: ``` # create index with correct mapping PUT /my-custom-index { "mappings" : { "properties": { "user.name": { "type": "keyword" } } } } # add a user POST /_bulk { "index": { "_index": "my-custom-index" } } { "user": { "name": "tiago" } } ``` - add a document to skip the onboarding screen ``` POST /logs-test-hello/_doc { "message" : "sup" } ``` - go to privileged user monitoring onbaording - select your index to sync - (it should work and load the users)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Closes #13399
Fixes a bug where syncing privileged users from an index failed in spaces other than "default".
The issue was that we could not find the API key saved object, this is because we weren't specifying the namespace when we searched for it.
Test Steps