Skip to main content

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

Project description

py-data-cloak

py-data-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-data-cloak
# For Django support
pip install "py-data-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.1.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.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_data_cloak-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 cf8f84f5bfd014e52bc5e5117b16ef83d1a51057385b8e5a4977f0b89949047d
MD5 57092bff273184f0972c944cc5b87b93
BLAKE2b-256 1c33a77b704914afe8a88121e0212c76a94faac75cfb9062e944b16cd9ea4d3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_data_cloak-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de71529ca9484e4a68b7e6d9ce1d5cc1ab2b32518de03cfe8779a0bb2b1ba733
MD5 c74df60df71ba1c60b90d096f057754d
BLAKE2b-256 df314de8bfc61206c32a2645ef76b66836583fa24271405aeacad072e5eabb72

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