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]>
This commit is contained in:
1 parent
9265e0d1c1
commit
b428ce9086
3 files changed
+67
No files matched your search
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/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}'."
|
||||
Reference in new issue
Block a user