Skip to content

refactor: Consolidate CA trust setup into import-additional-cas#2991

Draft
davdhacs wants to merge 11 commits intomasterfrom
refactor-ca-trust-scripts
Draft

refactor: Consolidate CA trust setup into import-additional-cas#2991
davdhacs wants to merge 11 commits intomasterfrom
refactor-ca-trust-scripts

Conversation

@davdhacs
Copy link
Contributor

Description

Consolidate the CA trust setup to align with how stackrox/stackrox handles it (see stackrox/stackrox#19454).

The scanner had a separate trust-root-ca script that copied the StackRox root CA and called update-ca-trust a second time. The stackrox main/sensor images don't have this — they handle everything in a single import-additional-cas script with one update-ca-trust call.

Changes

  • Add copy_single() function to import-additional-cas for the StackRox root CA at /run/secrets/stackrox.io/certs/ca.pem
  • Remove trust-root-ca script and its references in entrypoint.sh and create-bundle.sh
  • update-ca-trust extract --output is now called once instead of twice

Benefits

  • Eliminates a redundant update-ca-trust invocation (avoids the directory-hash permission issue on the second call)
  • Aligns scanner with the stackrox repo's CA trust pattern
  • Simpler entrypoint flow

Checklist

  • Investigated and inspected CI test results

Testing Performed

CI (especially slim-e2e-tests and e2e-tests) will validate that the scanner starts correctly with the consolidated CA trust setup.

davdhacs and others added 10 commits February 18, 2026 14:01
Migrate all scanner base images from UBI8/RHEL8 to UBI9/RHEL9:

Konflux base images:
- Builder: openshift-golang-builder:rhel_9_golang_1.25
- Scanner runtime: ubi9-minimal
- Scanner DB: rhel9/postgresql-15

Non-Konflux base images:
- Scanner: ubi9-minimal
- Scanner DB: ubi9 / ubi9-minimal
- Vulnerabilities: ubi9-minimal

Other updates:
- Tekton CPE labels: el8 -> el9
- rpms.lock.yaml: xz updated to RHEL 9 version (5.2.5-8.el9_0)
- rpms.rhel.repo: RHEL 8 repos -> RHEL 9 repos
- PostgreSQL download script: pg_rhel_major=9
- Image name labels: rhel8 -> rhel9
- microdnf install -y xz (explicit -y for UBI9 compatibility)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In UBI9, update-ca-trust fails when running as an unprivileged user
(nobody:nobody) because it attempts to write to system-wide paths.
Use the -o flag to specify a user-writable output directory.

Also switch restore-all-dir-contents to use --no-clobber to avoid
overwriting CA trust files that were already updated at runtime.

See: https://bugzilla.redhat.com/show_bug.cgi?id=2241240

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…migration

# Conflicts:
#	image/db/rhel/konflux.Dockerfile
…migration

# Conflicts:
#	image/db/rhel/konflux.Dockerfile
Align the scanner entrypoint scripts and Dockerfiles with the proven
CA trust setup from stackrox/stackrox#19454:

- save-dir-contents: Only save /etc/pki/ca-trust/source (not the full
  /etc/pki/ca-trust or /etc/ssl). The extracted dir is regenerated at
  runtime by update-ca-trust.
- Remove /etc/ssl from chown and save-dir-contents (not needed).
- import-additional-cas: Add logging, use --output flag with detailed
  comment explaining why it's needed (BZ#2241240).
- trust-root-ca: Same --output flag and comment.
- restore-all-dir-contents: Add comment explaining --no-clobber.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@davdhacs davdhacs requested review from a team and rhacs-bot as code owners March 25, 2026 23:16
@rhacs-bot rhacs-bot requested a review from a team March 25, 2026 23:17
@openshift-ci
Copy link

openshift-ci bot commented Mar 26, 2026

@davdhacs: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-tests 0a688a4 link false /test e2e-tests

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@davdhacs davdhacs force-pushed the refactor-ca-trust-scripts branch from 0a688a4 to 17e5bdb Compare March 26, 2026 00:39

update-ca-trust extract
# Copy the StackRox root CA if available (mounted by the operator).
copy_existing /run/secrets/stackrox.io/certs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mclasmeier what do you think about moving scanner's "root ca" copy into here to more-closely match the main/sensor setup?

Choose a reason for hiding this comment

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

You mean, as it is currently being done in this PR here, right?

Seems reasonable to me. Of course we shouldn't be over-engineering this, but I have been wondering if it would be a a good idea to generalize copy_existing() slightly, as in:

if $1 is a directory {
  current behaviour of this function
} else if $1 is a file {
  // Expect $1 to be a directly referenced CA pem file
  // case for the stackrox CA pem
} else {
  warn
}

This way we would consolidate the copying in a single function and could just invoke it with different arguments.

WDYT? Just an idea, definitely not a must from my side.

@davdhacs davdhacs marked this pull request as draft March 26, 2026 00:42
Merge trust-root-ca into import-additional-cas to align with how
stackrox/stackrox handles CA trust (single script, single
update-ca-trust call). This eliminates a redundant update-ca-trust
invocation and simplifies the entrypoint.

Changes:
- Add copy_single() to import-additional-cas for the StackRox root CA
  at /run/secrets/stackrox.io/certs/ca.pem
- Remove trust-root-ca script and its references in entrypoint.sh
  and create-bundle.sh
- update-ca-trust extract --output is now called once instead of twice

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
echo "Copying StackRox root CA from '$CA_PATH'"
cp -v -L "$CA_PATH" /etc/pki/ca-trust/source/anchors/
else
echo "No StackRox root CA found at $CA_PATH"

Choose a reason for hiding this comment

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

Is this an expected situation? Wondering if we should do something like

echo >&2 "WARNING: No StackRox root CA found at '$CA_PATH'"

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants