Skip to content

ART-21345: Expand build-time EC/ITS verification to layered products#3112

Draft
ashwindasr wants to merge 2 commits into
openshift-eng:mainfrom
ashwindasr:lp-build-time-its
Draft

ART-21345: Expand build-time EC/ITS verification to layered products#3112
ashwindasr wants to merge 2 commits into
openshift-eng:mainfrom
ashwindasr:lp-build-time-its

Conversation

@ashwindasr

@ashwindasr ashwindasr commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Remove the is_ocp_group guard that restricted enterprise contract verification
and SLSA attestation validation to OCP-only groups. EC now runs for any product
with a configured policy (OADP, MTC, Logging, MTA, OCP). SLSA validation now
runs for all non-OKD variants.

Changes

  • doozer/doozerlib/constants.py: Add PRODUCT_EC_POLICY_MAP, PRODUCT_TEST_EC_POLICY_MAP,
    and PRODUCT_PREGA_EC_POLICY_MAP for product-to-policy mapping
  • doozer/doozerlib/backend/konflux_image_builder.py: Replace is_ocp_group check with
    policy-availability check (ec_policy_configuration is not None); expand SLSA validation
    to all non-OKD variants
  • doozer/doozerlib/cli/images_konflux.py: Use product maps for EC policy resolution
    instead of hardcoded OCP constants
  • pyartcd/pyartcd/pipelines/build_layered_products.py: Add --skip-ec-verify flag

Depends on

  • konflux-release-data MR to create EC policies for LP tenants (art-oadp-tenant,
    art-mtc-tenant, art-logging-tenant, art-mta-tenant)

Test plan

  • Unit tests pass (make unit)
  • Validate with a test OADP build (e.g. --skip-ec-verify to start)
  • Enable EC for one product first, confirm pass/fail behavior
  • Roll out to remaining products

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Added a --skip-ec-verify option for layered product builds to bypass Enterprise Contract verification when needed.
    • Enterprise Contract policy selection is now driven by product-specific mappings, including test and PREGA variants.
  • Bug Fixes

    • SLSA attestation/signature validation is now determined by build variant rather than group naming.
    • Enterprise Contract verification now reliably skips when no policy configuration is provided, with updated skip behavior.
  • Tests

    • Expanded/adjusted coverage for variant-aware validation and “no policy configured” Enterprise Contract skipping.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 29, 2026
@openshift-ci

openshift-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci

openshift-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ashwindasr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

EC policies are selected by product and may be unset. Konflux verification gates now use BuildVariant.OKD and policy availability instead of group naming. The layered-products pipeline adds a --skip-ec-verify option, with tests updated for the new behavior.

Changes

EC verification controls

Layer / File(s) Summary
Product policy selection
doozer/doozerlib/constants.py, doozer/doozerlib/cli/images_konflux.py, doozer/doozerlib/backend/konflux_image_builder.py
Adds product-based EC and PREGA policy maps and passes optional policy values into image builds.
Variant and policy verification gates
doozer/doozerlib/backend/konflux_image_builder.py, doozer/tests/backend/test_konflux_ec_verification.py, doozer/tests/backend/test_konflux_image_builder.py
Uses non-OKD variants for attestation validation and requires configured EC policy for EC verification; tests cover OKD and unset-policy cases.

Layered-product EC skip wiring

Layer / File(s) Summary
Layered-product EC skip option
pyartcd/pyartcd/pipelines/build_layered_products.py
Adds the --skip-ec-verify option and forwards it to the Doozer build command.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant KonfluxBuildCli
  participant KonfluxImageBuilder
  participant EnterpriseContract
  KonfluxBuildCli->>KonfluxImageBuilder: pass product-selected EC policy
  KonfluxImageBuilder->>KonfluxImageBuilder: evaluate build variant and policy
  KonfluxImageBuilder->>EnterpriseContract: verify configured non-OKD build
Loading

Possibly related PRs

Suggested reviewers: locriandev, fgallott, lgarciaaco

