Finishing touches + undo RE2 removal

This commit is contained in:
x032205
2025-05-31 01:14:37 -04:00
parent 9c8bb71878
commit f711f8a35c
2 changed files with 3 additions and 8 deletions

View File

@@ -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'

View File

@@ -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."