Repository navigation
Harden image and fix Snyk URL sanitization - #14
Conversation
…r URL unwrap. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🔴 Claude BugBot Analysis
Found 1 potential bug in this PR.
medium: 1
The URL-unwrap hardening in normalize.py is correct. The Alpine non-root Dockerfile creates a permissions regression with the existing ./data bind mount, which can break persistence of seen.json.
| @@ -1,20 +1,35 @@ | |||
| FROM python:3.12-slim | |||
| # syntax=docker/dockerfile:1 | |||
There was a problem hiding this comment.
🟡 MEDIUM: Non-root user (uid 1001) cannot write to the bind-mounted ./data directory
The image now runs as appuser (uid 1001) and only chowns /app/data inside the image. docker-compose.yml bind-mounts ./data:/app/data, and that mount hides the chowned directory. On a Linux host, ./data is owned by the host user (commonly uid 1000) or by root, so uid 1001 gets no write access. data/seen.json then can't be saved, so seen-URL state is lost or the run errors, and the digest re-emails the same items every day. Fix: make the container uid configurable and match the host, for example user: "${UID:-1000}:${GID:-1000}" in compose. Alternatively, document a required chown 1001:1001 data step, or use a named volume.
⚠️ Could not locate exact line in the diff. The bug is atDockerfile:70.
Additional Locations
docker-compose.yml:12— The bind mount ./data:/app/data overrides the in-image chown of /app/data
There was a problem hiding this comment.
Fixed in bb80a15. The image user is now uid/gid 1000, and compose runs as ${APP_UID:-1000}:${APP_GID:-1000} (documented in .env.example). The README has a one-time chown step for existing root-owned data/ directories left by the old root image. I checked locally that the container runs as 1000 and that save_seen/load_seen round-trip under /app/data.
Luen
left a comment
There was a problem hiding this comment.
Review
src/normalize.py / tests: Looks good. _is_google_host correctly rejects evilgoogle.com, and the explicit http:///https:// prefix check closes the httpevil:// gap. Both cases have tests.
Dockerfile / compose (blocking): The BugBot finding is valid, and the real impact is a little worse than it says:
- The image now runs as uid 1001, but
docker-compose.ymlbind-mounts./data:/app/data, which hides the in-imagechown. On a Linux host, uid 1001 usually can't write there. - The old image ran as root, so an existing production
data/seen.jsonis root-owned. The first run after deploy would fail insave_seen()aftersend_digest(). The email goes out, the state isn't saved, and the same items get re-emailed every day. (run_schedulelogs the exception and keeps looping, so this fails quietly.)
Nit: --mount=type=cache,target=/root/.cache/pip doesn't do anything while --no-cache-dir is set.
I'll push a fix: uid/gid 1000 in the image, a configurable user: in compose (APP_UID/APP_GID), a README migration note (chown the existing data/), and removal of the unused pip cache mount.
The bind mount hides the in-image chown, so uid 1001 couldn't write seen.json on typical Linux hosts (and older root-owned data/ dirs), which would re-email the same items after every run. Use uid/gid 1000, make the compose user configurable via APP_UID/APP_GID, document the one-time chown for existing data/, and drop the pip cache mount that --no-cache-dir made a no-op. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
python:3.12.16-alpine3.24build that runs as a non-root user, clearing the Dockerfile Critical/High Snyk Container findings (rescanned image: no vulnerable paths).evilgoogle.com/httpevil://lookalikes) that caused the medium Snyk Code finding; rescanned with 0 code issues..dockerignoreand Dependabot Docker updates so base-image bumps stay automated.Test plan
ruff check . --fix && ruff format .pytestdocker compose buildanddocker compose run --rm digest python -m src --dry-runmedia-alerts-digest:latest: no vulnerable pathsMade with Cursor