Sometimes security is protection from yourself.
Project description
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…
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file third_factor-0.0.4.tar.gz.
File metadata
- Download URL: third_factor-0.0.4.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43b93f3b6dac007d193e9adcb4e514096d2cbb054b17c64b172fb97b037003da
|
|
| MD5 |
bed4dc96d22813c0ef53e9421ccf66ca
|
|
| BLAKE2b-256 |
ec003eb5b7b8ec44b77840a98f9dd87926e983f1dc6e68ff843350f22eac4328
|
File details
Details for the file third_factor-0.0.4-py3-none-any.whl.
File metadata
- Download URL: third_factor-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9efeaa268486f90be385b79724aac845fa2f2d80bad9b8bbdf6ac3f346b9b16e
|
|
| MD5 |
987a6597b8b49466c6b7152465e8d8d2
|
|
| BLAKE2b-256 |
ffdf054d5bc2d58ad7c48b63a05adf8c1445dd7c45a06d6a83068e716bd076cc
|