Skip to main content

No project description provided

Project description

Django Birdbath

A simple tool for giving Django database data a good wash. Anonymise user data, delete stuff you don't need in your development environment, or whatever it is you need to do.

Usage

  1. Add birdbath to your INSTALLED_APPS
  2. Set BIRDBATH_CHECKS and BIRDBATH_PROCESSORS as appropriate in your settings file (see Configuration below).
  3. Run ./manage.py run_birdbath to trigger processors.

Important! The default processors are destructive and will anonymise User emails and passwords. Do not run in production!

By default, Birdbath enables a Django system check which will trigger an error if a Birdbath cleanup has not been triggered on the current environment.

This is intended to give developers a hint that they need to anonymise/cleanup their data before running commands such as runserver.

The suggested approach is to set BIRDBATH_REQUIRED to False in production environments using an environment variable.

Configuration

Common Settings

  • BIRDBATH_REQUIRED (default: True) - if True, a Django system check will throw an error if anonymisation has not been executed. Set to False in your production environments.
  • BIRDBATH_CHECKS - a list of paths to 'Check' classes to be executed before processors. If any of these returns False, the processors will refuse to run.
  • BIRDBATH_PROCESSORS - a list of paths to 'Processor' classes to be executed to clean data.
  • BIRDBATH_SKIP_CHECKS (default: False) - if True, checks will be skipped and processors will be ran immediately.

Processor Specific Settings

  • BIRDBATH_USER_ANONYMISER_EXCLUDE_EMAIL_RE (default: example\.com$) - A regex pattern which will be used to exclude users that match a certain email address when anonymising.
  • BIRDBATH_USER_ANONYMISER_EXCLUDE_SUPERUSERS (default: True) - If True, users with is_superuser set to True will be excluded from anonymisation.

Implementing your Own

Your site will probably have some of your own check/processor needs.

Checks

Custom checks can be implemented by subclassing birdbath.checks.BaseCheck and implementing the check method:

from birdbath.checks import BaseCheck

class IsDirtyCheck(BaseCheck):
    def check(self):
        return os.environ.get("IS_DIRTY")

The check method should either return True if the checks should continue, or False to stop checking and prevent processors from running.

Processors

Custom processors can be implemented by subclassing birdbath.processors.BaseProcessor and implementing the run method:

from birdbath.processors import BaseProcessor

class DeleteAllMyUsersProcessor(BaseProcessor):
    def run(self):
        User.objects.all().delete()

Check/Processor Reference

Checks

  • checks.contrib.heroku.HerokuNotProductionCheck - fails if the HEROKU_APP_NAME environment variable is not set, or if it set and includes the word production.

Processors

  • processors.users.UserEmailAnonymiser - replaces user email addresses with randomised addresses
  • processors.users.UserPasswordAnonymiser - replaces user passwords with random UUIDs
  • processors.contrib.wagtail.SearchQueryCleaner - removes the full search query history
  • processors.contrib.wagtail.FormSubmissionCleaner - removes all form submissions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-birdbath-0.0.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

django_birdbath-0.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file django-birdbath-0.0.1.tar.gz.

File metadata

  • Download URL: django-birdbath-0.0.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for django-birdbath-0.0.1.tar.gz
Algorithm Hash digest
SHA256 13c310fadf1a0ed30b548fb1aa22909ab21900509dc9efa679f0b9778a8df72f
MD5 8fe5b400bfb7d40ecdfa46c31fcfd6c3
BLAKE2b-256 b161bc2abd77156bd0a836c53e1dcb6bd4fe6ce6adadfcdb1786e2ba865dcdfd

See more details on using hashes here.

File details

Details for the file django_birdbath-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_birdbath-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for django_birdbath-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54266ba4945cd2a305885c35eac4c70da6dc00cb3cbf29d11f4854bcee401598
MD5 2cdb9dfee14364dfc2f73e0150ccf88f
BLAKE2b-256 0b3a3479fa8c546557745b3d6f8dab0ced6f6993860fd038fdf9ddf81f48d759

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page