Skip to content

Commit 5953504

Browse files
committed
config: hide sensitive input during baudbot config
prompt_secret now uses read -rs (silent mode) for API keys, tokens, and secrets so they aren't echoed to the terminal. Non-sensitive fields like email addresses, user IDs, and org slugs remain visible. Falls back to plain read when stdin is not a terminal (piped input in CI), so automated tests are unaffected.
1 parent ba7110e commit 5953504

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

bin/config.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ fi
7777

7878
# ── Prompting ────────────────────────────────────────────────────────────────
7979

80-
# prompt_secret KEY "description" "url" [required] [prefix]
80+
# prompt_secret KEY "description" "url" [required] [prefix] [sensitive]
8181
# If an existing value is set, shows [****] and allows Enter to keep it.
82+
# sensitive defaults to "true" — input is hidden. Pass "false" for visible input.
8283
prompt_secret() {
83-
local key="$1" desc="$2" url="${3:-}" required="${4:-}" prefix="${5:-}"
84+
local key="$1" desc="$2" url="${3:-}" required="${4:-}" prefix="${5:-}" sensitive="${6:-true}"
8485
local label="" existing="${EXISTING[$key]:-}"
8586

8687
if [ "$required" = "required" ]; then
@@ -98,7 +99,14 @@ prompt_secret() {
9899
else
99100
ask "${label}${desc}: "
100101
fi
101-
read -r value
102+
103+
if [ "$sensitive" = "true" ] && [ -t 0 ]; then
104+
read -rs value
105+
# Print newline since -s suppresses it
106+
echo ""
107+
else
108+
read -r value
109+
fi
102110

103111
# Empty input with existing value = keep existing
104112
if [ -z "$value" ] && [ -n "$existing" ]; then
@@ -203,7 +211,8 @@ prompt_secret "SLACK_ALLOWED_USERS" \
203211
"Slack user IDs (comma-separated)" \
204212
"Click your Slack profile → ··· → Copy member ID" \
205213
"required" \
206-
"U"
214+
"U" \
215+
"false"
207216

208217
echo ""
209218

@@ -216,7 +225,8 @@ prompt_secret "AGENTMAIL_API_KEY" \
216225
"https://app.agentmail.to"
217226

218227
prompt_secret "BAUDBOT_EMAIL" \
219-
"Agent email address (e.g. agent@agentmail.to)"
228+
"Agent email address (e.g. agent@agentmail.to)" \
229+
"" "" "" "false"
220230

221231
if [ -n "${ENV_VARS[AGENTMAIL_API_KEY]:-}" ]; then
222232
prompt_secret "BAUDBOT_SECRET" \
@@ -227,16 +237,17 @@ if [ -n "${ENV_VARS[AGENTMAIL_API_KEY]:-}" ]; then
227237
fi
228238

229239
prompt_secret "BAUDBOT_ALLOWED_EMAILS" \
230-
"Allowed sender emails (comma-separated)"
240+
"Allowed sender emails (comma-separated)" \
241+
"" "" "" "false"
231242
fi
232243

233244
prompt_secret "SENTRY_AUTH_TOKEN" \
234245
"Sentry API token" \
235246
"https://sentry.io/settings/account/api/auth-tokens/"
236247

237248
if [ -n "${ENV_VARS[SENTRY_AUTH_TOKEN]:-}" ]; then
238-
prompt_secret "SENTRY_ORG" "Sentry org slug"
239-
prompt_secret "SENTRY_CHANNEL_ID" "Slack channel ID for Sentry alerts" "" "" "C"
249+
prompt_secret "SENTRY_ORG" "Sentry org slug" "" "" "" "false"
250+
prompt_secret "SENTRY_CHANNEL_ID" "Slack channel ID for Sentry alerts" "" "" "C" "false"
240251
fi
241252

242253
prompt_secret "KERNEL_API_KEY" \

slack-bridge/package-lock.json

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)