Skip to content

Commit

Permalink
Fix no warn (#21)
Browse files Browse the repository at this point in the history
* Fixing flag dropping

Previously I committed 4f6ffe9. Here, I
introduced a bug that caused files sometimes not to be read.

Fixing in this commit

* Logging arguments to detect-secrets

There is quite a bit of logic that goes into constructing these
arguments. By logging them, I will make it easier to detect problems in
the future.
  • Loading branch information
bgolding355 authored Aug 8, 2022
1 parent 4f6ffe9 commit bf855b9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions detect-new-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ fetch_flags_from_file() {
file_to_check="$2"

flags=()
(while read line; do
while read line; do
if [[ "${line::1}" != '#' ]] && [[ ! -z "$line" ]]; then
flag="$flag_to_add $line "
flags+="$flag"
fi
done < "$file_to_check") 2>&1 > /dev/null
done < "$file_to_check"

echo "$flags"
}

scan_new_secrets() {
excluded_files=$(fetch_flags_from_file '--exclude-files' "$EXCLUDE_FILES_PATH")
excluded_secrets=$(fetch_flags_from_file '--exclude-secrets' "$EXCLUDE_SECRETS_PATH")
excluded_lines=$(fetch_flags_from_file '--exclude-lines' "$EXCLUDE_LINES_PATH")
excluded_files=$(fetch_flags_from_file '--exclude-files' "$EXCLUDE_FILES_PATH" 2>/dev/null)
excluded_secrets=$(fetch_flags_from_file '--exclude-secrets' "$EXCLUDE_SECRETS_PATH" 2>/dev/null)
excluded_lines=$(fetch_flags_from_file '--exclude-lines' "$EXCLUDE_LINES_PATH" 2>/dev/null)
detect_secret_args="$excluded_files $excluded_secrets $excluded_lines $DETECT_SECRET_ADDITIONAL_ARGS"
echo "Running detect-secrets with args: $detect_secret_args"

detect-secrets scan $detect_secret_args --baseline "$BASELINE_FILE"
detect-secrets audit "$BASELINE_FILE" --report --json > "$all_secrets_file"
Expand Down

0 comments on commit bf855b9

Please sign in to comment.