Skip to content

Pin the policy bundle by modifying the ECP in tekton tasks#3268

Open
simonbaird wants to merge 3 commits into
conforma:mainfrom
simonbaird:policy-with-bundle-pin
Open

Pin the policy bundle by modifying the ECP in tekton tasks#3268
simonbaird wants to merge 3 commits into
conforma:mainfrom
simonbaird:policy-with-bundle-pin

Conversation

@simonbaird
Copy link
Copy Markdown
Member

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 1881dc13-125d-417f-98bf-515b81b96655

📥 Commits

Reviewing files that changed from the base of the PR and between ecd2dde and 48069b1.

⛔ Files ignored due to path filters (1)
  • features/__snapshots__/task_validate_image.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • Dockerfile
  • Dockerfile.dist
  • acceptance/kubernetes/kind/acceptance.Dockerfile
  • docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc
  • docs/modules/ROOT/pages/verify-enterprise-contract.adoc
  • features/task_validate_image.feature
  • hack/pin-konflux-policy-bundle.sh
  • hack/update-policy-digest-in-tasks.sh
  • tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml
  • tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml
✅ Files skipped from review due to trivial changes (3)
  • docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc
  • acceptance/kubernetes/kind/acceptance.Dockerfile
  • docs/modules/ROOT/pages/verify-enterprise-contract.adoc
🚧 Files skipped from review as they are similar to previous changes (7)
  • Dockerfile
  • tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml
  • hack/pin-konflux-policy-bundle.sh
  • hack/update-policy-digest-in-tasks.sh
  • tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml
  • features/task_validate_image.feature
  • Dockerfile.dist

📝 Walkthrough

Walkthrough

Adds optional POLICY_BUNDLE_DIGEST support to tasks that validate Enterprise Contract/Konflux policies, a helper script to pin OCI release-policy tags to digests, updates task steps to run the pinning script and prefer the generated pinned policy file, updates CI/runtime images to include the helper, and documents the new parameter.

Changes

Policy Bundle Digest Pinning

Layer / File(s) Summary
Core Script
hack/pin-konflux-policy-bundle.sh
New bash script: resolves POLICY_CONFIGURATION (inline JSON, file, or Kubernetes enterprisecontractpolicy resource), normalizes POLICY_BUNDLE_DIGEST, replaces oci::quay.io/conforma/release-policy:konflux with oci::quay.io/conforma/release-policy@<digest> if present, writes modified spec to ${HOME}/policy-with-pinned-bundle.yaml.
Digest Management Utility
hack/update-policy-digest-in-tasks.sh
Now runs with strict bash flags; computes image manifest digest via skopeo inspect --raw, extracts prior default digest from task YAMLs, compares old vs new, and sed -i replaces the digest across task YAMLs, docs, feature/snapshot files (skips missing files with warnings).
Task Parameter & Steps
tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml, tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml
Added POLICY_BUNDLE_DIGEST task parameter (default documented digest); inserted pin-policy-bundle step that runs pin-konflux-policy-bundle.sh (env: POLICY_CONFIGURATION, POLICY_BUNDLE_DIGEST); updated validate step to use ${HOMEDIR}/policy-with-pinned-bundle.yaml / $(params.HOMEDIR)/policy-with-pinned-bundle.yaml when present.
Container Images
Dockerfile, Dockerfile.dist, acceptance/kubernetes/kind/acceptance.Dockerfile
Runtime image stages now copy hack/pin-konflux-policy-bundle.sh into /usr/local/bin/ (alongside existing helper scripts).
Documentation
docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc, docs/modules/ROOT/pages/verify-enterprise-contract.adoc
Added POLICY_BUNDLE_DIGEST parameter docs describing format, behavior (replaces :konflux with @<digest>), and default digest value.
Tests / Features
features/task_validate_image.feature
Extended snapshot assertions in "Golden container image" and "Pin policy bundle digest" scenarios to include pin-policy-bundle step logs and show-config/report/task-results snapshots.
sequenceDiagram
    autonumber
    participant Tekton as Tekton Task
    participant Image as Container (runtime)
    participant PinScript as pin-konflux-policy-bundle.sh
    participant K8s as Kubernetes (kubectl)
    participant Validator as validate step
    Tekton->>Image: start task (includes pin-policy-bundle step)
    Image->>PinScript: execute with POLICY_CONFIGURATION & POLICY_BUNDLE_DIGEST
    PinScript->>K8s: (optional) kubectl get enterprisecontractpolicy -> .spec
    PinScript->>PinScript: sed replace :konflux -> `@sha256`:<...>
    PinScript->>Image: write ${HOME}/policy-with-pinned-bundle.yaml
    Image->>Validator: run validate step
    Validator->>Image: prefer pinned file if exists, else original POLICY_CONFIGURATION
    Validator->>Tekton: emit results & logs
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: pinning the policy bundle by modifying the ECP in Tekton tasks, which aligns with the actual implementation across multiple files.
Description check ✅ Passed The description references the Jira issue (EC-1790) which is related to the changeset, though it is minimal and lacks detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
acceptance 55.59% <ø> (ø)
generative 17.82% <ø> (ø)
integration 26.56% <ø> (ø)
unit 69.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread hack/pin-konflux-policy-bundle.sh
simonbaird added a commit to simonbaird/konflux-build-definitions that referenced this pull request May 1, 2026
It's a long story, but we want to reduce the number of moving parts
related to updating Conforma in Red Hat Konflux. Being able to pin
the policy bundle when building the Conforma tasks means we can
reduce breakages related to old incompatible versions of the cli
being used with the latest policy bundle.

