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

Exclude empty provider output. Closes #34 #35

Merged
merged 1 commit into from
Dec 1, 2016
Merged
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
9 changes: 6 additions & 3 deletions git-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ load_patterns() {
git config --get-all secrets.patterns
# Execute each provider and use their output to build up patterns
git config --get-all secrets.providers | while read -r cmd; do
echo "$(export IFS=$'\n\t '; $cmd)"
local result="$(export IFS=$'\n\t '; $cmd)"
# Do not add empty lines from providers as that would match everything.
if [ -n "${result}" ]; then
echo "$result"
fi
done
}

Expand All @@ -65,8 +69,7 @@ load_allowed() {
load_combined_patterns() {
local patterns=$(load_patterns)
local combined_patterns=''
for pattern in $patterns
do
for pattern in $patterns; do
combined_patterns=${combined_patterns}${pattern}"|"
done
combined_patterns=${combined_patterns%?}
Expand Down
12 changes: 12 additions & 0 deletions test/git-secrets.bats
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ load test_helper
echo "$output" | grep -F 'bam'
}

@test "Strips providers that return nothing" {
repo_run git-secrets --add-provider -- 'echo'
[ $status -eq 0 ]
repo_run git-secrets --add-provider -- 'echo 123'
[ $status -eq 0 ]
repo_run git-secrets --list
echo "$output" | grep -F 'echo 123'
echo 'foo' > $TEST_REPO/bad_file
repo_run git-secrets --scan $TEST_REPO/bad_file
[ $status -eq 0 ]
}

@test "--recursive cannot be used with SCAN_*" {
repo_run git-secrets --scan -r --cached
[ $status -eq 1 ]
Expand Down