Coder Social home page Coder Social logo

laorange / stoken Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 43 KB

密钥替换工具 | A code desensitization command tool to substitute tokens (and other sensitive information) in your code.

Home Page: https://pypi.org/project/stoken/

License: GNU Affero General Public License v3.0

Python 99.29% Batchfile 0.71%
desensitization git-tools token

stoken's Introduction

stoken

简体中文 | English docs

The project name stoken means substitute-token. It's a code desensitization tool, which can substitute tokens (and other sensitive information) in your code.

Installation

Method 1

If there's python environment on your device, you can run this command to install stoken :

pip install stoken

Method 2

(Perhaps for other language developers) You can browse the release page, download the stoken.exe, add its path to your system environment variables.

Quick start

  1. Here is demonstration code file, with the suffix .py
# demo.py
token = "qwertyuiop123456789"
password = "poiuytrewq987654321"
print(f"{token=}, {password=}")
  1. In the root directory of your project, create stoken.yaml and edit it with syntax of yaml.
    • suffix : the suffixes of the files you want to detect. Don't forget there's a . before each suffix.
    • token : the sensitive data you want to substitute.
suffix:
  - .py
  - .js
  	
token:
  SECRET_TOKEN: qwertyuiop123456789
  MY_PASSWORD: poiuytrewq987654321
  1. Run stoken --mode hide, or run directly stoken with the default parameter --mode auto, the tokens will be substituted.
# demo.py
token = "#{{SECRET_TOKEN}}#"
password = "#{{MY_PASSWORD}}#"
print(f"{token=}, {password=}")
  1. Run stoken --mode restore, or run directly stoken with the default parameter --mode auto, the tokens will be restored.

API

stoken --help

options description
--mode The mode of operation. Default: auto
-e | --encoding The encoding used to decode the file. Default: utf-8
-p | --variable-prefix The prefix of variable placeholder. Default: #{{
-s | --variable-suffix The suffix of variable placeholder. Default: }}#
--debug Activate this option to enter debug mode, as result, stoken won't modify files, only detect tokens.
--no-git By default, the program will detect if there is a git directory, and if so, it will ignore the files in .gitignore. Activate this option to detect all the files.
-v --version
--help Show this message and exit.

stoken's People

Contributors

etienne0519 avatar laorange avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

etienne0519

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.