-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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][Endpoint] Update to Endpoint List and associated supporting API to be space aware #194312
Merged
paul-tavares
merged 50 commits into
elastic:main
from
paul-tavares:task/olm-8538-endpoint-list-api-support-spaces-2
Oct 17, 2024
Merged
Changes from 44 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
9382f7d
Endpoint list API updated to return hosts scopped to current space
paul-tavares 79db62d
Enable space awareness for endpoint agent status API/Service
paul-tavares 1b5e7e0
Fleet: added new `getByIds()` service method for Agents
paul-tavares 04b3089
Change `EndpointFleetServicesFactory#asInternalUser()` method + adjus…
paul-tavares e18c9df
Host metadata API/service (single) updated to support spaces
paul-tavares 0dfe39c
Added `ensureInCurrentSpace()` to fleet services and refactored endpo…
paul-tavares 36af78c
Updated Policy response API to be space aware
paul-tavares 33c0bc9
update to jsdoc comment
paul-tavares 967b620
Fix calls to `createInternalScopedSoClient()` due to rebase from main
paul-tavares ce76ed0
Fleet: tests for agent service new method
paul-tavares aab3353
Tests for agent status api handler
paul-tavares 339c569
Fleet: Add missing members to agent service mocks
paul-tavares c626af6
Tests for metadata api handler
paul-tavares 97f44fa
Tests for policy response api + service
paul-tavares e02cd6b
Merge remote-tracking branch 'upstream/main' into task/olm-8538-endpo…
paul-tavares 373b59e
Tests for the metadata service + mock and generator updates
paul-tavares 6964f1a
Tests for Endpoint Agent Status
paul-tavares 32ca590
Merge remote-tracking branch 'upstream/main' into task/olm-8538-endpo…
paul-tavares 87f7093
Fix type in policy response route registration
paul-tavares ec157ac
Fix types in tests for policy response handlers
paul-tavares 410ad02
Fix API integration test
paul-tavares 5a496b5
Merge remote-tracking branch 'upstream/main' into task/olm-8538-endpo…
paul-tavares 641711b
Improve data loader for fleet server and also formatted axios error
paul-tavares ee77054
Improve FTR endpoint test services to enable loading data by space
paul-tavares c41d971
Initial set of FTR test setup (not yet implemented) for spaces
paul-tavares 81ea666
Rename variable
paul-tavares 0a825b4
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 3fe80f3
Re-structure space awareness API integration tests
paul-tavares 6743866
Fix up scripts `spaces` module to not use `KbnClient` internal `space…
paul-tavares 7591d0f
Update test data loaders for endpoint hosts, fleet agent and fleet se…
paul-tavares d601588
FTR API integration tests for space awareness
paul-tavares b3ddf26
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares d83ee04
Merge remote-tracking branch 'origin/task/olm-8538-endpoint-list-api-…
paul-tavares 96a40a3
Enable serverless config for spaces
paul-tavares 45f026f
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares bdb7378
enable spaces in FTR serverless config
paul-tavares 4a6bf16
Merge remote-tracking branch 'origin/task/olm-8538-endpoint-list-api-…
paul-tavares 9fb15b4
Add utility for logging supertest errors
paul-tavares cf4ce36
Fix failing tests in serverless
paul-tavares c45b17b
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares 38b0a93
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares c9f8c7e
Updated endpoint hosts indexer to now include the initial policy id r…
paul-tavares 12f5b9e
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares bfbb682
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares ae5c0f4
Adjustments from code review
paul-tavares 4f60af2
Merge remote-tracking branch 'origin/task/olm-8538-endpoint-list-api-…
paul-tavares b9b7f54
Merge remote-tracking branch 'upstream/main' into task/olm-8538-endpo…
paul-tavares 081389b
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares 3b741e6
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares 9ef0bea
Merge branch 'main' into task/olm-8538-endpoint-list-api-support-spac…
paul-tavares File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,6 +415,46 @@ export async function getAgentById( | |
return agentHit; | ||
} | ||
|
||
/** | ||
* Get list of agents by `id`. service method performs space awareness checks. | ||
* @param esClient | ||
* @param soClient | ||
* @param agentIds | ||
* @param options | ||
* | ||
* @throws AgentNotFoundError | ||
*/ | ||
export const getByIds = async ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also perhaps rename this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as before - just following Fleet conventions as other |
||
esClient: ElasticsearchClient, | ||
soClient: SavedObjectsClientContract, | ||
agentIds: string[], | ||
options?: Partial<{ ignoreMissing: boolean }> | ||
): Promise<Agent[]> => { | ||
const agentsHits = await getAgentsById(esClient, soClient, agentIds); | ||
const currentNamespace = getCurrentNamespace(soClient); | ||
const response: Agent[] = []; | ||
|
||
for (const agentHit of agentsHits) { | ||
let throwError = false; | ||
|
||
if ('notFound' in agentHit && !options?.ignoreMissing) { | ||
throwError = true; | ||
} else if ((await isAgentInNamespace(agentHit as Agent, currentNamespace)) !== true) { | ||
throwError = true; | ||
} | ||
|
||
if (throwError) { | ||
throw new AgentNotFoundError(`Agent ${agentHit.id} not found`, { agentId: agentHit.id }); | ||
} | ||
|
||
if (!(`notFound` in agentHit)) { | ||
response.push(agentHit); | ||
} | ||
} | ||
|
||
return response; | ||
}; | ||
|
||
async function _filterAgents( | ||
esClient: ElasticsearchClient, | ||
soClient: SavedObjectsClientContract, | ||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rename this to
getAgentsByIds
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @ashokaditya . I named
getByIds()
to mirror other APIs available from fleet - thus to remain consistent with their naming conventions.