fix: suppress terminal echo for secret input and guard against overwrites
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

- Use `read -rs` to hide typed secret value from terminal
- Prompt for confirmation before overwriting an existing secret

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-03-28 19:10:47 +00:00
parent 1b52761336
commit ec58cb1745

View file

@ -2059,13 +2059,23 @@ disinto_secrets() {
printf 'Enter value for %s: ' "$name" >&2 printf 'Enter value for %s: ' "$name" >&2
local value local value
IFS= read -r value IFS= read -rs value
echo >&2
if [ -z "$value" ]; then if [ -z "$value" ]; then
echo "Error: empty value" >&2 echo "Error: empty value" >&2
exit 1 exit 1
fi fi
local enc_path="${secrets_dir}/${name}.enc" local enc_path="${secrets_dir}/${name}.enc"
if [ -f "$enc_path" ]; then
printf 'Secret %s already exists. Overwrite? [y/N] ' "$name" >&2
local confirm
read -r confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
echo "Aborted." >&2
exit 1
fi
fi
if ! printf '%s' "$value" | age -r "$AGE_PUBLIC_KEY" -o "$enc_path"; then if ! printf '%s' "$value" | age -r "$AGE_PUBLIC_KEY" -o "$enc_path"; then
echo "Error: encryption failed" >&2 echo "Error: encryption failed" >&2
exit 1 exit 1