feat(docker): harden backend and frontend images with non-root user and Trivy CVE scanning#364
Conversation
utksh1
left a comment
There was a problem hiding this comment.
Requesting changes. The idea is useful, but multiple new Docker hardening/Trivy jobs are failing and formatting-hygiene is red. Please make the hardening checks deterministic in CI, fix the failing Trivy/policy gates, remove any line-ending/formatting issues, and keep the tests runnable without requiring local Docker unless they are explicitly skipped.
|
Thanks for following up. Clarifying the change request so it is actionable: Why this is blocked: What to do next:
|
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
|
Hey! Fixed the CI issues, bumped trivy-action to v0.36.0 and cleaned up trailing whitespace across the new files. All jobs are green now, feel free to take a look! |
utksh1
left a comment
There was a problem hiding this comment.
Re-reviewed latest state. CI is now green, but this remains high-blast-radius Docker/CI work. Please make sure Docker-dependent tests are explicitly skipped or isolated when Docker is unavailable, and split policy/Trivy workflow changes from Dockerfile hardening if possible so failures are easier to diagnose and review.
|
Hey! Docker-dependent tests are already guarded via pytest.mark.skipif, requires_docker and requires_trivy markers skip the relevant test classes automatically when Docker or Trivy is unavailable. Will split the trivy workflow changes from the docker one. Any other changes before I start working ? |
utksh1
left a comment
There was a problem hiding this comment.
Re-reviewed after the latest updates and maintainer cleanup. The Docker/Trivy workflows are split, Docker-dependent checks are isolated in CI, formatting is fixed, the JSON Trivy report artifact is generated before upload, and all CI checks are passing.
Description
Hardens the Docker setup for both backend and frontend containers as outlined in issue #245.
Changes include running containers as non-root users, pinning base images to specific versions, patching a critical OpenSSL CVE (CVE-2026-31789), adding a GitHub Actions workflow for automated Trivy vulnerability scanning, and documenting a base image update policy.
Also fixes two pre-existing bugs discovered during testing:
CMDpointed tosecuscan.apiwhich does not exist, corrected tosecuscan.mainCOPY pluginsin the backend Dockerfile referenced a path outside the build context, removed since plugins are injected via volume mount at runtimeRelated Issues
Closes #245
Type of Change
How Has This Been Tested?
Integration tests: new pytest suite covering all hardening requirements:
All tests passed:
TestNonRootUser- backend runs assecuscan(UID 1001), frontend asnginx(UID 101)TestSUIDFiles- no unexpected SUID/SGID binaries in either imageTestDockerfileStructure- USER instruction, pinned base, HEALTHCHECK, apt cleanup all verifiedTestTrivyCVEGate- zero unfixed CRITICAL CVEs in both images after patching OpenSSLManual smoke tests:
Full stack:
docker compose up --build # GET /api/v1/health HTTP/1.1" 200 OK healthcheck passingChecklist