Skip to content

security: remove hardcoded Postgres password fallback#5

Merged
marcabru-tech merged 1 commit into
mainfrom
copilot/remove-hardcoded-password
Apr 10, 2026
Merged

security: remove hardcoded Postgres password fallback#5
marcabru-tech merged 1 commit into
mainfrom
copilot/remove-hardcoded-password

Conversation

Copilot AI commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

GitGuardian flagged the hardcoded databank password embedded as a default fallback in docker-compose.yml, which risks credential exposure in source control.

Changes

  • docker-compose.yml — stripped :-databank default from both POSTGRES_PASSWORD and DATABASE_URL; password must now be explicitly supplied via environment variable
  • .env.example — added to root with POSTGRES_PASSWORD=databank as a local-dev reference template
# Before
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-databank}
DATABASE_URL: postgresql://databank:${POSTGRES_PASSWORD:-databank}@db:5432/databank

# After
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
DATABASE_URL: postgresql://databank:${POSTGRES_PASSWORD}@db:5432/databank

.gitignore already excluded .env, so no change was needed there.

@marcabru-tech marcabru-tech marked this pull request as ready for review April 10, 2026 20:37
Copilot AI review requested due to automatic review settings April 10, 2026 20:37
@marcabru-tech marcabru-tech merged commit cf094a0 into main Apr 10, 2026
3 checks passed
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Remove hardcoded Postgres password fallback for security

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Remove hardcoded password fallback from docker-compose.yml
• Add .env.example template for local development
• Enforce explicit password supply via environment variables
Diagram
flowchart LR
  A["docker-compose.yml<br/>with hardcoded fallback"] -- "remove :-databank<br/>default values" --> B["docker-compose.yml<br/>requires explicit env var"]
  C["new .env.example"] -- "provides local dev<br/>reference template" --> D["developers configure<br/>POSTGRES_PASSWORD"]
  B --> E["enhanced security<br/>no credential exposure"]
  D --> E
Loading

Grey Divider

File Changes

1. .env.example ⚙️ Configuration changes +1/-0

Add environment variable template file

• New file created as local development reference template
• Contains POSTGRES_PASSWORD=databank for developers to use locally
• Complements .gitignore exclusion to prevent accidental commits

.env.example


2. docker-compose.yml Security +2/-2

Remove hardcoded password defaults from services

• Removed hardcoded password fallback from POSTGRES_PASSWORD environment variable
• Removed hardcoded password fallback from DATABASE_URL connection string
• Password must now be explicitly supplied via POSTGRES_PASSWORD environment variable
• Prevents credential exposure in source control

docker-compose.yml


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Apr 10, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2)   📘 Rule violations (0)   📎 Requirement gaps (0)   🎨 UX Issues (0)
🐞\ ≡ Correctness (1) ☼ Reliability (1)

Grey Divider


Action required

1. Compose env var required 🐞
Description
docker-compose.yml now substitutes POSTGRES_PASSWORD without a default/required guard, but the
README Docker instructions don't set it, so docker compose up --build can run with an empty
substitution and break DB/app startup.
Code

docker-compose.yml[9]

+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
Evidence
docker-compose.yml requires POSTGRES_PASSWORD for both the db container password and for
building the app container DATABASE_URL, but the README Docker section provides no step to set
POSTGRES_PASSWORD or create a Compose-readable .env file, so the documented command will not
have the required variable.