See also the related PR at conforma/cli#3268

Ref: https://redhat.atlassian.net/browse/EC-1790
simonbaird added a commit to simonbaird/konflux-build-definitions that referenced this pull request May 1, 2026
It's a long story, but we want to reduce the number of moving parts
related to updating Conforma in Red Hat Konflux. Being able to pin
the policy bundle when building the Conforma tasks means we can
reduce breakages related to old incompatible versions of the cli
being used with the latest policy bundle.

See also the related PR at conforma/cli#3268

Ref: https://redhat.atlassian.net/browse/EC-1790
simonbaird added a commit to simonbaird/konflux-build-definitions that referenced this pull request May 1, 2026
It's a long story, but we want to reduce the number of moving parts
related to updating Conforma in Red Hat Konflux. Being able to pin
the policy bundle when building the Conforma tasks means we can
reduce breakages related to old incompatible versions of the cli
being used with the latest policy bundle.

See also the related PR at conforma/cli#3268

Ref: https://redhat.atlassian.net/browse/EC-1790
simonbaird added a commit to simonbaird/konflux-build-definitions that referenced this pull request May 1, 2026
It's a long story, but we want to reduce the number of moving parts
related to updating Conforma in Red Hat Konflux. Being able to pin
the policy bundle when building the Conforma tasks means we can
reduce breakages related to old incompatible versions of the cli
being used with the latest policy bundle.

See also the related PR at conforma/cli#3268

Ref: https://redhat.atlassian.net/browse/EC-1790
simonbaird added a commit to simonbaird/konflux-build-definitions that referenced this pull request May 6, 2026
It's a long story, but we want to reduce the number of moving parts
related to updating Conforma in Red Hat Konflux. Being able to pin
the policy bundle when building the Conforma tasks means we can
reduce breakages related to old incompatible versions of the cli
being used with the latest policy bundle.

See also the related PR at conforma/cli#3268

Ref: https://redhat.atlassian.net/browse/EC-1790
Co-authored-by: Claude Code <noreply@anthropic.com>
@simonbaird simonbaird force-pushed the policy-with-bundle-pin branch from d1cbab1 to e75a8c6 Compare May 7, 2026 20:01
@github-actions github-actions Bot added size: XL and removed size: L labels May 7, 2026
@simonbaird
Copy link
Copy Markdown
Member Author

/retest

@simonbaird simonbaird force-pushed the policy-with-bundle-pin branch from e75a8c6 to ecd2dde Compare May 8, 2026 15:10
@simonbaird simonbaird marked this pull request as ready for review May 8, 2026 15:24
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with 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.

