Redact sensitive values from Jeannie logs

This commit is contained in:
juvdiaz 2026-06-29 13:22:27 -06:00
parent ee51fbd421
commit f8a9e7b792
1 changed files with 16 additions and 3 deletions

19
jeannie
View File

@ -642,6 +642,19 @@ jeannie_verbose_enabled() {
truthy "${JEANNIE_VERBOSE:-false}" truthy "${JEANNIE_VERBOSE:-false}"
} }
redact_sensitive_output() {
sed -E \
-e 's/(GITEA_BOOTSTRAP_PASSWORD=)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
-e 's/(PIHOLE_WEBPASSWORD=)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
-e 's/(COSIGN_PASSWORD=)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
-e 's/(GITEA_RUNNER_REGISTRATION_TOKEN=)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
-e 's/(--password[=[:space:]]+)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
-e 's/(--token[=[:space:]]+)["'\'']?[^"'\''[:space:]]+["'\'']?/\1[REDACTED]/g' \
-e 's/(password[=:][[:space:]]*)[^[:space:]]+/\1[REDACTED]/Ig' \
-e 's/(token[=:][[:space:]]*)[^[:space:]]+/\1[REDACTED]/Ig' \
-e 's#(https?://[^:/[:space:]]+):[^@/[:space:]]+@#\1:[REDACTED]@#g'
}
run_step() { run_step() {
local description="$1" local description="$1"
local step_log local step_log
@ -663,13 +676,13 @@ run_step() {
if jeannie_verbose_enabled; then if jeannie_verbose_enabled; then
set +e set +e
"$@" 2>&1 | tee "${step_log}" "$@" 2>&1 | redact_sensitive_output | tee "${step_log}"
status=${PIPESTATUS[0]} status=${PIPESTATUS[0]}
set -e set -e
else else
set +e set +e
"$@" >"${step_log}" 2>&1 "$@" 2>&1 | redact_sensitive_output >"${step_log}"
status=$? status=${PIPESTATUS[0]}
set -e set -e
fi fi