GithubHelp home page GithubHelp logo

third-factor's Introduction

The Third Factor

Sometimes you're writing a dev tool script that your team needs, but you'd like everyone to be very careful when they use it, so you add an extra prompt.

Sometimes you want them to be REALLY careful when they use it; for these times, there's the Third Factor. The third factor is designed to eliminate the script user's ability to blindly press Y/Enter and do something dumb.

Suggested use cases:

  • Connecting to the production database
  • Deploying to prod from your local branch
  • Clearing an S3 bucket
  • Anything to do with git history rewriting
  • Twiddling config files directly in prod
  • When you just can't get that one person (you know who I mean) to stop and think

The possibilities are as endless as your team's capacity for unintentional destruction!

Installation

Definitely install this in your root python installation since you want it to be available everywhere.

pip install third-factor

Usage

Just slap it in your shell script before the part you don't want people to do!

Linux shell scripts

# Do some safe stuff here...

thirdfactor || exit 1

# NOW DO THE RISKY STUFF

Don't omit the exit 1! Otherwise your script will continue even if the user fails third-factor authentication.

Windows .bat file (No judgement)

Rem Do some safe stuff here...

thirdfactor
if !errorlevel! neq 0 exit /b !errorlevel!

Rem NOW DO THE RISKY STUFF

Demo

~/projects/third-factor$ python3 -m third_factor "connect to the prod db"
You're about to connect to the prod db, which is risky. Are you sure this is a good idea?
Type YES to continue: YES
--------------------------
Are you sure there isn't a better, safer way to achieve what you're about to do?
Type I AM SURE THERE IS NOT to continue: I AM SURE THERE IS NOT
--------------------------
You're not too sleep deprived, under-caffeinated, too many beers etc.?
Type I AM OF SOUND MIND to continue: I AM OF SOUND MIND
--------------------------
Prove it: type this random string.
Type PZBBEYNIBF to continue: PZBBEYNIBF
--------------------------
Let's cool off for 10 seconds and think...
1..2..3..4..5..6..7..8..9..10..
You're still sure?
Type YES to continue: YES
--------------------------
Be careful, and don't say you weren't warned…

third-factor's People

Contributors

dkolas avatar

Stargazers

Max Freundlich avatar

Watchers

 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.