Files
typo3-13/.ddev/commands/web/anonymize-db
T
frommeandClaude Opus 5.5 b428ce9086 feat: ddev anonymize-db removes personal data from production dumps
Runs automatically after every `ddev import-db`. Drops all zzz_deleted_
tables (renamed in production but still holding their data, e.g. the
retired address check and form answers), replaces names and emails of
backend and frontend users, sets every password to the local dev
password "password" and clears reset tokens and MFA secrets. Sessions,
record locks, CSP reports and logs are emptied (IP addresses, user
agents). Usernames stay, so everybody logs in locally as their own user.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 10:13:02 +01:00

20 lines
582 B
Bash
Executable File

#!/usr/bin/env bash
## Description: Remove personal data from the imported production database
## Usage: anonymize-db
## Example: "ddev anonymize-db"
set -euo pipefail
DEV_PASSWORD=password
# TYPO3 verifies argon2i hashes with plain password_verify()
hash=$(php -r 'echo password_hash($argv[1], PASSWORD_ARGON2I);' "$DEV_PASSWORD")
{
echo "SET @devPasswordHash = '${hash}';"
cat /var/www/html/.ddev/anonymize-db.sql
} | mysql --host=db --user=db --password=db db
echo "Database anonymized. Backend users log in with their username and the password '${DEV_PASSWORD}'."