Skip to content

[Security Solution][Endpoint] Show consistent Endpoint Agent Status across security solution#154961

Merged
paul-tavares merged 37 commits intoelastic:mainfrom
paul-tavares:task/olm-6308-add-new-response-actions-to-pending-actions
Apr 19, 2023
Merged

[Security Solution][Endpoint] Show consistent Endpoint Agent Status across security solution#154961
paul-tavares merged 37 commits intoelastic:mainfrom
paul-tavares:task/olm-6308-add-new-response-actions-to-pending-actions

Conversation

@paul-tavares
Copy link
Copy Markdown
Contributor

@paul-tavares paul-tavares commented Apr 13, 2023

Summary

  • PR refactors the display of the Endpoint Host Agent status across the multiple places in Security solution so that it uses 1 common component. The Status of an Endpoint Host also displays the isolation state of the endpoint along with any other Actions that might be pending against it.

  • The refactor also address a prior issue where new added response actions were not accounted for when the component displays (on hover in a popover) the itemized count of pending response actions against the host. The new implementation will display the summary of all pending actions going forward as they are added without having to remember to update the Component.

  • The Endpoint host agent pending actions display was also adjusted to ensure that isolation state is primary shown when there are multiple pending actions, so that its always visible to the user the state of isolation (see GIF below)

As a result of the refactor, several redundant components were deleted.

Pages that display Endpoint Host Agent status, and thus impacted by these changes, are:

  • Endpoint List
  • Endpoint Details flyout
  • Responder
  • Alert Details
  • Host Details

Screen capture:

Different condition for displaying isolation state:

olm-6308-endpoint-agent-status


Endpoint List:

image


Endpoint Details:

image


Alert Details:

image


Host overview:

image


Timeline:
image


Case:

image


Checklist

@paul-tavares paul-tavares added release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.8.0 labels Apr 13, 2023
@paul-tavares paul-tavares self-assigned this Apr 13, 2023
Comment on lines +204 to 207
hostInfo: endpointData,
endpointPolicy: endpointData.metadata.Endpoint.policy.applied.name,
policyStatus: endpointData.metadata.Endpoint.policy.applied.status,
sensorVersion: endpointData.metadata.agent.version,
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.

