Skip to main content

A robust data anonymization and sanitization tool for CLI and Django.

Project description

py-cloak

py-cloak is a robust, rule-based data anonymization and sanitization engine that works seamlessly on static files (CSV/JSON/SQL dumps) via CLI and integrates natively into the Django ORM for "safe dumps."

Features

  • Declarative Ruleset: Define how to mask data using YAML or Python dictionaries.
  • Consistency: Maintains referential integrity (e.g., "User 1" is always masked to the same value within a session).
  • Streaming Support: Efficiently handles large datasets.
  • Django Integration: Drop-in dumpdata_masked command and MaskedModelMixin.
  • CLI Tool: Process JSON/CSV files or pipe SQL dumps.

Installation

pip install py-cloak
# For Django support
pip install "py-cloak[django]"

Usage

CLI

  1. Define your rules in privacy_rules.yaml:

    email: "faker:email"
    ssn: "mask_all_but_last_4"
    password: "fixed:secret"
    
  2. Run the tool:

    pycloak process input.json --rules=privacy_rules.yaml --output=clean.json
    

Django

  1. Add pycloak.django to your INSTALLED_APPS.
  2. Use the management command:
    python manage.py dumpdata_masked auth.User --output=safe_users.json
    

Rules Reference

  • faker:<provider>: Use any Faker provider (e.g., faker:name, faker:email).
  • fixed:<value>: Replace with a static value.
  • mask_all_but_last_<n>: Mask characters with * except the last n.
  • clear: Set to null or empty string.

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

py_data_cloak-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_data_cloak-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file py_data_cloak-0.1.0.tar.gz.

File metadata

  • Download URL: py_data_cloak-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for py_data_cloak-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e1a677030f421a229ca80c273bf76ebddd260abdee653056823233fd12d583e
MD5 1e5d8c6a18b42b5d890893c3f17e4160
BLAKE2b-256 209141344c7bfed57a4f0c4b0976990f01db52c884ec1b2c422ab7182cf5d554

See more details on using hashes here.

File details

Details for the file py_data_cloak-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_data_cloak-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for py_data_cloak-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78a498159e648f8847e714d389a46465b83a44fce708daf3eaaed4a702cc792a
MD5 4c4505b299b5ee433c48dca00bd9ad89
BLAKE2b-256 f0b5743142ffd0c3e1991262c479a3f523b456bb7519e776549059f7380f8e2a

See more details on using hashes here.

Supported by

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