OWASP / OWASP/SecurityShepherd

Move database configuration from build-time to runtime environment variables

Open
#814 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.5k
Forks
515
Avg merge
3h 46m
Merged PRs (30d)
1

Description

Problem

Database configuration (database.properties, mongo.properties) is currently generated at Docker image build time via printf in the Dockerfile (line 28-29). This has several drawbacks:

  1. Changing any setting requires rebuilding the image — admins can't tune pool sizes, timeouts, or credentials without a full rebuild
  2. New pool settings aren't exposed — the HikariCP connection pool settings (pool.maximumPoolSize, pool.minimumIdle, pool.leakDetectionThreshold, etc.) added in #800 have no way to be configured in a standard deployment
  3. Secrets baked into image layersDB_PASS is written via printf in a RUN step, making it visible in docker image history

Proposed solution

Replace the build-time printf with a runtime entrypoint script that generates database.properties and mongo.properties from environment variables when the container starts.

Benefits
  • Change settings by restarting the container, no rebuild needed
  • Pool tuning via .env or docker-compose.yml (e.g. DB_POOL_MAX_SIZE=20)
  • Secrets only exist at runtime, not in image layers
  • Standard Docker pattern that admins expect
Example
# docker-compose.yml
environment:
  - DB_HOST=secshep_mariadb
  - DB_PORT=3306
  - DB_USER=root
  - DB_PASS=secret
  - DB_SCHEMA=core
  - DB_POOL_MAX_SIZE=10
  - DB_POOL_MIN_IDLE=2
  - DB_POOL_LEAK_DETECTION_THRESHOLD=60000
  - MONGO_HOST=secshep_mongo
  - MONGO_PORT=27017

An entrypoint script would generate the properties files from these env vars (with sensible defaults) before starting Tomcat.

Related

  • #536 — connection exhaustion issue (motivation for pool settings)
  • #800 — connection pooling implementation (adds configurable pool settings)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Dockerfile at lines 28-29 and inspect the existing database.properties and mongo.properties generation, then review the docker-compose.yml environment examples. Add a runtime entrypoint that creates both files before Tomcat starts, including the pool settings and sensible defaults. Done means configuration changes work after a restart and DB_PASS is not present in Docker image history.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, mariadb, mongodb
Domain
database, devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.