Skip to content

Housekeeping: Passenger/nginx security and config fixes, dev reload, Dependabot - #92

Merged
jrhoads merged 2 commits into
masterfrom
housekeeping
Nov 25, 2026
Merged

jrhoads merged 2 commits into
masterfrom
housekeeping

Conversation

@jrhoads

@jrhoads jrhoads commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Third PR of the viringo modernization (after #87 image/deps, #88 CI/CD, #89 CI speed-up).

Security

  • Passenger ran in development mode (vendor/docker/00_app_env.conf). That enables Passenger's friendly error pages, which list the process environment when the app fails to start. Reproduced on master: a startup failure returned a 500 page containing DATACITE_API_ADMIN_PASSWORD and its value. Now production; the same failure shows a generic error page.

Fixes

  • CORS headers were malformed (Access-Control-Allow-Origin: *: always), so browsers rejected them. Fixed add_header syntax. Note: this effectively turns CORS on for the first time (public, read-only endpoint, no credentials).
  • Static files: removed a location / block pointing at a nonexistent middleman build dir; nginx now serves viringo/static (/favicon.ico was 404, now 200).
  • Dev reload never worked: the marker was written to viringo/tmp while passenger_restart_dir is /home/app/webapp/tmp. Now triggered by FLASK_DEBUG=1 docker compose up (Flask removed FLASK_ENV), the marker lives in the restart dir, is removed on normal starts, and is no longer committed. Edits are picked up within ~10 s (Passenger stat throttle).

Cleanup

  • Add .github/dependabot.yml: weekly version updates for pip (minor/patch grouped), the Docker base image, and GitHub Actions (grouped).
  • Move factory-boy (and faker) out of production packages; via pipenv uninstall, so all other pins are unchanged. A full relock would have bumped sentry-sdk 2 → 3, left for Dependabot.
  • Remove Travis script and obsolete compose version:; readme uses GitHub Actions badge, docker compose, flask --app viringo run --debug.

Testing

  • Built the image locally; checked CORS on 200/404, favicon and XSL served, forced startup failure shows no env/secrets, sshd still listening, PUBLIC_KEY written to authorized_keys, no factory-boy/faker/pytest in the prod venv.
  • CI flow (docker compose up --no-build + bin/ci.sh): 25/25 tests pass.
  • FLASK_DEBUG=1 compose: dev deps installed, app.debug true, source edit reloaded; normal start removes the marker.
  • Local review with Codex (gpt-6.1-sol, high): no findings.

Not included

  • SSH host keys: containers share the host keys from the public base image (as before). Left unchanged because SSH is only reachable inside the VPC via the bastion, and per-container keys would churn known_hosts on every deploy. Longer term, ECS Exec could replace sshd.
  • Renaming the misspelled pull_reqest.yml.
  • The live DataCite API test that gates deploys (tracked separately).

🤖 Generated with Claude Code

…add Dependabot

Security
- Run Passenger with passenger_app_env production. Development mode enabled
  friendly error pages, which list the process environment (including
  DATACITE_API_ADMIN_PASSWORD) when the app fails to start.
- Delete the SSH host keys shipped in the public base image so each container
  generates its own at startup instead of all sharing well-known keys.

Fixes
- cors.conf: correct add_header syntax; headers were emitted as
  "Access-Control-Allow-Origin: *: always", which browsers reject.
- webapp.conf: drop the location block pointing at a nonexistent middleman
  build dir so nginx serves viringo/static (e.g. /favicon.ico).
- Dev reload: trigger on FLASK_DEBUG (FLASK_ENV is gone from Flask), write the
  always_restart marker into passenger_restart_dir, remove it on normal starts,
  stop committing it, and pass FLASK_DEBUG through compose and nginx.

Cleanup
- Add .github/dependabot.yml (pip, docker, github-actions).
- Move factory-boy out of production packages (lockfile otherwise unchanged).
- Remove Travis script, obsolete compose version key; update readme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jrhoads
jrhoads requested a review from a team November 24, 2026 13:21

@digitaldogsbody digitaldogsbody left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tentative approval because some parts are good to go (fixing the broken CORS etc) but I have concerns about whether all of the other changes find a balance between being beneficial (or even necessary) vs adding complexity.

Comment thread Dockerfile Resolved
Comment on lines +2 to +4
# Must not be "development": that turns on Passenger's friendly error pages,
# which show the process environment (including secrets) when the app fails.
passenger_app_env production;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The logic here is sound-ish, but it varies from our usual pattern, which is to leave this as development to make it simpler for local work, and then set the environment variable appropriately for the deployed containers using terraform.

See https://github.com/datacite/mastino/blob/master/prod-eu-west/services/client-api/client-api.json#L29-L32 and https://github.com/datacite/mastino/blob/master/stage/services/client-api/client-api.json#L24-L27

I personally think having the friendly error pages turned on by default when developing locally is a more useful approach than having to remember to explicitly enable them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Usually this is the case with how we configure things in mastino. The oai service was not setup this way. I think it better to be defensive with this so that the default is more secure and devs can turn on the dev interface if desired

Comment on lines +7 to +13
case "${FLASK_DEBUG,,}" in
"" | 0 | false | no)
# Don't keep restarting because of a file left behind by an earlier dev run.
rm -f "$RESTART_FILE"
exit 0
;;
esac

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this actually happen in practice? If the container has been stopped and restarted with different env variables, I would have expected docker to recreate it, which means the restart file wouldn't exist, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, I know this is a not a change from this PR, but why are we creating a whole directory for this file and not just keeping it in /tmp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think your comment is far. This PR was more to align with FLASK_ENV vs FLASK_DEBUG
In production neither would be used, and in dev I think it much more likely we would just rebuild the container.

Comment thread vendor/docker/webapp.conf
passenger_python /home/app/venv/bin/python;
passenger_app_root /home/app/webapp/;
# 20_always_restart.sh creates tmp/always_restart.txt here in development.
passenger_restart_dir /home/app/webapp/tmp;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As commented elsewhere, I think we could just use /tmp for this and save ourselves some hassle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can look at this going forward but if i recall, many (any?) users can write to /tmp
whereas to write to /home/app/webapp/tmp they would have to be part of a very small group.

The container is only reachable inside the VPC via the bastion, so per-container
host keys aren't worth the known_hosts churn on every deploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jrhoads jrhoads changed the title Housekeeping: Passenger/nginx security and config fixes, SSH host keys, Dependabot Housekeeping: Passenger/nginx security and config fixes, dev reload, Dependabot Nov 24, 2026
@jrhoads
jrhoads merged commit 924c2d9 into master Nov 25, 2026
1 check passed
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.

2 participants