🚥 Pre-merge checks | ✅ 9 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Ai-Attribution ⚠️ Warning AI use is disclosed ('Made with Cursor'), but the commit uses Co-Authored-By: Cursor instead of required Assisted-by/Generated-by trailers. Replace AI-related Co-Authored-By trailers with Assisted-by or Generated-by trailers on the affected commit(s).
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main theme: expanding build-time EC/ITS verification to layered products.
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.
No-Weak-Crypto ✅ Passed Reviewed the PR files; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or insecure secret comparisons were introduced.
Container-Privileges ✅ Passed HEAD changes only CLI/constants code; no container/K8s manifests or privilege flags (privileged, hostPID, hostNetwork, hostIPC, allowPrivilegeEscalation, SYS_ADMIN) are present.
No-Sensitive-Data-In-Logs ✅ Passed The new/updated logs only mention image keys, group names, and skip reasons; no secrets, PII, tokens, or hostnames are logged.
No-Hardcoded-Secrets ✅ Passed Scanned all touched files; changes only add policy names, URLs, and a skip flag, with no API keys, tokens, passwords, private keys, or embedded-credential strings.
No-Injection-Vectors ✅ Passed No listed injection sinks were added; the changes use arg-list exectools calls and yaml.safe_load, with no eval/exec/os.system/pickle.loads/dangerouslySetInnerHTML.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@ashwindasr ashwindasr changed the title Expand build-time EC/ITS verification to layered products ART-21345: Expand build-time EC/ITS verification to layered products Jun 29, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 29, 2026

Copy link
Copy Markdown

@ashwindasr: This pull request references ART-21345 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Remove the is_ocp_group guard that restricted enterprise contract verification
and SLSA attestation validation to OCP-only groups. EC now runs for any product
with a configured policy (OADP, MTC, Logging, MTA, OCP). SLSA validation now
runs for all non-OKD variants.

Changes

  • doozer/doozerlib/constants.py: Add PRODUCT_EC_POLICY_MAP, PRODUCT_TEST_EC_POLICY_MAP,
    and PRODUCT_PREGA_EC_POLICY_MAP for product-to-policy mapping
  • doozer/doozerlib/backend/konflux_image_builder.py: Replace is_ocp_group check with
    policy-availability check (ec_policy_configuration is not None); expand SLSA validation
    to all non-OKD variants
  • doozer/doozerlib/cli/images_konflux.py: Use product maps for EC policy resolution
    instead of hardcoded OCP constants
  • pyartcd/pyartcd/pipelines/build_layered_products.py: Add --skip-ec-verify flag

Depends on

  • konflux-release-data MR to create EC policies for LP tenants (art-oadp-tenant,
    art-mtc-tenant, art-logging-tenant, art-mta-tenant)

Test plan

  • Unit tests pass (make unit)
  • Validate with a test OADP build (e.g. --skip-ec-verify to start)
  • Enable EC for one product first, confirm pass/fail behavior
  • Roll out to remaining products

Made with Cursor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 29, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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 `@doozer/doozerlib/cli/images_konflux.py`:
- Around line 309-315: The `images_konflux` policy selection regresses `test`
assemblies to the non-test PREGA EC policy. Update the `runtime.assembly ==
"test"` branch in the policy lookup logic to derive `prega_ec_policy` from a
test-specific mapping or constant, using a unique symbol such as
`PRODUCT_TEST_PREGA_EC_POLICY_MAP` alongside `PRODUCT_TEST_EC_POLICY_MAP`, so
`test` builds keep the test PREGA value instead of falling back to
`PRODUCT_PREGA_EC_POLICY_MAP`.
🪄 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: Repository: openshift-eng/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bb3b33ea-fb88-46f9-a083-26a9aea4a8da

📥 Commits

Reviewing files that changed from the base of the PR and between 85f57db and b89a9df.

📒 Files selected for processing (6)
  • doozer/doozerlib/backend/konflux_image_builder.py
  • doozer/doozerlib/cli/images_konflux.py
  • doozer/doozerlib/constants.py
  • doozer/tests/backend/test_konflux_ec_verification.py
  • doozer/tests/backend/test_konflux_image_builder.py
  • pyartcd/pyartcd/pipelines/build_layered_products.py

