Redact sensitive values from Jeannie logs
This commit is contained in:
parent
ee51fbd421
commit
f8a9e7b792
19
jeannie
19
jeannie
|
|
@ -642,6 +642,19 @@ jeannie_verbose_enabled() {
|
|||
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() {
|
||||
local description="$1"
|
||||
local step_log
|
||||
|
|
@ -663,13 +676,13 @@ run_step() {
|
|||
|
||||
if jeannie_verbose_enabled; then
|
||||
set +e
|
||||
"$@" 2>&1 | tee "${step_log}"
|
||||
"$@" 2>&1 | redact_sensitive_output | tee "${step_log}"
|
||||
status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
else
|
||||
set +e
|
||||
"$@" >"${step_log}" 2>&1
|
||||
status=$?
|
||||
"$@" 2>&1 | redact_sensitive_output >"${step_log}"
|
||||
status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue