Skip to content

Commit 4a59480

Browse files
committed
Move password-redaction filter to a standalone script
Inline python3 -c couldn't be indented to match entrypoint.sh's style without breaking Python's indentation-sensitive syntax. Move it to redact_secret.py (picked up by the existing COPY . /app/ in the Dockerfile) so both files keep normal, consistent indentation.
1 parent 751c4c2 commit 4a59480

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

services/superset/entrypoint.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@ set -euo pipefail
55
DB_PASSWORD=$(< /run/secrets/mysql_superset_password)
66
DB_URI="mysql+mysqlconnector://superset:${DB_PASSWORD}@${VIRTUAL_IP_ADDRESS}:6446/superset"
77

8-
# -x stays off here: tracing this line, or superset test_db's own "SQLAlchemy
9-
# URI" printout, would put the plaintext DB password into docker logs/docker
10-
# service logs. Redact stdout+stderr as a backstop in case anything
11-
# downstream still echoes the URI.
128
if superset test_db "$DB_URI" --connect-args {} 2>&1 \
13-
| DB_PASSWORD="$DB_PASSWORD" python3 -c '
14-
import os, sys
15-
pw = os.environ["DB_PASSWORD"]
16-
for line in sys.stdin:
17-
sys.stdout.write(line.replace(pw, "<redacted>"))
18-
sys.stdout.flush()
19-
'; then
9+
| DB_PASSWORD="$DB_PASSWORD" python3 /app/redact_secret.py; then
2010
set -x
2111

2212
superset fab create-admin \

services/superset/redact_secret.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
5+
pw = os.environ["DB_PASSWORD"]
6+
for line in sys.stdin:
7+
sys.stdout.write(line.replace(pw, "<redacted>"))
8+
sys.stdout.flush()

0 commit comments

Comments
 (0)