Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:-

. <path_to_cred_scanner_local_repo>/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.

Expand All @@ -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.
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.
3 changes: 2 additions & 1 deletion cred_scanner.py → bin/cred_scanner
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
import os
import re
import sys
Expand Down Expand Up @@ -32,4 +33,4 @@ def scan(path, secret):
if fail == True:
sys.exit(1)
if __name__ == "__main__":
scan()
scan()
8 changes: 8 additions & 0 deletions cred-scanner-complete.sh
Original file line number Diff line number Diff line change
@@ -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;
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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)