From ef74347ebdac143ecb4322eff8f15f1489e6af2e Mon Sep 17 00:00:00 2001 From: Montse Ortega Date: Wed, 21 Feb 2024 13:50:21 +0100 Subject: [PATCH] Change regexp to validate SSH keys (#2499) --- .../lib/common/components/ui/formik/validationSchemas.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts b/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts index f7cc50088d..e36102cb3a 100644 --- a/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts +++ b/libs/ui-lib/lib/common/components/ui/formik/validationSchemas.ts @@ -36,7 +36,7 @@ const NAME_CHARS_REGEX = /^[a-z0-9-.]*$/; const CLUSTER_NAME_START_END_REGEX = /^[a-z0-9](.*[a-z0-9])?$/; const CLUSTER_NAME_VALID_CHARS_REGEX = /^[a-z0-9-]*$/; const SSH_PUBLIC_KEY_REGEX = - /^(ssh-rsa|ssh-ed25519|ecdsa-[-a-z0-9]*) AAAA[0-9A-Za-z+/]+[=]{0,3}( .+)?$/; + /^(ssh-rsa AAAAB3NzaC1yc2|ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNT|ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzOD|ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1Mj|ssh-ed25519 AAAAC3NzaC1lZDI1NTE5|ssh-dss AAAAB3NzaC1kc3)[0-9A-Za-z+/]+[=]{0,3}( .*)?$/; const DNS_NAME_REGEX = /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/; const PROXY_DNS_REGEX = @@ -117,7 +117,7 @@ export const sshPublicKeyValidationSchema = Yup.string().test( export const sshPublicKeyListValidationSchema = Yup.string() .test( 'ssh-public-keys', - 'SSH public keys separated by newlines must consist of "[TYPE] key [[EMAIL]]", supported types are: ssh-rsa, ssh-ed25519, ecdsa-[VARIANT].', + 'SSH public key must consist of "[TYPE] key [[EMAIL]]", supported types are: ssh-rsa, ssh-ed25519, ecdsa-[VARIANT].', (value: string) => { if (!value) { return true;