-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include prohibited regular expressions from a .gitprohibited file #163
base: master
Are you sure you want to change the base?
Conversation
…gitprohibited file
Would love to see this merged in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are also needed for this change.
- positive test, prohibited pattern is successfully detected as a secrets match
- negative test, commented line doesn't match
- positive test, line starting with
(#)
(or another suggested alternative to^#
) matches
Possibly others, try to exercise the various use cases here.
@@ -403,6 +403,9 @@ like Ubuntu (BSD vs GNU). | |||
You can add prohibited regular expression patterns to your git config using | |||
``git secrets --add <pattern>``. | |||
|
|||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sold on the name, but can't think of a better one. I'm opening this thread to explicitly ask the next reviewer to weigh in on the file name.
@@ -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!~/^#/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cat $gitprohibited | awk 'NF && $1!~/^#/' | |
awk 'NF && $1!~/^#/' "$gitprohibited" |
cat
is not necessary here, and the quotes are needed in case the path to the file has spaces
@@ -403,6 +403,9 @@ like Ubuntu (BSD vs GNU). | |||
You can add prohibited regular expression patterns to your git config using | |||
``git secrets --add <pattern>``. | |||
|
|||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should the user specify patterns that start with #
? I think (#)
would work, but that should probably be explicitly described here.
Update git-secrets to include prohibited regular expressions from a .gitprohibited file
Issue #, if available:
Add the possibility of using a
.gitprohibited
file in the repository root to include prohibited patterns - much the same as.gitallowed
is used to mark false positivesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.