Skip to content

Commit

Permalink
feat: improve handle-secrets function
Browse files Browse the repository at this point in the history
- No longer require popd/pushd and streamline that part
- Make the select more robust against invalid input
  • Loading branch information
Okeanos committed Sep 24, 2024
1 parent b8ff5ce commit cf524e0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions stow/shell/dot-config/bash/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit cf524e0

Please sign in to comment.