Repository navigation
Description
Trivy reports a misconfiguration that no issue names.
- Rule: DS-0002
- Path: .devcontainer/Dockerfile
- Severity: HIGH
Open alerts:
Judge it under "Judging a Trivy-config Alert" in SECURITY.md: fix the file, dismiss the alert with a reason, or add a time-limited entry to .trivyignore.yaml. The owner judges a CRITICAL alert within 24 hours. An agent judges any other alert within 14 days.
Proposed design
Problem statement
Trivy code scanning reports HIGH misconfiguration DS-0002, "Image user should not be root", in .devcontainer/Dockerfile, whose final stage names no USER instruction, so code-scanning alert 214 stays open even though the built DevContainer image runs as vscode (uid 1000) through its Dev Container features and metadata. The change adds a final USER 1000:1000 instruction so the Dockerfile itself declares the non-root user that the image runs as, and Trivy clears alert 214.
Acceptance criteria
Requirement: Dockerfile declares the non-root user
The final stage of .devcontainer/Dockerfile MUST end with a USER 1000:1000 instruction.
Scenario: Trivy clears DS-0002
- WHEN A person runs
uv run devops scan trivy .devcontainer/Dockerfile --type configwith the Trivy thatsrc/devops_cli/tools_lock/tools.lockpins. - THEN The command prints no finding whose title holds
[DS-0002], sotrivy configno longer reports "Image user should not be 'root'" for that file.
Requirement: Image keeps its non-root runtime user
The DevContainer image that the pull request builds MUST still install its features and run as vscode with uid and gid 1000:1000.
Scenario: The image smoke check passes
- WHEN The
DevContainer Imagejob runsdevcontainer build --workspace-folder . --config .devcontainer/image/devcontainer.json --frozen-lockfileand then.github/actions/devcontainer-smokeon the pushed digest. - THEN The job exits 0,
devcontainer exec --workspace-folder ... id -unprintsvscode, and the smoke step'stest "$(id -u):$(id -g)" = 1000:1000passes.
Requirement: Alert 214 closes
The change MUST close open code-scanning alert 214 as fixed.
Scenario: Alert 214 is fixed after the merge
- WHEN After the change is on the default branch, a person runs
gh api repos/dan-petty/devops-cli/code-scanning/alerts/214 --jq '.state'. - THEN The command prints
fixed.
Existing Tool Considered
Trivy (Aqua Security) is the open, maintained tool that covers the need: the repository pins it (src/devops_cli/security/trivy.py:223, .devcontainer/Dockerfile:96) and its trivy config check DS-0002 reports the missing non-root user (tests/security/test_secops.py:82). Trivy lacks an automatic fix — its resolution asks for a USER <non root user name> line (tests/security/test_secops.py:85) — and a decision, which this change makes by editing the Dockerfile. No alternatives check has run.
Key questions
- What does Trivy DS-0002 require?: DS-0002 is Trivy's "Image user should not be 'root'" check. It fires when the final stage of a Dockerfile names no
USER, and Trivy's resolution is to add aUSER <non root user name>line to the Dockerfile. [sources: tests/security/test_secops.py:83, tests/security/test_secops.py:85, openspec/changes/archive/2026-10-28-2214-pin-kubeconform-drop-checkov/proposal.md:60] - What runtime user does the project require for a Docker container?: SECURITY.md principle 5 requires Kubernetes pods, Docker containers and CI jobs to run under
USER 1000:1000, and the DevContainer image already runs asvscode, uid and gid 1000, after its features are installed. [sources: SECURITY.md:21, .github/actions/devcontainer-smoke/action.yml:42] - Does a person need to judge this HIGH alert?: No. SECURITY.md gives the owner the CRITICAL alerts within 24 hours and an agent every other alert, such as this HIGH one, within 14 days. A person dismisses an alert in code scanning, and this change dismisses none. [sources: SECURITY.md:101, SECURITY.md:106]
- Which action resolves open alert 214?: Fix
.devcontainer/Dockerfileby adding a finalUSER 1000:1000instruction. Do not dismiss the alert and do not add a.trivyignore.yamlentry. (best practice) [sources: SECURITY.md:104, SECURITY.md:105, SECURITY.md:106, tests/security/test_secops.py:85]- Chosen: Fix the Dockerfile. SECURITY.md makes the fix the first choice, the final stage at
.devcontainer/Dockerfile:374names noUSER, and oneUSER 1000:1000line adds the non-root user Trivy asks for with no expiry and no dismissal. - Rejected: Dismiss alert 214 with a reason. SECURITY.md reserves a dismissal to a person and an agent does not dismiss an alert, and the Dockerfile would keep no declared user.
- Rejected: Add a time-limited
.trivyignore.yamlentry. SECURITY.md allows an entry only when the fix breaks the workload or needs an unreleased change; a finalUSERline changes no build step, and an ignore hides the finding instead of fixing it.
- Chosen: Fix the Dockerfile. SECURITY.md makes the fix the first choice, the final stage at
- How does the Dockerfile declare the non-root user?: Append
USER 1000:1000as the last instruction of the final stage, after the lastCOPY, and create no user in the Dockerfile. (best practice) [sources: .devcontainer/image/devcontainer.json:8, .devcontainer/image/devcontainer.json:64, .github/actions/devcontainer-smoke/action.yml:42]- Chosen: A final
USER 1000:1000after the last COPY. The common-utils feature createsvscodewith uid and gid 1000 (.devcontainer/image/devcontainer.json:8) and the image runs as that user (.github/actions/devcontainer-smoke/action.yml:42); the last build step is a COPY, so a trailing numericUSERchanges no build step and needs no passwd entry at build time. - Rejected: Name the user,
USER vscode. The Dockerfile build has novscodeentry, because the common-utils feature creates it after the Dockerfile build (.devcontainer/image/devcontainer.json:8), while the numeric id matches the uid the image runs as. - Rejected: Create the user with
useraddand then setUSER. The common-utils feature already creates uid and gid 1000 forvscode(.devcontainer/image/devcontainer.json:8), so a second user with that id duplicates the feature's work.
- Chosen: A final
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 13, 2026
Both items judge Trivy-config alerts in .devcontainer/Dockerfile, but 4409 covers all 52 open alerts and the candidate covers only DS-0002.devops-cli-service commentedon Nov 17, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
dan-petty commentedon Nov 26, 2026
Closed: the finding is fixed.
.devcontainer/Dockerfilenow builds from the devtools image, and its final stageprojectsetsUSER vscode. Code scanning alert 214 showsfixedsince 2026-11-20.trivy config0.76.2 on 2026-11-26 reports 0 HIGH or CRITICAL findings for the file.