docker-compose.yml[6-30]
README.md[158-165]
.gitignore[28-31]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docker compose up --build` is documented as a one-liner, but `docker-compose.yml` now requires `POSTGRES_PASSWORD` to be provided at compose-parse time. Without an explicit guard or documentation, users will hit startup/connection failures.

## Issue Context
The PR intentionally removed the hardcoded fallback. The replacement should still provide a clear, deterministic failure mode and an updated onboarding path.

## Fix Focus Areas
- Enforce required substitution (e.g., `${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}`) for both `POSTGRES_PASSWORD` and `DATABASE_URL` construction.
- Update README Docker instructions to include the required env setup step (e.g., `cp .env.example .env` or exporting `POSTGRES_PASSWORD` before running compose).

- docker-compose.yml[6-30]
- README.md[158-165]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Env example breaks setup 🐞
Description
The new .env.example only defines POSTGRES_PASSWORD, but the documented setup and Prisma schema
require DATABASE_URL, so copying it to .env.local leaves migrations/app without a DB connection
string.
Code

.env.example[1]

+POSTGRES_PASSWORD=databank
Evidence
README instructs copying .env.example to .env.local and then running pnpm prisma migrate dev,
which requires DATABASE_URL. Prisma schema explicitly reads DATABASE_URL via
env("DATABASE_URL"), but .env.example does not define it.

README.md[58-66]
README.md[69-74]
prisma/schema.prisma[5-8]
.env.example[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`.env.example` is used by the README as the starting point for `.env.local`, but it doesn't include `DATABASE_URL`, which Prisma and the documented migration step require.

## Issue Context
This PR introduces `.env.example`, so it should be sufficient for the documented onboarding flow, or the README should be updated to reflect what users must add.

## Fix Focus Areas
- Add a `DATABASE_URL` template entry to `.env.example` (and ensure it matches the intended local workflow: host-based `localhost:5432` vs docker-network `db:5432`, or document both).
- Optionally change `POSTGRES_PASSWORD` example value to a placeholder (to avoid repeated secret-scanner noise), while still showing required shape.

- .env.example[1-1]
- README.md[58-66]
- README.md[69-74]
- prisma/schema.prisma[5-8]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Removes a hardcoded default Postgres password from docker-compose.yml to reduce credential exposure risk and require explicit configuration for local/dev environments.

Changes:

  • Removed :-databank fallback from POSTGRES_PASSWORD and DATABASE_URL in docker-compose.yml.
  • Added a root .env.example intended as a local development environment template.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
docker-compose.yml Removes the hardcoded password fallback from Compose variable expansion.
.env.example Introduces an env template for local setup (currently includes POSTGRES_PASSWORD).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .env.example
@@ -0,0 +1 @@
POSTGRES_PASSWORD=databank

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

POSTGRES_PASSWORD=databank in .env.example reintroduces a hardcoded credential-like value in the repo (likely to keep triggering secret scanners) and also doesn’t provide the DATABASE_URL that Prisma requires (prisma/schema.prisma uses env("DATABASE_URL"), and README.md instructs cp .env.example .env.local). Consider using a non-secret placeholder (e.g., POSTGRES_PASSWORD=changeme) and include a DATABASE_URL=... example (or a comment) so local setup works after copying the file.

Copilot uses AI. Check for mistakes.
Comment thread docker-compose.yml
Comment on lines 7 to 10
POSTGRES_DB: databank
POSTGRES_USER: databank
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-databank}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

Using ${POSTGRES_PASSWORD} without a default or required check means docker compose will substitute an empty string when the variable is unset, which can lead to confusing startup failures (Postgres requires a non-empty password by default, and the app’s DATABASE_URL will be malformed). Prefer Compose’s required-variable form (e.g., ${POSTGRES_PASSWORD:?...}) for both POSTGRES_PASSWORD and the DATABASE_URL substitution so misconfiguration fails fast.

Copilot uses AI. Check for mistakes.
Comment thread docker-compose.yml
POSTGRES_DB: databank
POSTGRES_USER: databank
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-databank}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Compose env var required 🐞 Bug ☼ Reliability

docker-compose.yml now substitutes POSTGRES_PASSWORD without a default/required guard, but the
README Docker instructions don't set it, so docker compose up --build can run with an empty
substitution and break DB/app startup.
Agent Prompt
## Issue description
`docker compose up --build` is documented as a one-liner, but `docker-compose.yml` now requires `POSTGRES_PASSWORD` to be provided at compose-parse time. Without an explicit guard or documentation, users will hit startup/connection failures.

## Issue Context
The PR intentionally removed the hardcoded fallback. The replacement should still provide a clear, deterministic failure mode and an updated onboarding path.

## Fix Focus Areas
- Enforce required substitution (e.g., `${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}`) for both `POSTGRES_PASSWORD` and `DATABASE_URL` construction.
- Update README Docker instructions to include the required env setup step (e.g., `cp .env.example .env` or exporting `POSTGRES_PASSWORD` before running compose).

- docker-compose.yml[6-30]
- README.md[158-165]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread .env.example
@@ -0,0 +1 @@
POSTGRES_PASSWORD=databank

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Env example breaks setup 🐞 Bug ≡ Correctness

The new .env.example only defines POSTGRES_PASSWORD, but the documented setup and Prisma schema
require DATABASE_URL, so copying it to .env.local leaves migrations/app without a DB connection
string.
Agent Prompt
## Issue description
`.env.example` is used by the README as the starting point for `.env.local`, but it doesn't include `DATABASE_URL`, which Prisma and the documented migration step require.

## Issue Context
This PR introduces `.env.example`, so it should be sufficient for the documented onboarding flow, or the README should be updated to reflect what users must add.

## Fix Focus Areas
- Add a `DATABASE_URL` template entry to `.env.example` (and ensure it matches the intended local workflow: host-based `localhost:5432` vs docker-network `db:5432`, or document both).
- Optionally change `POSTGRES_PASSWORD` example value to a placeholder (to avoid repeated secret-scanner noise), while still showing required shape.

- .env.example[1-1]
- README.md[58-66]
- README.md[69-74]
- prisma/schema.prisma[5-8]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants