Skip to main content

Downloads: http://pypi.python.org/pypi/django-anonymizer

Intro

This app helps you anonymize data in a database used for development of a Django project.

It is common practice in develpment to use a database that is very similar in content to the real data. The problem is that this can lead to having copies of sensitive customer data on development machines. This Django app helps by providing an easy and customizable way to anonymize data in your models.

The basic method is to go through all the models that you specify, and generate fake data for all the fields specified. Introspection of the models will produce an anonymizer that will attempt to provide sensible fake data for each field, leaving you to tweak for your needs.

Please note that the methods provided may not be able to give full anonymity. Even if you anonymize the names and other details of your customers, there may well be enough data to identify them. Relationships between records in the database are not altered, in order to preserve the characteristic structure of data in your application, but this may leave you open to information leaks which might not be acceptable for your data. This application should be good enough for simpler policies like ‘remove all real telephone numbers from the database’.

An alternative approach to the problem of realistic amounts of test data for development/tests is to populate a database from scratch - see django-poseur, django-mockups, django-eadred and django-autofixture. The disavantage of that method is that the structure of the data - in terms of related models - can be unrealistic.

Usage

Quick overview (see docs for more information, either in docs/ or on <http://packages.python.org/django-anonymizer>).

  • Install using setup.py or pip/easy_install.

  • Add ‘anonymizer’ to your INSTALLED_APPS setting.

  • Create some stub files for your anonymizers:

    ./manage.py create_anonymizers app_name1 [app_name2...]

    This will create a file anonymizers.py in each of the apps you specify. (It will not overwrite existing files).

  • Edit the generated anonymizers.py files, adjusting or deleting as necessary, using the functions in module anonymizer.replacers or custom functions.

  • Run the anonymizers:

    ./manage.py anonymize_data app_name1 [app_name2...]

    This will DESTRUCTIVELY UPDATE all your data. Make sure you only do this on a copy of your database, use at own risk, yada yada.

  • Note: your database may not actually delete the changed data from the disk when you update fields. For Postgresql you will need to VACUUM FULL to delete that data.

    And even then, your operating system may not delete the data from the disk. Properly getting rid of these traces is left as an excercise to the reader :-)

Tests

To run the test suite, do the following inside the folder containing this README:

./manage.py test anonymizers

or:

./manage.py test anonymizers.tests

Version 0.5.1

  • Added unicode compatibility for anonymizer.py files

  • Now with universal wheels

  • Added a new maintainer

Version 0.5

  • Python 3 compatibility

Version 0.4

  • Changed ‘Anonymizer.attributes’ to require every field to be listed. This is deal with the common security problem when a model is updated, but the Anonymizer is not updated.

    Fields that should not be anonymized should specify the special value “SKIP” as the ‘replacer’.

  • attributes must now be a list of tuples, not a dictionary.

Version 0.3

  • Support for DecimalField.

  • Improved docs.

  • Added tests

Version 0.2

  • Changed format of attributes from a dictionary to a list of 2-tuples (with backwards compatibility - previous format is deprecated).

  • Fixed small bug with names/usernames/emails sometimes not being generated in corresponding sets, due to fields with unique=True not being (reliably) set before other fields.

  • Added docs.

Version 0.1.2

  • Changed ‘varchar’ field to do max_length introspection at runtime. This breaks the previous signature of the function.

  • Introduced ‘replacers’ module and new shortcuts.

Version 0.1.1

  • Removed some debug code

  • Better handling of SlugField and skipped fields in introspection

Version 0.1

Initial release

Metadata

Release files for django-anonymizer 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-anonymizer 0.5.1
File Size Uploaded Provenance
django-anonymizer-0.5.1.tar.gz 21.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-anonymizer 0.5.1
File Interpreter ABI Platform
django_anonymizer-0.5.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 38.6 kB

Release files / django-anonymizer-0.5.1.tar.gz

Download URL django-anonymizer-0.5.1.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ad3e1265e6393055e9ed8c841380528d452a648bbd4ab7167d1d359accb6561b
BLAKE2b-256 checksum
How to use checksums
61bf27115fcd3c8de07b8dcd78c1cf83a826ccc784bb1fd9346a4f1bbd1d1647
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_anonymizer-0.5.1-py2.py3-none-any.whl

Download URL django_anonymizer-0.5.1-py2.py3-none-any.whl
Size 16.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e21b50fac2607853152c5fd3216fe3725bde96badb5567319574a01567e3397e
BLAKE2b-256 checksum
How to use checksums
056eda16d0984a28ad9c3ea258cc33ccf8131485ec7c3f3e08a90ff8e47285ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-anonymizer 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page