fix(export): no client names hardcoded in export_public.sh leak check
The leak-check grep pattern no longer contains (obfuscated) client names. Patterns are now derived at runtime from: - sibling variant theme folders (../<name>_vanilla, excluding this theme) - variants/leak-patterns.txt (gitignored; canonical copy in the private repo respondage_vanilla_variants) The export tar also excludes leak-patterns.txt, and the script was verified: export builds clean, and a planted client string is correctly detected. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
0ca0da8b1a
commit
d22abc8745
2 changed files with 27 additions and 3 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -4,3 +4,6 @@
|
|||
# variants/build.php at that folder (2nd CLI argument or RESPONDAGE_VARIANTS_DIR).
|
||||
variants/*.json
|
||||
variants/README.internal.md
|
||||
# extra leak-check patterns for variants/export_public.sh (client names/terms/colors);
|
||||
# the canonical copy lives in the private repo respondage_vanilla_variants
|
||||
variants/leak-patterns.txt
|
||||
|
|
|
|||
|
|
@ -31,12 +31,33 @@ mkdir -p "$STAGE" "$OUT_DIR"
|
|||
|
||||
# 1. copy the theme, excluding .git, client variant definitions, the internal
|
||||
# variants README and old exports (the generic build/export scripts are kept)
|
||||
(cd "$THEME_DIR" && tar --exclude='./.git' --exclude='./dist' --exclude='./variants/*.json' --exclude='./variants/README.internal.md' -cf - .) | (cd "$STAGE" && tar -xf -)
|
||||
(cd "$THEME_DIR" && tar --exclude='./.git' --exclude='./dist' --exclude='./variants/*.json' --exclude='./variants/README.internal.md' --exclude='./variants/leak-patterns.txt' -cf - .) | (cd "$STAGE" && tar -xf -)
|
||||
|
||||
# 2. leak check: no client-identifying strings may remain (text files only).
|
||||
# The bracket trick keeps this script from matching its own pattern.
|
||||
if grep -rIlE 'eras[m]us|defen[s]ie|rijk[s]logo' "$STAGE"; then
|
||||
# Client names are NOT hardcoded in this public file. Patterns are derived:
|
||||
# - the names of sibling variant theme folders (../<name>_vanilla next to
|
||||
# this theme, excluding this theme itself);
|
||||
# - extra patterns (names, terms, hex colors) from variants/leak-patterns.txt,
|
||||
# one regex per line. That file is gitignored here and lives in the PRIVATE
|
||||
# variants repository (respondage_vanilla_variants).
|
||||
PATTERNS=""
|
||||
MOTHER_NAME="$(basename "$THEME_DIR")"
|
||||
for d in "$THEME_DIR"/../*_vanilla; do
|
||||
[ -d "$d" ] || continue
|
||||
name="$(basename "$d")"
|
||||
[ "$name" = "$MOTHER_NAME" ] && continue
|
||||
PATTERNS="$PATTERNS|$name"
|
||||
done
|
||||
if [ -f "$THEME_DIR/variants/leak-patterns.txt" ]; then
|
||||
while IFS= read -r line; do
|
||||
case "$line" in ''|\#*) continue ;; esac
|
||||
PATTERNS="$PATTERNS|$line"
|
||||
done < "$THEME_DIR/variants/leak-patterns.txt"
|
||||
fi
|
||||
PATTERNS="${PATTERNS#|}"
|
||||
if [ -n "$PATTERNS" ] && grep -rIlE "$PATTERNS" "$STAGE"; then
|
||||
echo "ERROR: client-identifying strings found in the public export - aborting, staging removed." >&2
|
||||
echo "(patterns came from sibling *_vanilla folders and variants/leak-patterns.txt)" >&2
|
||||
rm -rf "$STAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue