From 9d682ca874d927e2681c76211d8b5923b1cd896a Mon Sep 17 00:00:00 2001 From: x032205 Date: Fri, 9 May 2025 02:10:53 -0400 Subject: [PATCH] added RE2 to regex --- .../oci-vault/oci-vault-sync-schemas.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/src/services/secret-sync/oci-vault/oci-vault-sync-schemas.ts b/backend/src/services/secret-sync/oci-vault/oci-vault-sync-schemas.ts index 2b82da4ea..84a58bc8a 100644 --- a/backend/src/services/secret-sync/oci-vault/oci-vault-sync-schemas.ts +++ b/backend/src/services/secret-sync/oci-vault/oci-vault-sync-schemas.ts @@ -1,3 +1,4 @@ +import RE2 from "re2"; import { z } from "zod"; import { SecretSyncs } from "@app/lib/api-docs"; @@ -15,8 +16,8 @@ const OCIVaultSyncDestinationConfigSchema = z.object({ .string() .trim() .min(1, "Compartment OCID required") - .regex( - /^ocid1\.(tenancy|compartment)\.oc1\..+$/, + .refine( + (val) => new RE2("^ocid1\\.(tenancy|compartment)\\.oc1\\..+$").test(val), "Invalid Compartment OCID format. Must start with ocid1.tenancy.oc1. or ocid1.compartment.oc1." ) .describe(SecretSyncs.DESTINATION_CONFIG.OCI_VAULT.compartmentOcid), @@ -24,13 +25,19 @@ const OCIVaultSyncDestinationConfigSchema = z.object({ .string() .trim() .min(1, "Vault OCID required") - .regex(/^ocid1\.vault\.oc1\..+$/, "Invalid Vault OCID format. Must start with ocid1.vault.oc1.") + .refine( + (val) => new RE2("^ocid1\\.vault\\.oc1\\..+$").test(val), + "Invalid Vault OCID format. Must start with ocid1.vault.oc1." + ) .describe(SecretSyncs.DESTINATION_CONFIG.OCI_VAULT.vaultOcid), keyOcid: z .string() .trim() .min(1, "Key OCID required") - .regex(/^ocid1\.key\.oc1\..+$/, "Invalid Key OCID format. Must start with ocid1.key.oc1.") + .refine( + (val) => new RE2("^ocid1\\.key\\.oc1\\..+$").test(val), + "Invalid Key OCID format. Must start with ocid1.key.oc1." + ) .describe(SecretSyncs.DESTINATION_CONFIG.OCI_VAULT.keyOcid) });