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.rhel7
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/cluster-kube-controller-manager-operator
COPY . .

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

Restrict COPY to specific files/directories in builder stage.

The builder stage copies the entire build context (.), which may include unnecessary files like .git, temporary files, or sensitive data. While this is in the builder stage (not the final image), it still violates the guideline to copy specific files.

Consider listing only the required directories/files or using a .dockerignore file to exclude unnecessary content.

🔒 Recommended approach

Option 1: Use .dockerignore to exclude unnecessary files:

.git
.github
*.md
tmp/
*.log

Option 2: Copy only specific directories if the structure allows:

-COPY . .
+COPY go.mod go.sum ./
+COPY cmd/ cmd/
+COPY pkg/ pkg/
+COPY vendor/ vendor/
+COPY bindata/ bindata/
+COPY Makefile .

As per coding guidelines: "COPY specific files, not entire context" applies to container builds to minimize attack surface and prevent accidental inclusion of sensitive data.

🤖 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.rhel7` at line 3, The Dockerfile's builder stage currently does a
broad COPY . . which risks including .git, temp files, or secrets; update the
builder stage to copy only needed files/directories (e.g., COPY package.json
package-lock.json ./ and COPY src/ ./) or create/extend a .dockerignore to
exclude .git, .github, *.md, tmp/, *.log so only required build artifacts are
included; ensure the COPY commands in the builder stage are replaced with
specific COPY entries (or add a .dockerignore) rather than copying the entire
context.

Source: Coding guidelines

RUN make build --warn-undefined-variables \
&& gzip cluster-kube-controller-manager-operator-tests-ext

FROM registry.ci.openshift.org/ocp/4.22:base-rhel9-minimal
FROM registry.ci.openshift.org/ocp/5.0:base-rhel9
RUN mkdir -p /usr/share/bootkube/manifests/bootstrap-manifests/ /usr/share/bootkube/manifests/config/ /usr/share/bootkube/manifests/manifests/
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/bootstrap-manifests /usr/share/bootkube/manifests/bootstrap-manifests/
COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/config /usr/share/bootkube/manifests/config/
Expand Down