Skip to content

Commit 88ca009

Browse files
authored
fix(docker): stop the container entrypoint printing database connection strings in logs (#4346)
## Summary The container entrypoint runs under `set -x`, which echoes every command to the logs with its variables expanded. Several startup guards reference full database connection strings, so the DSN (including the password) was printed to the container logs on every boot. This turns tracing off around those lines so connection strings are never traced, while leaving migration behavior and ordinary startup logging unchanged. ## Fix The leaking lines are the `[ -n "$RUN_OPS_DATABASE_URL" ]` and `[ -n "$RUN_OPS_LEGACY_DIRECT_URL" ]` guards, and the ClickHouse block (its `[ -n "$CLICKHOUSE_URL" ]` guard plus the lines that build `GOOSE_DBSTRING` from `CLICKHOUSE_URL`). `set -x` prints each of these with the credential expanded. Tracing is now disabled around each region and restored afterward, so non-secret tracing is preserved everywhere else. The existing legacy-migration subshell already protected its own command body; this adds the missing protection for the guards and the ClickHouse block. ```sh { set +x; } 2>/dev/null if [ -n "$RUN_OPS_DATABASE_URL" ]; then set -x ... ``` ## Verification Built the webapp image and ran it with dummy sentinel connection strings whose password token is `S3NTINEL_PW_DoNotLog`, then grepped the boot logs. Before (unmodified), the token appears in the traced guards: ``` + [ -n postgresql://user:S3NTINEL_PW_DoNotLog@fake-host:6432/run-ops ] + [ -n postgresql://user:S3NTINEL_PW_DoNotLog@fake-host:5432/legacy ] + [ -n https://default:S3NTINEL_PW_DoNotLog@fake-host:8443 ] ``` After, `grep S3NTINEL_PW_DoNotLog` on the same run returns nothing, and the normal "skipping ... migrations" lines still log.
1 parent 3c82248 commit 88ca009

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
Container startup no longer prints database and ClickHouse connection strings (with credentials) to the logs.

docker/scripts/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ fi
1515

1616
# Run-ops split: migrate the dedicated NEW run-ops database only when it is configured. Single-DB
1717
# installs never set the URL, so this is a no-op there.
18+
{ set +x; } 2>/dev/null
1819
if [ -n "$RUN_OPS_DATABASE_URL" ]; then
20+
set -x
1921
if [ "$SKIP_RUN_OPS_MIGRATIONS" != "1" ]; then
2022
echo "Running run-ops migrations"
2123
pnpm --filter @internal/run-ops-database db:migrate:deploy
@@ -24,13 +26,16 @@ if [ -n "$RUN_OPS_DATABASE_URL" ]; then
2426
echo "SKIP_RUN_OPS_MIGRATIONS=1, skipping run-ops migrations."
2527
fi
2628
else
29+
set -x
2730
echo "RUN_OPS_DATABASE_URL not set, skipping run-ops migrations."
2831
fi
2932

3033
# Run-ops split: keep the legacy runs DB's schema current by applying the full @trigger.dev/database
3134
# migrations to it too, pointed at its direct (non-pooled) URL. Only runs when that URL is configured;
3235
# installs that never set it skip this entirely.
36+
{ set +x; } 2>/dev/null
3337
if [ -n "$RUN_OPS_LEGACY_DIRECT_URL" ]; then
38+
set -x
3439
if [ "$SKIP_RUN_OPS_LEGACY_MIGRATIONS" != "1" ]; then
3540
echo "Running legacy run-ops migrations"
3641
# Subshell with tracing off so `set -x` does not print the DSN (with credentials) to the logs.
@@ -40,6 +45,7 @@ if [ -n "$RUN_OPS_LEGACY_DIRECT_URL" ]; then
4045
echo "SKIP_RUN_OPS_LEGACY_MIGRATIONS=1, skipping legacy run-ops migrations."
4146
fi
4247
else
48+
set -x
4349
echo "RUN_OPS_LEGACY_DIRECT_URL not set, skipping legacy run-ops migrations."
4450
fi
4551

@@ -51,6 +57,7 @@ else
5157
echo "SKIP_DASHBOARD_AGENT_MIGRATIONS=1, skipping dashboard agent migrations."
5258
fi
5359

60+
{ set +x; } 2>/dev/null
5461
if [ -n "$CLICKHOUSE_URL" ] && [ "$SKIP_CLICKHOUSE_MIGRATIONS" != "1" ]; then
5562
# Run ClickHouse migrations
5663
echo "Running ClickHouse migrations..."
@@ -76,6 +83,7 @@ elif [ "$SKIP_CLICKHOUSE_MIGRATIONS" = "1" ]; then
7683
else
7784
echo "CLICKHOUSE_URL not set, skipping ClickHouse migrations."
7885
fi
86+
set -x
7987

8088
# Copy over required prisma files
8189
cp internal-packages/database/prisma/schema.prisma apps/webapp/prisma/

0 commit comments

Comments
 (0)