Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: release
namespace: openshift
tag: rhel-9-release-golang-1.25-openshift-4.22
tag: rhel-9-release-golang-1.26-openshift-5.0
4 changes: 2 additions & 2 deletions Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS builder
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.26-openshift-5.0 AS builder
WORKDIR /go/src/github.com/openshift/openshift-controller-manager
COPY . .
RUN make build --warn-undefined-variables \
&& gzip openshift-controller-manager-tests-ext

FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
FROM registry.ci.openshift.org/ocp/5.0:base-rhel9

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Set an explicit non-root runtime user in the final stage.

The final image does not declare USER, so it defaults to root. Add a non-root user before shipping this image.

Suggested patch
 FROM registry.ci.openshift.org/ocp/5.0:base-rhel9
 COPY --from=builder /go/src/github.com/openshift/openshift-controller-manager/openshift-controller-manager /usr/bin/
 COPY --from=builder /go/src/github.com/openshift/openshift-controller-manager/openshift-controller-manager-tests-ext.gz /usr/bin/
+USER 1001
 LABEL io.k8s.display-name="OpenShift Controller Manager Command" \
       io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \
       io.openshift.tags="openshift,openshift-controller-manager"

As per coding guidelines, "USER non-root; never run as root".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile.rhel` at line 7, The final image stage (starting with FROM
registry.ci.openshift.org/ocp/5.0:base-rhel9) does not set a non-root runtime
user; add a dedicated non-root user and switch to it in the final stage by
creating a user/group (with a fixed UID/GID), chowning any runtime
directories/assets to that user, and adding a USER <username> (or UID) directive
in the final stage so the container never runs as root.

COPY --from=builder /go/src/github.com/openshift/openshift-controller-manager/openshift-controller-manager /usr/bin/
COPY --from=builder /go/src/github.com/openshift/openshift-controller-manager/openshift-controller-manager-tests-ext.gz /usr/bin/
LABEL io.k8s.display-name="OpenShift Controller Manager Command" \
Expand Down