Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Endpoint] Use "valid" agents for creating action …
…requests and updating cases (#187145) ## Summary This PR corrects an API we were able to create multi-agent action for duplicate/non-existing agent ids. The changes in the PR fix that 1. by not including invalid agent ids (that do not have Elastic Defend installed) and 2. adds a warning info in the action request comment so that the user is aware of discarded agents This action when errored shows multi agent action Host/Error grouping. **Before** (notice the single `Hostname` above outputs) You could do this: ```json5 POST /api/endpoint/action/suspend_process { "endpoint_ids": [ "1d793b46-7b6a-4dd4-a6b7-4c75718e04be", "1d793b46-7b6a-4dd4-a6b7-4c75718e04be" ], "parameters": { "pid": "42424242" } } ``` and get a response that looked like (notice the duplicate agent ids in `agents`) ```json5 { "data": { "id": "ff66dc36-5be9-4b12-a94f-09421baed8da", "agentType": "endpoint", "agents": [ "1d793b46-7b6a-4dd4-a6b7-4c75718e04be", 1d793b46-7b6a-4dd4-a6b7-4c75718e04be ], "hosts": { "1d793b46-7b6a-4dd4-a6b7-4c75718e04be": { "name": "ashokaditya-dev-7131" } }, "command": "suspend-process", "startedAt": "2024-06-28T13:56:40.524Z", "isCompleted": false, "wasSuccessful": false, "isExpired": false, "status": "pending", "outputs": {}, "agentState": { "1d793b46-7b6a-4dd4-a6b7-4c75718e04be": { "isCompleted": false, "wasSuccessful": false } }, "createdBy": "elastic", "parameters": { "pid": 4242424242 } } } ``` **after** With this change when you try and send a request such as ```json5 POST /api/endpoint/action/suspend_process { "endpoint_ids": [ "1d793b46-7b6a-4dd4-a6b7-4c75718e04be", "1d793b46-7b6a-4dd4-a6b7-4c75718e04be", "no-dice" ] , "parameters": { "pid": 4242424242 } } ``` you get a response that looks like (notice neither the duplicate agent id nor the invalid agent id in `agents`, also additional WARNING in the `comment` field) ```json5 { "data": { "id": "9bf67816-4d58-4843-bc7a-776f6017b06b", "agentType": "endpoint", "agents": [ "1d793b46-7b6a-4dd4-a6b7-4c75718e04be" ], "hosts": { "1d793b46-7b6a-4dd4-a6b7-4c75718e04be": { "name": "ashokaditya-dev-7131" } }, "command": "suspend-process", "startedAt": "2024-06-28T15:13:20.138Z", "isCompleted": false, "wasSuccessful": false, "isExpired": false, "status": "pending", "outputs": {}, "agentState": { "1d793b46-7b6a-4dd4-a6b7-4c75718e04be": { "isCompleted": false, "wasSuccessful": false } }, "createdBy": "elastic", "comment": "undefined; WARNING: The following agent ids are not valid: [\"no-dice\"] and would not be included in action request.", "parameters": { "pid": 4242424242 } } } ``` follow up of /pull/186284 ### 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 ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information