Comment thread doozer/doozerlib/cli/images_konflux.py

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
doozer/doozerlib/backend/konflux_image_builder.py (1)

307-315: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Gate EC on the selected lifecycle policy

should_run_ec only checks ec_policy_configuration, but this block can later pick prega_ec_policy_configuration for pre-release builds. If that pre-GA policy is unset, EC still runs with ec_policy=None. Select the policy before this gate and require the chosen value to be non-None; add a regression test for the pre-release/no-preGA-policy case.

🤖 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 `@doozer/doozerlib/backend/konflux_image_builder.py` around lines 307 - 315,
Update the logic around should_run_ec to select the lifecycle-appropriate EC
policy first, using the pre-release policy for pre-release builds and the
standard policy otherwise. Gate should_run_ec on the selected policy being
non-None, then pass that same selected policy to the later EC invocation. Add a
regression test covering a pre-release build with no pre-GA policy, asserting EC
does not run.
🧹 Nitpick comments (2)
doozer/tests/backend/test_konflux_image_builder.py (1)

123-136: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the new non-OpenShift, non-OKD path.

The production change replaces the openshift- group-name check with variant-based gating. This test only covers OKD skipping, while the existing positive test uses an OpenShift group; a regression to the old group check would therefore still pass. Add a case using a product group such as OADP with a non-OKD variant and assert SLSA validation is called.

🤖 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 `@doozer/tests/backend/test_konflux_image_builder.py` around lines 123 - 136,
The test coverage in test_build_skips_slsa_validation_for_okd_variant is missing
the non-OpenShift, non-OKD path. Add a test case using a product group such as
OADP with a non-OKD BuildVariant, and assert that SLSA validation is invoked,
ensuring gating depends on the variant rather than the group-name prefix.
doozer/doozerlib/backend/konflux_image_builder.py (1)

961-961: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Use zip(..., strict=True) in _resolve_source_package_nvrs. Any length mismatch between the Koji results and requested NVRs should fail fast instead of silently truncating and mis-associating builds.

🤖 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 `@doozer/doozerlib/backend/konflux_image_builder.py` at line 961, Update the
zip call in _resolve_source_package_nvrs to use strict=True, ensuring mismatched
nvrs and build_tasks lengths raise an error instead of silently truncating;
preserve the existing iteration and association behavior when lengths match.

Source: Linters/SAST tools

🤖 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.

Outside diff comments:
In `@doozer/doozerlib/backend/konflux_image_builder.py`:
- Around line 307-315: Update the logic around should_run_ec to select the
lifecycle-appropriate EC policy first, using the pre-release policy for
pre-release builds and the standard policy otherwise. Gate should_run_ec on the
selected policy being non-None, then pass that same selected policy to the later
EC invocation. Add a regression test covering a pre-release build with no pre-GA
policy, asserting EC does not run.

---

Nitpick comments:
In `@doozer/doozerlib/backend/konflux_image_builder.py`:
- Line 961: Update the zip call in _resolve_source_package_nvrs to use
strict=True, ensuring mismatched nvrs and build_tasks lengths raise an error
instead of silently truncating; preserve the existing iteration and association
behavior when lengths match.

In `@doozer/tests/backend/test_konflux_image_builder.py`:
- Around line 123-136: The test coverage in
test_build_skips_slsa_validation_for_okd_variant is missing the non-OpenShift,
non-OKD path. Add a test case using a product group such as OADP with a non-OKD
BuildVariant, and assert that SLSA validation is invoked, ensuring gating
depends on the variant rather than the group-name prefix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift-eng/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cdbaee02-28bd-4326-b776-b683da419407

📥 Commits

Reviewing files that changed from the base of the PR and between b89a9df and 5e9d447.

📒 Files selected for processing (6)
  • doozer/doozerlib/backend/konflux_image_builder.py
  • doozer/doozerlib/cli/images_konflux.py
  • doozer/doozerlib/constants.py
  • doozer/tests/backend/test_konflux_ec_verification.py
  • doozer/tests/backend/test_konflux_image_builder.py
  • pyartcd/pyartcd/pipelines/build_layered_products.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • doozer/tests/backend/test_konflux_ec_verification.py
  • pyartcd/pyartcd/pipelines/build_layered_products.py
  • doozer/doozerlib/cli/images_konflux.py
  • doozer/doozerlib/constants.py

Remove the is_ocp_group guard that restricted enterprise contract
verification and SLSA attestation validation to OCP-only groups.
EC now runs for any product with a configured policy (OADP, MTC,
Logging, MTA, OCP). SLSA validation now runs for all non-OKD variants.

- Add PRODUCT_EC_POLICY_MAP and PRODUCT_TEST_EC_POLICY_MAP to constants
- Replace hardcoded OCP policy selection with product-aware lookup
- Add --skip-ec-verify flag to build-layered-products pipeline
- Update tests to reflect new policy-availability gating

Co-authored-by: Cursor <cursoragent@cursor.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
PRODUCT_PREGA_EC_POLICY_MAP only had the prod PREGA policy for ocp, so
test-assembly builds in the pre-release lifecycle phase would pick the
prod PREGA policy instead of the test one. Add
PRODUCT_TEST_PREGA_EC_POLICY_MAP and use it in the test-assembly branch.

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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 `@doozer/doozerlib/backend/konflux_image_builder.py`:
- Around line 307-310: Update the EC verification flow around the should_run_ec
predicate to resolve the phase-specific ec_policy first, selecting the PREGA
policy for pre-release builds and the standard policy otherwise. Gate
should_run_ec on that resolved policy being present, and reuse the same
ec_policy value in the skip log and verification call. Apply the equivalent
change to the second affected flow.
🪄 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: Repository: openshift-eng/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1e3b9587-5544-45b2-9a6b-5ae7ec73039a

📥 Commits

Reviewing files that changed from the base of the PR and between 4bb8936 and 9bc1022.

📒 Files selected for processing (6)
  • doozer/doozerlib/backend/konflux_image_builder.py
  • doozer/doozerlib/cli/images_konflux.py
  • doozer/doozerlib/constants.py
  • doozer/tests/backend/test_konflux_ec_verification.py
  • doozer/tests/backend/test_konflux_image_builder.py
  • pyartcd/pyartcd/pipelines/build_layered_products.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • doozer/tests/backend/test_konflux_ec_verification.py
  • pyartcd/pyartcd/pipelines/build_layered_products.py
  • doozer/tests/backend/test_konflux_image_builder.py
  • doozer/doozerlib/cli/images_konflux.py
  • doozer/doozerlib/constants.py

Comment on lines 307 to +310
should_run_ec = (
outcome is KonfluxBuildOutcome.SUCCESS
and metadata.runtime.variant is not BuildVariant.OKD
and is_ocp_group
and self._config.ec_policy_configuration is not None

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Gate on the phase-specific EC policy.

The predicate checks only ec_policy_configuration, but Lines 327-329 select the PREGA policy for pre-release builds. This causes both incorrect outcomes: a standard-only configuration can call EC verification with ec_policy=None, while a PREGA-only configuration is skipped despite having a usable policy. Resolve the policy before gating and use that same value for the skip log.

Proposed direction
-                    and self._config.ec_policy_configuration is not None
+                    and ec_policy is not None
...
-                    elif self._config.ec_policy_configuration is None:
+                    elif ec_policy is None:

Ensure ec_policy is resolved from the lifecycle phase before evaluating should_run_ec.

Also applies to: 361-363

🤖 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 `@doozer/doozerlib/backend/konflux_image_builder.py` around lines 307 - 310,
Update the EC verification flow around the should_run_ec predicate to resolve
the phase-specific ec_policy first, selecting the PREGA policy for pre-release
builds and the standard policy otherwise. Gate should_run_ec on that resolved
policy being present, and reuse the same ec_policy value in the skip log and
verification call. Apply the equivalent change to the second affected flow.

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

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants