Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Finishing touches + undo RE2 removal

x032205f711f8a35c5b
diff --git a/.github/workflows/check-non-re2-regex.yml b/.github/workflows/check-non-re2-regex.yml
index b4bccb7536..11d8ea0372 100644
--- a/.github/workflows/check-non-re2-regex.yml
+++ b/.github/workflows/check-non-re2-regex.yml
@@ -15,29 +15,24 @@ jobs:
- name: Get diff of backend/*
run: |
- echo "Fetching base ref: ${{ github.base_ref }}"
-
- echo "Generating diff for backend/ directory against origin/${{ github.base_ref }}"
git diff --unified=0 "origin/${{ github.base_ref }}"...HEAD -- backend/ > diff.txt
- name: Scan backend diff for non-RE2 regex
run: |
- echo "Scanning added/modified lines in backend/ for raw regex literals..."
grep '^+' diff.txt | grep -v '^+++' | sed 's/^\+//' > added_lines.txt
if [ ! -s added_lines.txt ]; then
- echo "No relevant lines added or modified in backend/ found in the diff."
echo "✅ No raw regex literals to check in backend."
exit 0
fi
raw_regex_pattern='(^|[^A-Za-z0-9_])\/[^\/]+\/[gimsuy]*'
- # First, find all added lines that contain the raw_regex_pattern.
+ # Find all added lines that contain the raw_regex_pattern.
grep -E "$raw_regex_pattern" added_lines.txt > potential_violations.txt
if [ -s potential_violations.txt ]; then # If any lines match the raw regex pattern
- # From these potential violations, filter out lines that also contain the string 'new RE2'.
+ # Filter out lines that also contain the string 'new RE2'.
grep -v 'new RE2' potential_violations.txt > actual_violations.txt
if [ -s actual_violations.txt ]; then # If there are lines left after filtering out 'new RE2'
diff --git a/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts b/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts
index 5a5af935de..f9096ac711 100644
--- a/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts
+++ b/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts
@@ -23,7 +23,7 @@ const HCVaultSyncDestinationConfigSchema = z.object({
.trim()
.min(1, "Path required")
.max(128)
- .transform((val) => val.replace(/^\/+|\/+$/g, "")) // removes leading/trailing slashes
+ .transform((val) => new RE2("^/+|/+$", "g").replace(val, "")) // removes leading/trailing slashes
.refine((val) => new RE2("^([a-zA-Z0-9._-]+/)*[a-zA-Z0-9._-]+$").test(val), {
message:
"Invalid Vault path format. Use alphanumerics, dots, dashes, underscores, and single slashes between segments."