Inline comments:
In `@hack/pin-konflux-policy-bundle.sh`:
- Around line 27-34: The check for an empty digest fails under set -o nounset
because expanding ${POLICY_BUNDLE_DIGEST} errors if the variable is unset;
update the test that reads [[ -z "${POLICY_BUNDLE_DIGEST}" ]] to use parameter
expansion with a default (e.g. ${POLICY_BUNDLE_DIGEST:-}) so the -z check can
run safely even when POLICY_BUNDLE_DIGEST is unset, leaving the rest of the
no-op exit logic unchanged.
- Around line 53-65: The parsing treats any string with "/" as a k8s
namespace/name; change the detection around POLICY_CONFIGURATION (the if [[
"${POLICY_CONFIGURATION}" == *"/"* ]] branch that sets NAMESPACE and NAME and
calls kubectl get enterprisecontractpolicy) so it only treats true k8s ECP refs
as namespace/name—e.g. require exactly one slash and reject inputs that look
like URLs (contain "://" or "//" or domain dots) or otherwise match git-style
paths; if the check fails, skip the kubectl path and continue with the non-k8s
handling that avoids pinning into WORKING_POLICY. Ensure references to
POLICY_CONFIGURATION, NAMESPACE, NAME, and WORKING_POLICY remain but tighten the
conditional logic around the kubectl get calls.

In `@tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml`:
- Around line 345-352: The pin-policy-bundle step currently hard-fails if
pin-konflux-policy-bundle.sh exits non‑zero; update the pin-policy-bundle step
(the container using image quay.io/conforma/cli:latest with envs
POLICY_CONFIGURATION and POLICY_BUNDLE_DIGEST) so the command does not abort the
Task on failure (e.g. run the script under a shell that swallows non‑zero exit
like "sh -c 'pin-konflux-policy-bundle.sh || true'" or modify the script to exit
0 on handled errors) so the later validate/fallback logic can execute and select
the original policy configuration when pinning fails.

In `@tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml`:
- Around line 291-305: The pin step (name: pin-policy-bundle, command:
pin-konflux-policy-bundle.sh) must not stop the Task on failures so the fallback
validate step can run; update that step to be non-blocking by adding Tekton's
continueOnError: true to the step spec (or, if your runtime doesn't support
continueOnError, make the command tolerant to failure e.g. wrap/chain the script
with "|| true") so failures in pin-konflux-policy-bundle.sh do not abort the
Task and the subsequent validate logic still executes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: ed675d0a-c8ea-41db-a0c3-57e0088a8f89

📥 Commits

Reviewing files that changed from the base of the PR and between f678eda and ecd2dde.

⛔ Files ignored due to path filters (1)
  • features/__snapshots__/task_validate_image.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • Dockerfile
  • Dockerfile.dist
  • acceptance/kubernetes/kind/acceptance.Dockerfile
  • docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc
  • docs/modules/ROOT/pages/verify-enterprise-contract.adoc
  • features/task_validate_image.feature
  • hack/pin-konflux-policy-bundle.sh
  • hack/update-policy-digest-in-tasks.sh
  • tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml
  • tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml

Comment thread hack/pin-konflux-policy-bundle.sh
Comment thread hack/pin-konflux-policy-bundle.sh
@simonbaird
Copy link
Copy Markdown
Member Author

I'll do some coderabbit fixes.

@simonbaird simonbaird marked this pull request as draft May 8, 2026 16:12
simonbaird and others added 2 commits May 8, 2026 12:23
Add optional POLICY_BUNDLE_DIGEST parameter to both conforma Tekton
tasks. When provided, the policy configuration is resolved and the
oci::quay.io/conforma/release-policy:konflux tag reference is replaced
with a digest-pinned reference for reproducible policy evaluation.

The reason we want to do this is the same tekton task uses the same
policy always, to avoid unexpected cli/policy incompatibilities.

As mentioned elsewhere, this is quite Red Hat Konflux-specific, and
quite an unpleasant hack, but we're choosing an uncoupled,
easy-to-delete hack over alternative options.

Ref: https://redhat.atlassian.net/browse/EC-1790
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonbaird simonbaird force-pushed the policy-with-bundle-pin branch from ecd2dde to c6c7fb1 Compare May 8, 2026 16:23
I'm imagining running this manually to begin with, but we might want
to automate it have it triggered on a policy bundle push.

Ref: https://redhat.atlassian.net/browse/EC-1790
Co-authored-by: Claude Code <noreply@anthropic.com>
@simonbaird simonbaird force-pushed the policy-with-bundle-pin branch from c6c7fb1 to 48069b1 Compare May 8, 2026 16:44
@simonbaird simonbaird marked this pull request as ready for review May 11, 2026 17:20
@joejstuart
Copy link
Copy Markdown
Contributor

LGTM. Depending on how we deploy, I could possibly see the update-policy-digest-in-tasks.sh script changing, but this is a good first step.

Copy link
Copy Markdown
Contributor

@st3penta st3penta left a comment

Choose a reason for hiding this comment

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

LGTM, imho this is a promising approach

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants