diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..894a44c --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/README.md b/README.md index 9a66f33..042da6d 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,17 @@ I suspect there are other, better tools out there (such as [git-secrets](https:/ To install just copy it where you want it and install the requirements: - pip install -r ./requirements.txt + pip install . This was written in Python 3.6. +To enable auto-complete, please add the following line to your bashrc/bash_profile:- + + . /cred-scanner-complete.sh + To run: - python cred_scanner.py + cred_scanner That will scan the local directory and all subdirectories. It will list the files, which ones have potential access keys, and which files can't be scanned due to the file format. cred_scanner exits with a code of 1 if it finds any potential keys. @@ -25,4 +29,4 @@ That will scan the local directory and all subdirectories. It will list the file false matches due to the nature of secret keys. --help Show this message and exit. -To run as a test in Jenkins just use the command line or add it as a step to your Jenkins build. Jenkins will automatically fail the build if it sees the exit code 1. \ No newline at end of file +To run as a test in Jenkins just use the command line or add it as a step to your Jenkins build. Jenkins will automatically fail the build if it sees the exit code 1. diff --git a/cred_scanner.py b/bin/cred_scanner old mode 100644 new mode 100755 similarity index 97% rename from cred_scanner.py rename to bin/cred_scanner index e72cdcc..97a03b5 --- a/cred_scanner.py +++ b/bin/cred_scanner @@ -1,3 +1,4 @@ +#!/usr/bin/env python import os import re import sys @@ -32,4 +33,4 @@ def scan(path, secret): if fail == True: sys.exit(1) if __name__ == "__main__": - scan() \ No newline at end of file + scan() diff --git a/cred-scanner-complete.sh b/cred-scanner-complete.sh new file mode 100644 index 0000000..210dd7a --- /dev/null +++ b/cred-scanner-complete.sh @@ -0,0 +1,8 @@ +_cred_scanner_completion() { + COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \ + COMP_CWORD=$COMP_CWORD \ + _CRED_SCANNER_COMPLETE=complete $1 ) ) + return 0 +} + +complete -F _cred_scanner_completion -o default cred_scanner; diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b98f660..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -click \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6517c84 --- /dev/null +++ b/setup.py @@ -0,0 +1,10 @@ +from setuptools import setup + +setup(name='cred_scanner', + description='A simple command line tool for finding AWS credentials in files', + url='https://github.com/disruptops/cred_scanner', + author='DisruptOps', + license='MIT', + install_requires=['click'], + scripts=['bin/cred_scanner'], + zip_safe=False)