Skip to content

fix(security): judge Trivy-config DS-0002 in .devcontainer/Dockerfile #5368

Not planned

Description

@github-actions

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 config with the Trivy that src/devops_cli/tools_lock/tools.lock pins.
  • THEN The command prints no finding whose title holds [DS-0002], so trivy config no 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 Image job runs devcontainer build --workspace-folder . --config .devcontainer/image/devcontainer.json --frozen-lockfile and then .github/actions/devcontainer-smoke on the pushed digest.
  • THEN The job exits 0, devcontainer exec --workspace-folder ... id -un prints vscode, and the smoke step's test "$(id -u):$(id -g)" = 1000:1000 passes.

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 a USER <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 as vscode, 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/Dockerfile by adding a final USER 1000:1000 instruction. Do not dismiss the alert and do not add a .trivyignore.yaml entry. (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:374 names no USER, and one USER 1000:1000 line 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.yaml entry. SECURITY.md allows an entry only when the fix breaks the workload or needs an unreleased change; a final USER line changes no build step, and an ignore hides the finding instead of fixing it.
  • How does the Dockerfile declare the non-root user?: Append USER 1000:1000 as the last instruction of the final stage, after the last COPY, 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:1000 after the last COPY. The common-utils feature creates vscode with 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 numeric USER changes no build step and needs no passwd entry at build time.
    • Rejected: Name the user, USER vscode. The Dockerfile build has no vscode entry, 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 useradd and then set USER. The common-utils feature already creates uid and gid 1000 for vscode (.devcontainer/image/devcontainer.json:8), so a second user with that id duplicates the feature's work.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/security
    on Nov 13, 2026
  2. added
    status/new
    value/medium
    effort/low
    on Nov 13, 2026
  3. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. dan-petty commented on Nov 26, 2026

    @dan-petty
    Owner

    Closed: the finding is fixed.

    .devcontainer/Dockerfile now builds from the devtools image, and its final stage project sets USER vscode. Code scanning alert 214 shows fixed since 2026-11-20. trivy config 0.76.2 on 2026-11-26 reports 0 HIGH or CRITICAL findings for the file.

  6. removed
    status/new
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/securitytype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions