Giter Club home page Giter Club logo

anonymize's Introduction

anonymize

Data anonymizer from CSV/Database to CSV file. (more sources/outputs to come)

Setup

Requirements

  • Python 3.9
  • poetry (optional)

Installation

  • Clone the repository
  • Install dependencies
poetry install
or
pip install -r requirements.txt
  • Create a config.yml file with the configuration for source, output and rules to apply. (see Config) (example config)
  • Run: python -m anonymize -c config.yml

Config

Sources (see sources.py)

Database

List of supported databases.

source:
  type: db
  uri: postgres://postgres:pass@localhost:5432/postgres
  table: mydata

CSV

source:
  type: csv
  path: /path/to/data.csv
  separator: '|' # Optional, default is ','

Outputs (see outputs.py)

CSV

output:
  type: csv
  path: /path/to/output.csv
  separator: '|' # Optional, default is ','

Rules (see rules.py)

  • The rules will validate the column name and the method, and then apply the method to the column
  • If the column is not found in the source, it will be ignored.
  • The if the column is not found in rules list, it will be kept as is.

Hash

Available algorithms are the ones in hashlib module.

rules:
  - column: credit_card
    method: hash
    algorithm: md5
    salt: my_very_secret_salt

Fake

Available types are: email, firstname, lastname, fullname.

rules:
  - column: name
    method: fake
    faker_type: firstname

Mask right (last n characters)

rules:
  - column: email
    method: mask_right
    n_chars: 5
    mask_char: x

Mask left (first n characters)

rules:
  - column: birthdate
    method: mask_left
    n_chars: 4
    mask_char: "*"

Destroy (replace with a fixed value)

The destroy name is inspired from postgresql_anonymizer

rules:
  - column: email
    method: destroy
    replace_with: "SOME VALUE" # Optional, default is "CONFIDENTIAL"

Shuffle

Shuffle letters and numbers separately (example: abc1.2!3 -> skM4.9!0)

rules:
  - column: email
    method: shuffle

Contributing

  • ๐Ÿด Fork the repository
  • โฌ‡๏ธ Install dev dependencies: poetry install --with=dev or pip install -r requirements-dev.txt
  • ๐ŸŒณ Create a branch git checkout -b feature/my-feature
  • ๐Ÿ”ง Make your changes
  • โœ… Run formatting, linting and tests poe all (see pyproject.toml)
  • ๐Ÿ”ƒ Create a pull request

Next steps/Improvements

  • Add database output
  • Validation (especially for database sources)
  • More rules (rounding, etc.)
    • Destroy
    • Shuffle

anonymize's People

Contributors

aymane11 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.