Last active
May 29, 2020 09:48
-
-
Save fourirakbar/64493438311d697d3c00c64bee8488f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| import os | |
| import re | |
| precommit_check = sys.argv[1] | |
| def check_secret(secret_file): | |
| for root, dirs, files in os.walk(secret_file): | |
| for file in files: | |
| with open(os.path.join(root, file), "r") as auto: | |
| if ".groovy" in file: | |
| nameFile = root + "/" + file | |
| secret = r'([a-zA-Z0-9]{37}(?![a-zA-Z0-9]))' | |
| with open(nameFile) as f: | |
| for i in re.findall(secret, f.read(), re.DOTALL): | |
| # raise ValueError("Secret detected: " + i + ". File name: " + nameFile) | |
| print("Secret detected: " + i + " || File name: " + nameFile) | |
| # return -1 | |
| if __name__ == '__main__': | |
| check_secret(precommit_check) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment