fix: do not log the database password on startup - #343
Conversation
|
pre-commit.ci run |
The startup script prints EXTERNAL_DB verbatim, so a deployment using an external vector database writes its password into the container log on every start, where docker logs and any log shipper will pick it up. Redact the credentials before printing. The scheme, user, host and database name stay visible, which is what the line is useful for. Signed-off-by: Baki Burak Öğün <63836730+bakiburakogun@users.noreply.github.com>
978743e to
3b25fcb
Compare
kyteinsky
left a comment
There was a problem hiding this comment.
hello,
thanks for the PR!
it seems there is some issue with the sed replacement.
see https://github.com/nextcloud/context_chat_backend/actions/runs/33286580772/job/99755336536?pr=343#step:41:16
EXTERNAL_DB="postgresql+psycopg://root:rootpassword@${{ env.NODE_IP }}:4445/nextcloud"
yields
Using EXTERNAL_DB, CCB_DB_URL is set to: ***10.1.0.218:4445/nextcloud
### Problem `check-ai-trailers` fails on every pull request from a fork, whatever the commits contain. The first step never gets as far as inspecting them: ``` gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable. Process completed with exit code 4 ``` Secrets are not exposed to `pull_request` runs from forks, so `secrets.COMMAND_BOT_PAT` is empty and `gh api` exits 4. ### Change Fall back to `github.token`, which is what the organization template in [nextcloud/.github](https://github.com/nextcloud/.github/blob/master/.github/workflows/ai-policy.yml) already does: ```yaml GH_TOKEN: ${{ secrets.COMMAND_BOT_PAT || github.token }} ``` `nextcloud/spreed` already carries the updated version; this copy predates it. The workflow declares the permissions it needs (`contents: read`, `pull-requests: write`, `issues: write`), so the default token can read the commit list. Noticed because it is the only red check on #343. Signed-off-by: Baki Burak Öğün <63836730+bakiburakogun@users.noreply.github.com>
The character class stopped at the first '@', so a password containing one left the rest of it in the log. Matching up to the last '@' of the authority fixes that, and staying inside [^/] keeps an '@' in a later path segment from swallowing the host. Signed-off-by: Baki Burak Öğün <63836730+bakiburakogun@users.noreply.github.com>
|
Thanks for looking at it. I went through that job output, and I think the The same line on master, without this PR, looks the same. For example run 33121423491 from 27 August, on commit 040adab: At that point the script still printed Your review did turn up a real problem, though, just a different one. The character class stopped at the first I have pushed a commit that matches up to the last
The failing |
The problem
dockerfile_scripts/pgsql/setup.shprintsEXTERNAL_DBverbatim on every start:On a deployment that uses an external vector database, that means the database password lands in the container log:
docker logsshows it to anyone who can reach the daemon, and any log shipper carries it off the host. We noticed it while bringing up a four node deployment against an external Patroni cluster: the password we had just written to a0600env file was indocker logsa minute later.The change
Redact the credentials before printing. The scheme, user, host and database name — the parts that make the line useful for diagnosis — stay visible:
Testing
bash -non the script is clean.Related: I sent the same class of fix to nextcloud/whiteboard in #1316, where the websocket server logged its Redis password the same way.