{"id":20859084,"url":"https://github.com/andersinno/django-sanitized-dump","last_synced_at":"2025-10-10T08:36:00.319Z","repository":{"id":45316250,"uuid":"125986669","full_name":"andersinno/django-sanitized-dump","owner":"andersinno","description":"Sanitize sensitive information from your database dumps 💩","archived":false,"fork":false,"pushed_at":"2023-09-20T14:17:05.000Z","size":98,"stargazers_count":14,"open_issues_count":7,"forks_count":5,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-08T15:22:55.534Z","etag":null,"topics":["database-dump","django"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andersinno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-20T08:44:05.000Z","updated_at":"2024-09-04T15:23:26.000Z","dependencies_parsed_at":"2022-08-28T13:52:37.105Z","dependency_job_id":null,"html_url":"https://github.com/andersinno/django-sanitized-dump","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fdjango-sanitized-dump","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fdjango-sanitized-dump/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fdjango-sanitized-dump/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersinno%2Fdjango-sanitized-dump/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andersinno","download_url":"https://codeload.github.com/andersinno/django-sanitized-dump/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225130741,"owners_count":17425506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-dump","django"],"created_at":"2024-11-18T04:48:35.583Z","updated_at":"2025-10-10T08:35:55.261Z","avatar_url":"https://github.com/andersinno.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-sanitized-dump\nSanitize sensitive information from your database dumps 💩\n\nSupports:\n- PostgreSQL\n- MySQL\n\n# Getting started\n\n1. `pip install django-sanitized-dump` or `pip install django-sanitized-dump[MySQL]` if you use MySQL\n2. Add `sanitized_dump` to `INSTALLED_APPS`\n3. Initialize config file: `./manage.py init_sanitizer`\n4. Check your newly created `.sanitizerconfig` file and modify the sanitation strategy to fit your requirements.\n5. Run `./manage.py check_sanitizerconfig` to verify that your `.sanitizerconfig` includes all models and fields\n6. Get sanitized database dump: `./manage.py create_sanitized_dump \u003e dump.sql`\n\n# DB Sanitation\n\nHeavy lifting of the DB sanitation is done by: https://github.com/andersinno/python-database-sanitizer\n\n### Configuration\n\nConfiguration file is used to define a strategy on how to sanitize your data. Strategy defines a sanitation function for each model field.\n\n#### Example config\n```yaml\nconfig:\n addons:\n   - \"ai-sanitizers\"\n   - \"some-other-lib\"\nstrategy:\n user:\n   first_name: \"name.first_name\"\n   last_name: \"name.last_name\"\n education:\n   created: null\n   modified: null\n   id: null\n   field: \"education.field\"\n   school: \"education.school\"\n   started: \"datetime.datetime\"\n   credits: null\n   information: \"string.loremipsum_preserved\"\n file_file: null\n```\n\n#### Example custom sanitizers\n```python\n# /sanitizers/name.py\ndef sanitize_first_name(value):\n    return faker.first_name()\n\ndef sanitize_last_name(value):\n    return faker.last_name()\n\n# /sanitizers/education.py\ndef sanitize_field(value):\n    return \"Some field\"\n\ndef sanitize_schoo(value):\n    return \"My school\"\n```\n\n#### Validating sanitizer return value\n\n\u003e Note: This should not be done in the initial implementation of the sanitizer but is up to the sanitizer functions. This is just a nice to have but not of a high priority.\n\nCheck that the returned value is of the same type as the argument value passed to the sanitizer.\nFor instance, if a MySQL DATETIME value is passed to the sanitizer, a MySQL DATETIME value shoud be returned as well.\n\n\n#### Configuration method resolution order\n\n1. Custom sanitizers inside ./sanitizers\n2. Addon sanitizers (`config.addons`)\n3. Core sanitizers\n\n### Django Management Commands\n\n#### Sanitized Dump\n\n`./manage.py create_sanitized_dump \u003e dump.sql`\n\n1. Warn about unhandled fields\n2. Creates a database dump (`mysqldump`/`pgdump`)\n3. Run sanitizer\n\n\n#### Check Sanitized Dump\n\n`./manage.py check_sanitizerconfig`\n\n1. Returns an error code if there are unhandled database fields\n\nCheck can be used in CI environments for detecting changes in models, that are not present in\nsanitizer configuration.\n\n\n#### Init Sanitizer\n\n`./manage.py init_sanitizer`\n\n1. Create configuration from current database state\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersinno%2Fdjango-sanitized-dump","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandersinno%2Fdjango-sanitized-dump","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersinno%2Fdjango-sanitized-dump/lists"}