[Security Solution][Admin][Responder] Disable responder option when metadata api returns an error (#137923)

This commit is contained in:
Candace Park 2022-08-08 17:12:37 -04:00 committed by GitHub
parent 92fb5dbafc
commit 604a18d0c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View file

@ -30,6 +30,10 @@ export const LOADING_ENDPOINT_DATA_TOOLTIP = i18n.translate(
'xpack.securitySolution.endpoint.detections.takeAction.responseActionConsole.loadingTooltip',
{ defaultMessage: 'Loading' }
);
export const METADATA_API_ERROR_TOOLTIP = i18n.translate(
'xpack.securitySolution.endpoint.detections.takeAction.responseActionConsole.generalMetadataErrorTooltip',
{ defaultMessage: 'Failed to retrieve Endpoint metadata' }
);
export interface ResponderContextMenuItemProps {
endpointId: string;
@ -62,16 +66,21 @@ export const ResponderContextMenuItem = memo<ResponderContextMenuItemProps>(
return [true, LOADING_ENDPOINT_DATA_TOOLTIP];
}
// if we got an error and it's a 400 (alerts can exist for endpoint that are no longer around)
// if we got an error and it's a 400 with unenrolled in the error message (alerts can exist for endpoint that are no longer around)
// or,
// the Host status is `unenrolled`
if (
(error && error.body?.statusCode === 400) ||
(error && error.body?.statusCode === 400 && error.body?.message.includes('unenrolled')) ||
endpointHostInfo?.host_status === HostStatus.UNENROLLED
) {
return [true, HOST_ENDPOINT_UNENROLLED_TOOLTIP];
}
// return general error tooltip
if (error) {
return [true, METADATA_API_ERROR_TOOLTIP];
}
return [false, undefined];
}, [endpointHostInfo, endpointId, error, isFetching, isResponderCapabilitiesEnabled]);

View file

@ -24,8 +24,8 @@ import { initialUserPrivilegesState as mockInitialUserPrivilegesState } from '..
import { useUserPrivileges } from '../../../common/components/user_privileges';
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
import {
HOST_ENDPOINT_UNENROLLED_TOOLTIP,
NOT_FROM_ENDPOINT_HOST_TOOLTIP,
HOST_ENDPOINT_UNENROLLED_TOOLTIP,
} from '../endpoint_responder/responder_context_menu_item';
import { endpointMetadataHttpMocks } from '../../../management/pages/endpoint_hosts/mocks';
import type { HttpSetup } from '@kbn/core/public';

View file

@ -15,6 +15,7 @@ import { HOST_METADATA_GET_ROUTE } from '../../../../common/endpoint/constants';
interface HttpResponse {
statusCode: number;
message: string;
}
/**