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 images/Dockerfile.ocp
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

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and show the Dockerfile content with line numbers
ls -la images || true
sed -n '1,200p' images/Dockerfile.ocp | cat -n

# Quick focused checks
echo "---- FROM lines ----"
rg -n '^FROM ' images/Dockerfile.ocp || true

echo "---- USER lines ----"
rg -n '^\s*USER\s+' images/Dockerfile.ocp || true

echo "---- HEALTHCHECK lines ----"
rg -n '^\s*HEALTHCHECK\s+' images/Dockerfile.ocp || true

echo "---- COPY . . patterns ----"
rg -n 'COPY\s+\.\s+\.' images/Dockerfile.ocp || true
rg -n 'COPY\s+\.\s+/' images/Dockerfile.ocp || true
rg -n 'COPY\s+\.\s+\.' -S images/Dockerfile.ocp || true

Repository: openshift/agent-installer-utils

Length of output: 1065


Fix container policy violations in images/Dockerfile.ocp (base image, COPY scope, USER, HEALTHCHECK)

  • FROM registry.ci.openshift.org/... (lines 1 and 7) violates the requirement to use UBI minimal/distroless images from catalog.redhat.com.
  • COPY . . (line 3) violates “COPY specific files, not entire context”.
  • Final stage has no USER non-root and no HEALTHCHECK (no USER/HEALTHCHECK present in the file).
🧰 Tools
🪛 Trivy (0.69.3)

[error] 1-1: Image user should not be 'root'

Specify at least 1 USER command in Dockerfile with non-root user as argument

Rule: DS-0002

Learn more

(IaC/Dockerfile)

🤖 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 `@images/Dockerfile.ocp` at line 1, Replace the builder base image reference to
a supported UBI minimal or distroless image from catalog.redhat.com (swap the
FROM registry.ci.openshift.org/... line to the appropriate catalog.redhat.com
UBI Go builder), change the broad COPY . . to copy only the needed
files/artifacts (replace COPY . . with explicit COPY statements for go.mod,
go.sum, source files and built binary used by the final stage), ensure the final
stage in this Dockerfile sets a non-root user (add USER <non-root-uid> or create
a user and switch to it in the final stage) and add a HEALTHCHECK instruction to
the final stage that verifies the app is alive (e.g., curl or tcp check) so the
image satisfies policy; locate these changes around the builder stage name
"builder", the COPY directives, and the final stage where USER and HEALTHCHECK
must be added.

Source: Coding guidelines

WORKDIR /go/src/github.com/openshift/agent-installer-utils
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

Avoid copying full build context into the builder stage.

Line 3 uses COPY . ., which conflicts with the policy and increases accidental secret/context exposure risk.

Proposed fix
-COPY . .
+COPY go.mod go.sum ./
+COPY hack/ ./hack/
+COPY tools/ ./tools/
+COPY pkg/ ./pkg/
+COPY Makefile ./

As per coding guidelines, “COPY specific files, not entire context” and “No secrets in ENV, ARG, or COPY”.

🤖 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 `@images/Dockerfile.ocp` at line 3, The Dockerfile currently uses a broad COPY
. . which pulls the entire build context into the builder stage; replace that
with explicit, minimal COPY instructions that only copy required build inputs
(e.g., COPY package.json package-lock.json ./ and COPY src/ ./ or other exact
files/directories needed) and ensure a .dockerignore excludes secrets and
unnecessary files; update the builder stage in this Dockerfile to reference
those specific COPY targets instead of the global "COPY . ." and remove any
secrets from ENV/ARG entries if present.

Source: Coding guidelines

RUN dnf install -y gcc nmstate-devel nmstate-libs && dnf clean all
RUN ./hack/build.sh

FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
FROM registry.ci.openshift.org/ocp/5.0:base-rhel9
RUN dnf install -y nmstate-libs && dnf clean all
COPY --from=builder /go/src/github.com/openshift/agent-installer-utils/bin/agent-tui /usr/bin/agent-tui
LABEL io.openshift.release.operator=true