From 2f47951c6994c3a611dcb6364a05de59b1d22314 Mon Sep 17 00:00:00 2001 From: chrisronline Date: Fri, 17 Jul 2020 13:01:54 -0400 Subject: [PATCH 1/4] Fix the copy --- .../public/alerts/lib/security_toasts.tsx | 81 +------------------ 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx index 918c0b5c9b609..ec826a95fd3c6 100644 --- a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx +++ b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx @@ -30,11 +30,10 @@ const showTlsAndEncryptionError = () => {

{i18n.translate('xpack.monitoring.healthCheck.tlsAndEncryptionError', { - defaultMessage: `You must enable Transport Layer Security between Kibana and Elasticsearch - and configure an encryption key in your kibana.yml file to use the Alerting feature.`, + defaultMessage: `Stack monitoring alerts require Transport Layer Security between Kibana and Elasticsearch and an encryption key in your kibana.yml file.`, })}

- + { }); }; -const showEncryptionError = () => { - const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks; - - Legacy.shims.toastNotifications.addWarning( - { - title: toMountPoint( - - ), - text: toMountPoint( -
- {i18n.translate('xpack.monitoring.healthCheck.encryptionErrorBeforeKey', { - defaultMessage: 'To create an alert, set a value for ', - })} - - {'xpack.encryptedSavedObjects.encryptionKey'} - - {i18n.translate('xpack.monitoring.healthCheck.encryptionErrorAfterKey', { - defaultMessage: ' in your kibana.yml file. ', - })} - - {i18n.translate('xpack.monitoring.healthCheck.encryptionErrorAction', { - defaultMessage: 'Learn how.', - })} - -
- ), - }, - {} - ); -}; - -const showTlsError = () => { - const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks; - - Legacy.shims.toastNotifications.addWarning({ - title: toMountPoint( - - ), - text: toMountPoint( -
- {i18n.translate('xpack.monitoring.healthCheck.tlsError', { - defaultMessage: - 'Alerting relies on API keys, which require TLS between Elasticsearch and Kibana. ', - })} - - {i18n.translate('xpack.monitoring.healthCheck.tlsErrorAction', { - defaultMessage: 'Learn how to enable TLS.', - })} - -
- ), - }); -}; - export const showSecurityToast = (alertingHealth: AlertingFrameworkHealth) => { const { isSufficientlySecure, hasPermanentEncryptionKey } = alertingHealth; if ( @@ -127,11 +58,5 @@ export const showSecurityToast = (alertingHealth: AlertingFrameworkHealth) => { return; } - if (!isSufficientlySecure && !hasPermanentEncryptionKey) { - showTlsAndEncryptionError(); - } else if (!isSufficientlySecure) { - showTlsError(); - } else if (!hasPermanentEncryptionKey) { - showEncryptionError(); - } + showTlsAndEncryptionError(); }; From 9135ccb78e24fd9d63272b35f3da4015a4725a85 Mon Sep 17 00:00:00 2001 From: chrisronline Date: Fri, 17 Jul 2020 14:49:07 -0400 Subject: [PATCH 2/4] Fix type issues --- .../plugins/monitoring/public/alerts/lib/security_toasts.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx index ec826a95fd3c6..a8e3d04d7576f 100644 --- a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx +++ b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiSpacer, EuiLink, EuiCode, EuiText } from '@elastic/eui'; +import { EuiSpacer, EuiLink } from '@elastic/eui'; import { Legacy } from '../../legacy_shims'; import { toMountPoint } from '../../../../../../src/plugins/kibana_react/public'; @@ -49,7 +49,6 @@ const showTlsAndEncryptionError = () => { }; export const showSecurityToast = (alertingHealth: AlertingFrameworkHealth) => { - const { isSufficientlySecure, hasPermanentEncryptionKey } = alertingHealth; if ( Array.isArray(alertingHealth) || (!alertingHealth.hasOwnProperty('isSufficientlySecure') && From f5f8762017d3264acb5031330f10459c0ae0f99f Mon Sep 17 00:00:00 2001 From: chrisronline Date: Mon, 20 Jul 2020 13:48:04 -0400 Subject: [PATCH 3/4] PR feedback --- .../monitoring/public/alerts/lib/security_toasts.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx index a8e3d04d7576f..006268104f7e3 100644 --- a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx +++ b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx @@ -30,7 +30,7 @@ const showTlsAndEncryptionError = () => {

{i18n.translate('xpack.monitoring.healthCheck.tlsAndEncryptionError', { - defaultMessage: `Stack monitoring alerts require Transport Layer Security between Kibana and Elasticsearch and an encryption key in your kibana.yml file.`, + defaultMessage: `Stack monitoring alerts require Transport Layer Security between Kibana and Elasticsearch, and an encryption key in your kibana.yml file.`, })}

@@ -57,5 +57,7 @@ export const showSecurityToast = (alertingHealth: AlertingFrameworkHealth) => { return; } - showTlsAndEncryptionError(); + if (!isSufficientlySecure || !hasPermanentEncryptionKey) { + showTlsAndEncryptionError(); + } }; From 5c2fe230083ccbd60e20ebca6ea03554a403af2e Mon Sep 17 00:00:00 2001 From: chrisronline Date: Mon, 20 Jul 2020 14:21:52 -0400 Subject: [PATCH 4/4] Add missing code --- x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx index 006268104f7e3..2850a5b772c32 100644 --- a/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx +++ b/x-pack/plugins/monitoring/public/alerts/lib/security_toasts.tsx @@ -49,6 +49,8 @@ const showTlsAndEncryptionError = () => { }; export const showSecurityToast = (alertingHealth: AlertingFrameworkHealth) => { + const { isSufficientlySecure, hasPermanentEncryptionKey } = alertingHealth; + if ( Array.isArray(alertingHealth) || (!alertingHealth.hasOwnProperty('isSufficientlySecure') &&