Skip to main content

leukeleu-django-gdpr is a tool to generate GDPR documentation based on the project's models.

Project description

leukeleu-django-gdpr

Installation

pip install leukeleu-django-gdpr

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'leukeleu_django_gdpr',
    # ...
]

Usage:

On first run, leukeleu-django-gdpr will generate a gdpr.yml file with a models list. This is a list of models in your project, each containing a list of fields.

./manage.py gdpr

A file gdpr.yml is created in the project root directory. It should be added to version control. Each model in the models list has the following structure:

models:
  auth.User:
    name: User
    fields:
      username:
        name: Username
        description: String (up to %(max_length)s)
        help_text: Required. 150 characters or fewer. Letters, digits and @/./+/-/_
          only.
        required: true
        pii: null
      first_name:
        name: First Name
        description: String (up to %(max_length)s)
        help_text: ''
        required: false
        pii: null

Leukeleu-django-gdpr adds the pii: null to all fields. The objective is to replace all those null values with the correct boolean value; pii: true if the field represents PII data, pii: false otherwise.

When run again, leukeleu-django-gdpr will persist those values, allowing you to work your way to eliminating all pii: nulls.

Leukeleu-django-gdpr outputs counts of the pii: values when run:

./manage.py gdpr
Checking...
No PII set     48
PII True       1
PII False      0

Run with --check to make the command exit with exit code 1 if 'No PII set' > 0 (the yaml file will still be generated/updated).

You can prevent leukeleu-django-gdpr from writing (back) to the yaml file by running with the --dry-run flag.

Excluding/including

To exclude apps, models or fields from this process altogether, list them in the exclude: list in the yaml file. Each item is a regex which should match an object's string representation in the following formats;

  • for apps: the app's label, such as admin or auth.
  • for models: the model's label, such as admin.LogEntry or auth.Permission
  • for fields: the model's label followed by . followed by the field's name, such as auth.User.username.

Keep in mind that the items in the list are considered to be regexes which should fully match the object's string representation.

Default excludes

By default, leukeleu-django-gdpr excludes fields of the following types:

  • AutoField
  • UUIDField
  • BooleanField
  • RelatedField

and the following models:

  • ContentType

If you still want to include a field/model that would be excluded this way, you can put an item in the include: list in the yaml file:

include:
- clients\.Client\.external_epd_uuid
- accounts\.Profile\.is_pregnant

Checks

Leukeleu-django-gdpr adds a gdpr.I001 check to the check command. This check will fail if there are any pii: null values in the yaml file. To run the check, run:

./manage.py check

Pipelines

To run this in Bitbucket Pipelines you need to ensure this package can be installed from wherever this package is indexed. Run it with --check to make a (scheduled?) pipeline fail if there are unclassified fields, which can happen if someone adds a field to a model but forgets to mark it as (non-) PII in the gdpr.yml.

Reports

When run from a Bitbucket Pipeline, leukeleu-django-gdpr can send the PII stats as a report to Bitbucket. This will be visible in Pull Requests and Pipelines. Run with --report-pipeline to enable it.

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

leukeleu-django-gdpr-1.2.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

leukeleu_django_gdpr-1.2.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file leukeleu-django-gdpr-1.2.1.tar.gz.

File metadata

  • Download URL: leukeleu-django-gdpr-1.2.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for leukeleu-django-gdpr-1.2.1.tar.gz
Algorithm Hash digest
SHA256 41456fc90e0c3b359190e0f8755d01862855d2c0ea24c4663aa66af9642084dd
MD5 3454d3964e2d997c11359cdc867f9d7d
BLAKE2b-256 2df1c322274d734e21fa25a869ffb6e7c846d208fda51b2619e90ae7b921b815

See more details on using hashes here.

File details

Details for the file leukeleu_django_gdpr-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for leukeleu_django_gdpr-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd8a7e80a7b4711846e6c430e1eba4b6b5b230e505c0e25f2e0dce0121693a57
MD5 1589b6ed2a7a1bd5b3117e070086a148
BLAKE2b-256 2d383e6ea7985a483990aae63cbdcc80955b4c3b659953a4ca19536fb6903b36

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