ansible-anonymizer


Nameansible-anonymizer JSON
Version 1.5.0 PyPI version JSON
download
home_page
SummaryAnsible Anonymizer
upload_time2024-02-01 14:22:02
maintainer
docs_urlNone
author
requires_python>=3.9
license
keywords pii anonymize
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==========
Anonymizer
==========


.. image:: https://img.shields.io/pypi/v/ansible-anonymizer.svg
        :target: https://pypi.python.org/pypi/ansible-anonymizer
.. image:: https://github.com/ansible/anonymizer/actions/workflows/tox.yml/badge.svg
        :target: https://github.com/ansible/anonymizer/actions



Library to clean up Ansible tasks from any Personally Identifiable Information (PII)


* Free software: Apache Software License 2.0

Anonymized fields
-----------------

- Credit Card number
- email address
- IP address
- MAC address
- US SSN
- US phone number
- YAML comment
- password value, when the field name is identified as being sensitive
- user name from home directory path

Usage
-----

The library can be used to remove the PII from a multi level structure:

.. code-block:: python

    from ansible_anonymizer.anonymizer import anonymize_struct

    example = [{"name": "foo bar", "email": "my-email@address.com"}]

    anonymize_struct(example)
    # [{'name': 'foo bar', 'email': 'noah2@example.com'}]

But you can also anonymize a block of text:

.. code-block:: python

    from ansible_anonymizer.anonymizer import anonymize_text_block

    some_text = """
    - name: a task
      a_module:
        secret: foobar
    """

    anonymize_text_block(some_text)
    # '\n- name: a task\n  a_module:\n    secret: "{{ secret }}"\n'

You can also use the ``ansible-anonymizer`` command:

.. code-block:: console

   ansible-anonymizer my-secret-file

Customize the anonymized strings
================================

By default, the variables are anonymized with a string based on the name of the field.
You can customize it with the ``value_template`` parameter:

.. code-block:: python

    from ansible_anonymizer.anonymizer import anonymize_struct
    from string import Template

    original = {"password": "$RvEDSRW#R"}
    value_template = Template("_${variable_name}_")
    anonymize_struct(original, value_template=value_template)
    #  {'password': '_password_'}


Limitations
-----------

- ``anonymize_text_block()`` relies on its own text parser which only support a subset of YAML features. Because of this, it may not be able to identify some PII. When possible, use ``anonymize_struct`` which accepts a Python structure instead.
- The Anonymizer is not a silver bullet and it's still possible to see PII going through the filters.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ansible-anonymizer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "pii,anonymize",
    "author": "",
    "author_email": "Gon\u00e9ri Le Bouder <goneri@lebouder.net>",
    "download_url": "https://files.pythonhosted.org/packages/69/f6/391d66d11d16eb98cd34b82bce62ee9afd2ea4b73f1b4734d1d78eb225b6/ansible-anonymizer-1.5.0.tar.gz",
    "platform": null,
    "description": "==========\nAnonymizer\n==========\n\n\n.. image:: https://img.shields.io/pypi/v/ansible-anonymizer.svg\n        :target: https://pypi.python.org/pypi/ansible-anonymizer\n.. image:: https://github.com/ansible/anonymizer/actions/workflows/tox.yml/badge.svg\n        :target: https://github.com/ansible/anonymizer/actions\n\n\n\nLibrary to clean up Ansible tasks from any Personally Identifiable Information (PII)\n\n\n* Free software: Apache Software License 2.0\n\nAnonymized fields\n-----------------\n\n- Credit Card number\n- email address\n- IP address\n- MAC address\n- US SSN\n- US phone number\n- YAML comment\n- password value, when the field name is identified as being sensitive\n- user name from home directory path\n\nUsage\n-----\n\nThe library can be used to remove the PII from a multi level structure:\n\n.. code-block:: python\n\n    from ansible_anonymizer.anonymizer import anonymize_struct\n\n    example = [{\"name\": \"foo bar\", \"email\": \"my-email@address.com\"}]\n\n    anonymize_struct(example)\n    # [{'name': 'foo bar', 'email': 'noah2@example.com'}]\n\nBut you can also anonymize a block of text:\n\n.. code-block:: python\n\n    from ansible_anonymizer.anonymizer import anonymize_text_block\n\n    some_text = \"\"\"\n    - name: a task\n      a_module:\n        secret: foobar\n    \"\"\"\n\n    anonymize_text_block(some_text)\n    # '\\n- name: a task\\n  a_module:\\n    secret: \"{{ secret }}\"\\n'\n\nYou can also use the ``ansible-anonymizer`` command:\n\n.. code-block:: console\n\n   ansible-anonymizer my-secret-file\n\nCustomize the anonymized strings\n================================\n\nBy default, the variables are anonymized with a string based on the name of the field.\nYou can customize it with the ``value_template`` parameter:\n\n.. code-block:: python\n\n    from ansible_anonymizer.anonymizer import anonymize_struct\n    from string import Template\n\n    original = {\"password\": \"$RvEDSRW#R\"}\n    value_template = Template(\"_${variable_name}_\")\n    anonymize_struct(original, value_template=value_template)\n    #  {'password': '_password_'}\n\n\nLimitations\n-----------\n\n- ``anonymize_text_block()`` relies on its own text parser which only support a subset of YAML features. Because of this, it may not be able to identify some PII. When possible, use ``anonymize_struct`` which accepts a Python structure instead.\n- The Anonymizer is not a silver bullet and it's still possible to see PII going through the filters.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Ansible Anonymizer",
    "version": "1.5.0",
    "project_urls": {
        "Homepage": "https://github.com/ansible/anonymizer"
    },
    "split_keywords": [
        "pii",
        "anonymize"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56911b7e0dd4ae4f7579f607e5fd71d226cb9faaf5298f8dbdc5b5641d8476fa",
                "md5": "a28d119a8ee6ca921429999946e403d9",
                "sha256": "756501ee757d8efcb16340260952b7726a413521b006f30d0706b5bec807d74c"
            },
            "downloads": -1,
            "filename": "ansible_anonymizer-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a28d119a8ee6ca921429999946e403d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 13637,
            "upload_time": "2024-02-01T14:22:01",
            "upload_time_iso_8601": "2024-02-01T14:22:01.445586Z",
            "url": "https://files.pythonhosted.org/packages/56/91/1b7e0dd4ae4f7579f607e5fd71d226cb9faaf5298f8dbdc5b5641d8476fa/ansible_anonymizer-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69f6391d66d11d16eb98cd34b82bce62ee9afd2ea4b73f1b4734d1d78eb225b6",
                "md5": "7fc79ea41c1186fb4f712d76ef814437",
                "sha256": "6c2f3aacb17d755195e15540baba75ef4110f34145c4cbd20f74516c14ba6729"
            },
            "downloads": -1,
            "filename": "ansible-anonymizer-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7fc79ea41c1186fb4f712d76ef814437",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 23948,
            "upload_time": "2024-02-01T14:22:02",
            "upload_time_iso_8601": "2024-02-01T14:22:02.667106Z",
            "url": "https://files.pythonhosted.org/packages/69/f6/391d66d11d16eb98cd34b82bce62ee9afd2ea4b73f1b4734d1d78eb225b6/ansible-anonymizer-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-01 14:22:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ansible",
    "github_project": "anonymizer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "ansible-anonymizer"
}
        
Elapsed time: 0.17320s