From d4f3a95491fd69a63a7e43ce1786c1e66cedfa39 Mon Sep 17 00:00:00 2001 From: William Davies Date: Tue, 21 Apr 2020 11:50:32 -0700 Subject: [PATCH] Update git-secrets to include prohibited regular expressions from a .gitprohibited file --- README.rst | 3 +++ git-secrets | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/README.rst b/README.rst index 13f7c02..f4764d5 100644 --- a/README.rst +++ b/README.rst @@ -403,6 +403,9 @@ like Ubuntu (BSD vs GNU). You can add prohibited regular expression patterns to your git config using ``git secrets --add ``. +You can also add prohibited regular expressions patterns to a +``.gitprohibited`` file located in the repository's root directory. Lines starting +with ``#`` are skipped (comment line) and empty lines are also skipped. Ignoring false positives ------------------------ diff --git a/git-secrets b/git-secrets index 11be153..301995d 100755 --- a/git-secrets +++ b/git-secrets @@ -47,6 +47,10 @@ prepare_commit_msg_hook* prepare-commit-msg hook (internal only)" load_patterns() { git config --get-all secrets.patterns + local gitprohibited="$(git rev-parse --show-toplevel)/.gitprohibited" + if [ -e "$gitprohibited" ]; then + cat $gitprohibited | awk 'NF && $1!~/^#/' + fi # Execute each provider and use their output to build up patterns git config --get-all secrets.providers | while read -r cmd; do # Only split words on '\n\t ' and strip "\r" from the output to account