[Security Solution][Endpoint][Host Isolation] Fixes bug where Isolate Host option is missing from alert details take actions menu (#109991) (#110106)
Co-authored-by: Candace Park <56409205+parkiino@users.noreply.github.com>
This commit is contained in:
parent
132a67cd8f
commit
53ed133ed0
|
@ -13,7 +13,7 @@ import { useIsolationPrivileges } from '../../../common/hooks/endpoint/use_isola
|
|||
import { endpointAlertCheck } from '../../../common/utils/endpoint_alert_check';
|
||||
import { useHostIsolationStatus } from '../../containers/detection_engine/alerts/use_host_isolation_status';
|
||||
import { ISOLATE_HOST, UNISOLATE_HOST } from './translations';
|
||||
import { getFieldValue, getFieldValues } from './helpers';
|
||||
import { getFieldValue } from './helpers';
|
||||
|
||||
interface UseHostIsolationActionProps {
|
||||
closePopover: () => void;
|
||||
|
@ -47,29 +47,21 @@ export const useHostIsolationAction = ({
|
|||
[detailsData]
|
||||
);
|
||||
|
||||
const hostCapabilities = useMemo(
|
||||
() =>
|
||||
getFieldValues(
|
||||
{ category: 'Endpoint', field: 'Endpoint.capabilities' },
|
||||
detailsData
|
||||
) as string[],
|
||||
[detailsData]
|
||||
);
|
||||
|
||||
const isolationSupported = isIsolationSupported({
|
||||
osName: hostOsFamily,
|
||||
version: agentVersion,
|
||||
capabilities: hostCapabilities,
|
||||
});
|
||||
|
||||
const {
|
||||
loading: loadingHostIsolationStatus,
|
||||
isIsolated: isolationStatus,
|
||||
agentStatus,
|
||||
capabilities,
|
||||
} = useHostIsolationStatus({
|
||||
agentId,
|
||||
});
|
||||
|
||||
const isolationSupported = isIsolationSupported({
|
||||
osName: hostOsFamily,
|
||||
version: agentVersion,
|
||||
capabilities,
|
||||
});
|
||||
|
||||
const { isAllowed: isIsolationAllowed } = useIsolationPrivileges();
|
||||
|
||||
const isolateHostHandler = useCallback(() => {
|
||||
|
|
|
@ -14,6 +14,7 @@ import { HostStatus } from '../../../../../common/endpoint/types';
|
|||
|
||||
interface HostIsolationStatusResponse {
|
||||
loading: boolean;
|
||||
capabilities: string[];
|
||||
isIsolated: boolean;
|
||||
agentStatus: HostStatus | undefined;
|
||||
pendingIsolation: number;
|
||||
|
@ -28,6 +29,7 @@ export const useHostIsolationStatus = ({
|
|||
agentId: string;
|
||||
}): HostIsolationStatusResponse => {
|
||||
const [isIsolated, setIsIsolated] = useState<boolean>(false);
|
||||
const [capabilities, setCapabilities] = useState<string[]>([]);
|
||||
const [agentStatus, setAgentStatus] = useState<HostStatus>();
|
||||
const [pendingIsolation, setPendingIsolation] = useState(0);
|
||||
const [pendingUnisolation, setPendingUnisolation] = useState(0);
|
||||
|
@ -45,6 +47,9 @@ export const useHostIsolationStatus = ({
|
|||
const metadataResponse = await getHostMetadata({ agentId, signal: abortCtrl.signal });
|
||||
if (isMounted) {
|
||||
setIsIsolated(isEndpointHostIsolated(metadataResponse.metadata));
|
||||
if (metadataResponse.metadata.Endpoint.capabilities) {
|
||||
setCapabilities([...metadataResponse.metadata.Endpoint.capabilities]);
|
||||
}
|
||||
setAgentStatus(metadataResponse.host_status);
|
||||
fleetAgentId = metadataResponse.metadata.elastic.agent.id;
|
||||
}
|
||||
|
@ -84,5 +89,5 @@ export const useHostIsolationStatus = ({
|
|||
abortCtrl.abort();
|
||||
};
|
||||
}, [agentId]);
|
||||
return { loading, isIsolated, agentStatus, pendingIsolation, pendingUnisolation };
|
||||
return { loading, capabilities, isIsolated, agentStatus, pendingIsolation, pendingUnisolation };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue