{"id":13638501,"url":"https://github.com/anki-code/xontrib-history-encrypt","last_synced_at":"2025-03-21T08:31:21.288Z","repository":{"id":62590091,"uuid":"341962804","full_name":"anki-code/xontrib-history-encrypt","owner":"anki-code","description":"🔐 The xonsh shell history backend that encrypt the commands history file to prevent leaking sensitive data. ","archived":false,"fork":false,"pushed_at":"2023-02-16T15:21:52.000Z","size":57,"stargazers_count":21,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T11:03:13.600Z","etag":null,"topics":["command-history","encryption","security-tools","shell","shell-history","xonsh","xontrib"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anki-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://github.com/anki-code","https://www.buymeacoffee.com/xxh","https://github.com/xonsh/xonsh#the-xonsh-shell-community"]}},"created_at":"2021-02-24T16:29:18.000Z","updated_at":"2025-02-04T10:48:41.000Z","dependencies_parsed_at":"2024-10-28T10:14:00.801Z","dependency_job_id":"2ed4a253-9eab-4493-9ff7-462d278c7c74","html_url":"https://github.com/anki-code/xontrib-history-encrypt","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.4285714285714286,"last_synced_commit":"372dc54fbfa2e1a4e00d4bed280f8def95def488"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-history-encrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-history-encrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-history-encrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-history-encrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki-code","download_url":"https://codeload.github.com/anki-code/xontrib-history-encrypt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244122731,"owners_count":20401476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-history","encryption","security-tools","shell","shell-history","xonsh","xontrib"],"created_at":"2024-08-02T01:00:47.035Z","updated_at":"2025-03-21T08:31:20.743Z","avatar_url":"https://github.com/anki-code.png","language":"Python","funding_links":["https://github.com/anki-code","https://www.buymeacoffee.com/xxh","https://github.com/xonsh/xonsh#the-xonsh-shell-community"],"categories":["Plugins"],"sub_categories":["History backends"],"readme":"\u003cp align=\"center\"\u003e\nThe xonsh shell history backend that encrypt the commands history file\u003cbr\u003e to prevent leaking sensitive data. \n\u003cbr\u003e\u003cbr\u003e\n\u003cimg src=\"https://repository-images.githubusercontent.com/341962804/355cf080-76df-11eb-8fb3-85de54fe7f76\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e  \nIf you like the idea click ⭐ on the repo and \u003ca href=\"https://twitter.com/intent/tweet?text=History%20backend%20for%20xonsh%20shell%20that%20encrypt%20the%20history.\u0026url=https://github.com/anki-code/xontrib-history-encrypt\" target=\"_blank\"\u003etweet\u003c/a\u003e.\n\u003c/p\u003e\n\n\n## Installation\n\nTo install use pip:\n\n```bash\nxpip install xontrib-history-encrypt\n# or: xpip install -U git+https://github.com/anki-code/xontrib-history-encrypt\n```\n\n## Usage: supported encryption\n\n### Base64 (default)\n\n*Protection level: no protection.*\n\nBase64 is not the real encrypter and implemented as fast way to encode history file and for education reasons.\nIt can save you from the massive scanning the file system for keywords (i.e. password, key) \nas well as reading the history file by not experienced user. But it can be decoded in five minutes by the professional.\n\n```python\n# Add to xonsh RC file\n$XONSH_HISTORY_ENCRYPTOR = 'base64'\nxontrib load history_encrypt\n```\n\n### Fernet \n\n*Protection level: high.*\n\nThe implementation of [Fernet](https://cryptography.io/en/latest/fernet.html) (AES CBC + HMAC) that was strongly \nrecommended on [stackoverflow](https://stackoverflow.com/a/55147077). On first start it generates a key that you \nshould save in secure place. Than you can use this key to decrypt the history.\n\n```python\n# Add to xonsh RC file\n$XONSH_HISTORY_ENCRYPTOR = 'fernet'\nxontrib load history_encrypt\n```\n\n### Dummy\n\n*Protection level: super high.*\n\nThe best encryption of the data when there is no the data. The dummy encryptor stores command only in the memory during \nthe session without saving it on the disk. After the end of the session the commands will be lost.\n\n```python\n# Add to xonsh RC file\n$XONSH_HISTORY_ENCRYPTOR = 'dummy'\nxontrib load history_encrypt\n```\n\n### Custom \n\n*Protection level: all in your hands.*\n\nTo create custom encryptor you should implement three functions: key getter function, encryptor and decryptor.\n\n```python\n# Add to xonsh RC file\n$XONSH_HISTORY_ENCRYPTOR = {\n  'key': lambda: input('[xontrib-history-encrypt] Enter any key just for fun: '),\n  'enc': lambda data, key=None: data[::-1], # just flip the string\n  'dec': lambda data, key=None: data[::-1]  # flip the string back\n}\nxontrib load history_encrypt\n```\n\nAfter debugging you can add your encryptor to the `history_encrypt` directory of the xontrib by PR.\n\n## Common use case\n\n1. You're on the public/shared/opened server where you have xonsh and bash.\n2. Install the xontrib and create your RC-file from bash:\n    ```python\n    pip install xontrib-history-encrypt\n    mkdir -p ~/.local/share/xonsh/\n    echo -e '$XONSH_HISTORY_ENCRYPTOR = \"fernet\"\\nxontrib load history_encrypt' \u003e ~/.local/share/xonsh/rc\n    ```\n3. Run xonsh with RC-file then get the key and remember the key:\n    ```python\n    xonsh --rc ~/.local/share/xonsh/rc\n    # Enter the key or press enter to create new: \u003cPRESS ENTER\u003e\n    # Save the key and use it next time: CFB5kAfD3BgdpQHJxmKb\n    ```\n4. Next time run xonsh with RC and key:\n    ```python\n    xonsh --rc ~/.local/share/xonsh/rc\n    # Enter the key or press enter to create new: CFB5kAfD3BgdpQHJxmKb\n    ```\n\n## What should I know?\n\n### How to check the backend is working\n\n```bash\nhistory info\n# backend: xontrib-history-encrypt\n# sessionid: 374eedc9-fc94-4d27-9ab7-ebd5a5c87d12\n# filename: /home/user/.local/share/xonsh/xonsh-history-encrypt.txt\n# commands: 1\n```\n\n### Some points about the backend\n\n* At start the backend read and decrypt all commands and this could take time. Basically we assume that you will use the xontrib on your servers and haven't so big history.\n\n* The commands are stored in the memory and flush to the disk at the exit from the shell. If the shell has crash there is no flushing to the disk and commands will be lost. Use `history flush` command if you plan to run something experimental.\n\n* The backend has minimal history management support in comparing with json or sqlite backends and you can find the lack of features.\n\nIf you want to improve something from the list PRs are welcome!\n\n## Credits\n\n* This package is the part of [ergopack](https://github.com/anki-code/xontrib-ergopack) - the pack of ergonomic xontribs.\n* This package was created with [xontrib cookiecutter template](https://github.com/xonsh/xontrib-cookiecutter).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxontrib-history-encrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki-code%2Fxontrib-history-encrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxontrib-history-encrypt/lists"}