If we put everything into the hostInfo entry, why do we need to have the other 3? Looks like we send redundant data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@semd - True. I was waiting for a response from the 'security-threat-hunting' on whether we needed to maintain backwards compatibility in this API. Looks like Pablo replied today and based on his response, I plan to remove the extra data here in a subsequent PR (don't want to increase the scope of this one)

Copy link
Copy Markdown
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

The threat-hunting-explore team code looks good to me.

metadata: HostMetadata;
// Host Information as return by the Host Details API.
// NOTE: `HostInfo` type is the original and defined as Immutable. If needing to
// work with data that is not mutable, use `HostInfo` instead
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This message is confusing. It sounds like you are telling me to use HostInfo instead of HostInfo. 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, this does not sound like a clear message. I'll change it in my next PR or this one if I end up making another change.
Thanks for the feedback.

@paul-tavares paul-tavares requested review from ashokaditya and removed request for patrykkopycinski April 18, 2023 12:03
Copy link
Copy Markdown
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

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

Nice work!

@paul-tavares paul-tavares requested review from joeypoon and removed request for gergoabraham April 18, 2023 12:16
Copy link
Copy Markdown
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

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

I've looked at the code changes partially. Will give it another go a bit later. I tested it out locally with emulator data and I'm seeing some inconsistency with the isolated badge when isolated. It says isolating... and then shows nothing sometimes and switches to isolated. Also, when released it shows isolated even after it is released. Here are a few clips I managed to record while testing locally.

Not sure if you saw it too.

badge doesn't show up until flyout is closed.
isolating

doesn't show isolated badge after isolating (goes into a "release"d UI without a badge and then shows isolated)
(have to see the clip a little further after the actions fail)
isolation

still shows isolated badge after release
release

Comment on lines +81 to +89
>({
isolate: 'isolate',
unisolate: 'release',
execute: 'execute',
'get-file': 'get-file',
'running-processes': 'processes',
'kill-process': 'kill-process',
'suspend-process': 'suspend-process',
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can also use lodash zipObject here e.g. Object.freeze(zipObject(RESPONSE_ACTION_API_COMMANDS_NAMES, CONSOLE_RESPONSE_ACTION_COMMANDS)). We'd need to ensure that the values in those two consts (RESPONSE_ACTION_API_COMMANDS_NAMES and CONSOLE_RESPONSE_ACTION_COMMANDS) are in the same order if you decide to use zipObject. Perhaps with comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Had not known about that lodash function. I kind of prefer this here only because it's its clearer what the values are and I don['t have to worry about the ordering of items in the arrays.


export type HostInfo = Immutable<{
metadata: HostMetadata;
// Host Information as return by the Host Details API.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: ...returned...

return merge(hostMetadataDoc, overrides);
}

/** Generates the complete `HostInfo` as return by a call to the Endpoint host details api */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: ...as returned by...

EuiTextColor,
EuiToolTip,
} from '@elastic/eui';
import styled from 'styled-components';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't have to change but eui also exports a euiStyled that you can use.
import { euiStyled } from '@kbn/kibana-react-plugin/common'; Then you can use it the same way as we use styled

euiStyled(EuiFlexGroup) or euiStyled.div etc.

import { getAgentStatusText } from '../agent_status_text';

const TOOLTIP_CONTENT_STYLES: React.CSSProperties = Object.freeze({ width: 150 });
const AUTO_REFRESH_INTERVAL = 10000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is same as the DEFAULT_POLL_INTERVAL. No?

import { getAgentStatusText } from '../agent_status_text';

const TOOLTIP_CONTENT_STYLES: React.CSSProperties = Object.freeze({ width: 150 });
const AUTO_REFRESH_INTERVAL = 10000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is same as the DEFAULT_POLL_INTERVAL. No?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I think that's a common const so I will use that instead

* If set to `true` (Default), then the endpoint isolation state and response actions count
* will be kept up to date by querying the API periodically
*/
autoFresh?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe name thisauotRefresh instead for naming consistency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ahhh. Crap. Yeah, I meant to rename that and forgot. Will do it

@paul-tavares
Copy link
Copy Markdown
Contributor Author

@ashokaditya ,

Thanks for the reviews.
I have pushed through another update that includes most of your comments.

Re:

badge doesn't show up until flyout is closed

This is a known problem. The list currently only refreshes the data when the details flyout is closed. I think we might have an issue tracking this.

re:

doesn't show isolated badge after isolating (goes into a "release"d UI without a badge and then shows isolated)

And

still shows isolated badge after release

I will take a closer look at these, but I'm guessing they are due to how the component is being used from the endpoint list/details. The isolation state is given through using the data the list/details retrieves from the API, while the actions are auto-retrieved from inside of the component. So the isolation state (which comes from the Endpoint Metadata) might be taking a bit longer to update because of that refresh interval on the list.

I'm also wondering if what you highlighted here also exists prior to my changes 🤔

@paul-tavares
Copy link
Copy Markdown
Contributor Author

@ashokaditya ,
So I think the issue is that I moved the sync of pending actions to the Component itself, which means that the refresh of the metadata -vs- the refresh of the pending actions is not sync'd up, thus why you are seeing inconsistencies.
I'm also finding that for the Endpoint list, this new component is not as efficient because it makes an API call to the pending actions status API for each host, while on the Endpoint list it makes only 1 single call to the pending actions api requesting the status of all of the endpoints in the current page of data.

I'm going to see if I can still address this today, but if not, then I can put up a separate PR to only add the execute and get-file actions to the pending list 😞

@paul-tavares
Copy link
Copy Markdown
Contributor Author

paul-tavares commented Apr 18, 2023

Ok. I made some changes that I think will mitigate the issues you were seeing on the Endpoint list/details (FYI: can't wait until we rip out Redux stuff out this area of the code).

There are still issues with refreshing the list data while the flyout is opened, but at least now the refreshed data (including the pending actions) are passed directly to the EndpointAgentStatus which should keep things in sync.

Also - FYI: the emulator seems to have some issues with sending the metadata update after an isolate/release response action. I'm not sure what the issue is (maybe timestamps and transform dropping the document?), but I tested with a real endpoint and it seem ok.

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 3826 3821 -5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 16.0MB 9.0MB -6.9MB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 58.3KB 58.3KB +2.0B
Unknown metric groups

async chunk count

id before after diff
securitySolution 42 41 -1

ESLint disabled line counts

id before after diff
securitySolution 432 435 +3

Total ESLint disabled count

id before after diff
securitySolution 512 515 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @paul-tavares

Copy link
Copy Markdown
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

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

I tested it out a couple more times. I am kind of seeing similar behavior on the endpoint list as I'm seeing on the main branch. There are still sometimes when I see the Isolating badge disappearing for a couple of seconds before Isolated badge shows up.

I'm not seeing the pending actions badge on the Hosts page on auto-refresh.

on main
Screenshot 2023-04-19 at 17 13 20

We talked offline. The changes look alright on the PR

* If set to `true` (Default), then the endpoint status and isolation/action counts will
* be kept up to date by querying the API periodically
*/
autoFresh?: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe you missed this one. We can alsochange in a new PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FYI: Done in #155455

@paul-tavares paul-tavares merged commit e35a1d4 into elastic:main Apr 19, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Apr 19, 2023
@paul-tavares paul-tavares deleted the task/olm-6308-add-new-response-actions-to-pending-actions branch April 19, 2023 15:40
paul-tavares added a commit that referenced this pull request May 8, 2023
…se and remove redundant endpoint data (#156709)

## Summary

- Removes several pieces of data from the Host Details search strategy
response that is now available via the `hostInfo` property of the data
returned.

This PR is a follow up from
#154961 (comment)
ashokaditya added a commit to ashokaditya/kibana that referenced this pull request Jun 29, 2023
related to changes in elastic/pull/154961 where `endpointDetails.hostInfo` was added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants