Skip to content

fix(rocprofiler-systems): fix Dockerfile Trivy misconfigurations - #14129

Merged
dgaliffiAMD merged 6 commits into
developfrom
users/dgaliffi/trivy-fixes
Oct 28, 2026
Merged

dgaliffiAMD merged 6 commits into
developfrom
users/dgaliffi/trivy-fixes

Conversation

@dgaliffiAMD

@dgaliffiAMD dgaliffiAMD commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Fix the HIGH and CRITICAL Dockerfile misconfigurations that Trivy reports for projects/rocprofiler-systems/docker, so these Dockerfiles pass the security scan gate.

This splits the rocprofiler-systems portion out of #13267 ("security: fix all dockerfile related trivy issues") by @cgoea so it can be reviewed and merged with this project's changes on their own. The original commit is cherry-picked here with authorship credit preserved. The changes to other projects remain in #13267.

Technical Details

  • Cherry-picked the projects/rocprofiler-systems changes from security: fix all dockerfile related trivy issues #13267 (by Ciprian Goea):
    • --no-install-recommends on apt-get install (DS-0029)
    • zypper clean --all after installs in the openSUSE image (DS-0020)
    • explicit USER root with # trivy:ignore:DS-0002 on these build/dev images, so the runtime user is unchanged
  • Follow-up fixes on top:
    • Install ca-certificates explicitly in Dockerfile.ubuntu*, because --no-install-recommends no longer pulls it in as a Recommends and the images download over HTTPS (wget).
    • Install python3-dev explicitly in Dockerfile.ubuntu*. It was previously pulled in as a Recommends of python3-pip, and without it the Development.Module lookup fails when building the Python bindings against the system interpreter.
    • Remove /var/lib/apt/lists in the same RUN that creates it, and run apt-get update before installing the amdgpu-install .deb, since the earlier RUN's lists are now removed.
    • Use apt-get clean instead of apt-get autoclean in Dockerfile.ubuntu*, since autoclean removes almost nothing in a fresh image.
    • Run apt-get update before apt-get install libopenmpi-dev in the "Install MPI" step of rocprofiler-systems-continuous-integration.yml, because the systems-ci-multiarch image (built from Dockerfile.ubuntu.ci) no longer ships the apt lists.
    • Apply the same changes to the Dockerfile.{ubuntu,opensuse,rhel}.ci variants. Trivy does not scan files named Dockerfile.*.ci, so they were not covered by the original PR. Scanning renamed copies showed the same failures as their non-CI counterparts.

Issue Tracking

JIRA ID: ROCM-28051
JIRA ID: AIPROFSYST-830

Test Plan

Ran trivy config --severity HIGH,CRITICAL --file-patterns "dockerfile:Dockerfile.*" docker/ on projects/rocprofiler-systems.

The GPU CI job's "Install MPI" step only exercises the workflow change after the systems-ci-multiarch image is republished following merge, so it is not covered by this PR's CI.

Test Result

Before: the .ci files reported DS-0002, DS-0020 and DS-0029. After: 0 HIGH/CRITICAL findings on all six Dockerfiles. The images were not built locally; the container CI jobs for this PR cover the build.

Submission Checklist

@dgaliffiAMD
dgaliffiAMD requested review from a team and jrmadsen as code owners October 23, 2026 04:05
Copilot AI balanced review requested due to automatic review settings October 23, 2026 04:05
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass PR does not contain code files — Unit Test auto-passed
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both Ubuntu package lists need explicit Python development headers to preserve binding builds against the system interpreter.

1 open issue
What changed in this PR

This PR isolates the rocprofiler-systems Dockerfile security-scan fixes from #13267, applying them to development and CI images while preserving root execution.

Changes:

  • Disable recommended APT packages, explicitly install CA certificates, and clean package lists in Ubuntu images.
  • Add or normalize openSUSE package-cache cleanup.
  • Declare USER root with a documented Trivy exception in all six images.
File Description
projects/​rocprofiler-systems/​docker/​Dockerfile.ubuntu.ci Update APT installs, certificates, cleanup, and root declaration.
projects/​rocprofiler-systems/​docker/​Dockerfile.ubuntu Update APT installs, certificates, cleanup, and root declaration.
projects/​rocprofiler-systems/​docker/​Dockerfile.rhel.ci Declare intentional root execution with a Trivy exception.
projects/​rocprofiler-systems/​docker/​Dockerfile.rhel Declare intentional root execution with a Trivy exception.
projects/​rocprofiler-systems/​docker/​Dockerfile.opensuse.ci Normalize cache cleanup and declare root execution.
projects/​rocprofiler-systems/​docker/​Dockerfile.opensuse Clean package caches and declare root execution.

Review effort: Balanced

@dgaliffiAMD
dgaliffiAMD requested a review from a team as a code owner October 23, 2026 18:57
@github-actions github-actions Bot added the github actions Pull requests that update GitHub Actions code label Oct 23, 2026
dgaliffiAMD and others added 6 commits October 27, 2026 17:33
Co-authored-by: Ciprian Goea <ciprian.goea@amd.com>
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
--no-install-recommends no longer pulls in Recommends, so install
ca-certificates explicitly instead of relying on python3-pip's
transitive dependency for the HTTPS downloads. Remove
/var/lib/apt/lists in the same RUN that populates it so the cleanup
actually shrinks the image, and run apt-get update before installing
the amdgpu-install deb since the first RUN's lists are now removed.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
Apply the same hardening as the non-CI Dockerfiles, which Trivy
does not scan under the Dockerfile.*.ci names: add
--no-install-recommends, install ca-certificates explicitly, clean apt
lists in the same RUN, use plain `zypper clean --all`, and make the
root user explicit with a DS-0002 ignore.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
python3-dev was previously pulled in as a Recommends of python3-pip.
With --no-install-recommends the Python headers are missing, which
breaks the Development.Module lookup when building the Python bindings
against the system interpreter. List it explicitly.

Also sort the apt package lists alphabetically and wrap them at about
90 columns. No other packages are added or removed.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
The systems-ci-multiarch image no longer ships /var/lib/apt/lists, so
the Install MPI step must run apt-get update before installing
libopenmpi-dev.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
apt-get autoclean only removes obsolete cached packages and does almost
nothing in a fresh image; clean removes all cached .deb files.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
@dgaliffiAMD
dgaliffiAMD force-pushed the users/dgaliffi/trivy-fixes branch from 05edc81 to f616bc5 Compare October 27, 2026 21:33
@dgaliffiAMD
dgaliffiAMD merged commit 1420d37 into develop Oct 28, 2026
230 of 235 checks passed
@dgaliffiAMD
dgaliffiAMD deleted the users/dgaliffi/trivy-fixes branch October 28, 2026 16:16
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github actions Pull requests that update GitHub Actions code organization: ROCm project: rocprofiler-systems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants