From cf524e051c6a266b53dd9a9022078b22c1f9fa6f Mon Sep 17 00:00:00 2001 From: Nikolas Grottendieck Date: Tue, 24 Sep 2024 20:28:40 +0200 Subject: [PATCH] feat: improve handle-secrets function - No longer require popd/pushd and streamline that part - Make the select more robust against invalid input --- stow/shell/dot-config/bash/functions | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stow/shell/dot-config/bash/functions b/stow/shell/dot-config/bash/functions index a03c90bc88..e69d8b902e 100644 --- a/stow/shell/dot-config/bash/functions +++ b/stow/shell/dot-config/bash/functions @@ -215,12 +215,10 @@ function handle-secrets { fi echo "Scanning: ${target_directory}" - pushd "${target_directory}" >/dev/null - if [[ -f .gitleaksignore ]]; then - ignore_file_contents=$(cat .gitleaksignore) + if [[ -f "${target_directory}/.gitleaksignore" ]]; then + ignore_file_contents=$(< "${target_directory}/.gitleaksignore") fi - gitleaks git --verbose --report-format=json --report-path="${report_file}" --exit-code=0 . &>/dev/null - popd >/dev/null + gitleaks git --verbose --report-format=json --report-path="${report_file}" --exit-code=0 "${target_directory}" &>/dev/null if [[ -f ${report_file} ]]; then if [[ $(jq length "${report_file}") == 0 ]]; then @@ -244,6 +242,7 @@ function handle-secrets { echo "Commit: ${commit}" echo "Secret: ${secret}" select finding_type in "False Positive" "Valid" "Other"; do + [[ -n "${finding_type}" ]] || { echo "Please select a valid option." >&2; continue; } documented_as="${finding_type}" break done