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_maskedcommand andMaskedModelMixin. - 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
-
Define your rules in
privacy_rules.yaml:email: "faker:email" ssn: "mask_all_but_last_4" password: "fixed:secret"
-
Run the tool:
pycloak process input.json --rules=privacy_rules.yaml --output=clean.json
Django
- Add
pycloak.djangoto yourINSTALLED_APPS. - 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 lastn.clear: Set tonullor empty string.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf8f84f5bfd014e52bc5e5117b16ef83d1a51057385b8e5a4977f0b89949047d
|
|
| MD5 |
57092bff273184f0972c944cc5b87b93
|
|
| BLAKE2b-256 |
1c33a77b704914afe8a88121e0212c76a94faac75cfb9062e944b16cd9ea4d3b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de71529ca9484e4a68b7e6d9ce1d5cc1ab2b32518de03cfe8779a0bb2b1ba733
|
|
| MD5 |
c74df60df71ba1c60b90d096f057754d
|
|
| BLAKE2b-256 |
df314de8bfc61206c32a2645ef76b66836583fa24271405aeacad072e5eabb72
|