Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

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.

Copy link
Contributor

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.


Ignoring false positives
------------------------
Expand Down
4 changes: 4 additions & 0 deletions git-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -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!~/^#/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

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
Expand Down