Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions deployment/choreo/development/docker/postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ RUN groupadd -g 10014 choreo && \
ARG GITHUB_BACKUP_REPO=LDFLK/data-backups
ARG BACKUP_VERSION=0.0.4
ARG BACKUP_ENVIRONMENT=development
# Superuser password is only needed at build time to seed the DB. ARG keeps
# the value out of the runtime image (ENV would persist it in image layers).
# Override at build time: docker build --build-arg POSTGRES_PASSWORD=... .
ARG POSTGRES_PASSWORD=postgres
Comment on lines +25 to +28

# Place data outside /var/lib/postgresql/ entirely so that the base image's
# VOLUME ["/var/lib/postgresql/data"] and Choreo's runtime volume management
# cannot hide the baked-in files.
ENV PGDATA=/opt/pgdata
# Set superuser password so the entrypoint never fails on uninitialized-DB check.
# Must match the password set during build-time data ingestion below.
# FIXME: https://github.com/LDFLK/OpenGIN/issues/448 - Hardcoded password. Use build args instead.
ENV POSTGRES_PASSWORD=postgres

# Create directory and set permissions
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA"
Expand All @@ -52,9 +52,8 @@ RUN echo "Initializing database in $PGDATA..." && \
echo "Starting PostgreSQL..." && \
pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w start && \
\
# Set default password to match docker-compose config
# FIXME: https://github.com/LDFLK/OpenGIN/issues/448 - Hardcoded password.
psql -U postgres -c "ALTER USER postgres WITH PASSWORD 'postgres';" && \
# Set superuser password from the POSTGRES_PASSWORD build arg.
psql -U postgres -c "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';" && \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Avoid passing sensitive information like passwords as command-line arguments to prevent them from being exposed in the process list. Instead, use methods like here strings (<<<) to pass the data via standard input. This approach is more secure than using command-line variables or direct interpolation which can be logged or viewed by other users on the system.

psql -U postgres <<< "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';"
References
  1. Avoid passing sensitive information like passwords as command-line arguments to prevent them from being exposed in the process list. Instead, use methods like here strings (<<<) to pass the data via standard input, or write it to a temporary file that is securely handled and deleted.

\
# Create temp workspace
temp_dir=$(mktemp -d) && \
Expand Down
Loading