Skip to content

fix: rewrite firmware collection to use veritas container approach#94

Merged
butler54 merged 7 commits into
validatedpatterns:mainfrom
butler54:fix/veritas-container-approach
Jun 2, 2026
Merged

fix: rewrite firmware collection to use veritas container approach#94
butler54 merged 7 commits into
validatedpatterns:mainfrom
butler54:fix/veritas-container-approach

Conversation

@butler54
Copy link
Copy Markdown
Collaborator

@butler54 butler54 commented Jun 1, 2026

Summary

Cherry-picks the veritas container rewrite from the baremetal-tests-20260529 test branch. These changes were validated on a live bare metal cluster but missed being PR'd to main.

Changes

  • Rewrite scripts/collect-firmware-refvals.sh — replaces the in-cluster kata pod approach with a local podman container approach using quay.io/openshift_sandboxed_containers/coco-tools:1.12
  • Add label-based exclusion for firmware collection pods in Kyverno initdata policy

Why

The old script required a running confidential container (kata-cc pod) to collect firmware measurements from inside the TEE. The new approach computes reference values offline from OCP release artifacts via the veritas tool in a container — no cluster pods needed.

Old (main) New (this PR)
Requires running TEE Yes — launches kata-cc pod No — runs locally via podman
Tool pip install veritas-collectd inside pod veritas CLI in coco-tools container
Dependencies oc, jq, cluster access podman, yq, jq, pull secret
Approach Measures running VM Computes from OCP release artifacts

Testing

Validated on bare metal cluster (OCP 4.20.18, Intel TDX) — firmware values collected via this script were loaded to Vault and used for successful attestation (configuration:2, hardware:2, executables:4).

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

butler54 and others added 3 commits June 1, 2026 22:45
Add exclude block to inject-coco-initdata Kyverno policy to skip
pods with label coco.io/skip-initdata: "true".

Update firmware collection script to add this label to the pod,
preventing Kyverno from trying to inject init_data (which would
fail since the pod doesn't have coco.io/initdata-configmap annotation).

The firmware collection pod doesn't need init_data injection because
it only collects measurements from the TEE device - it doesn't attest
to KBS or request secrets.

Fixes error: mutation policy inject-coco-initdata error: failed to
evaluate preconditions: failed to substitute variables in condition key

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Complete rewrite based on Red Hat documentation and veritas usage:

- Runs veritas via podman container (quay.io/openshift_sandboxed_containers/coco-tools:1.12)
- No cluster pods needed - computes firmware values locally from OCP release artifacts
- Auto-detects OCP version from cluster or accepts --ocp-version flag
- Extracts reference-values.json from veritas ConfigMap output
- Saves to ~/.coco-pattern/firmware-reference-values.json
- Uses --hw-xfam-allow x87,sse,avx to prevent attestation failures

Previous approach was fundamentally wrong:
- Tried to run veritas inside a kata pod on the cluster
- Tried to "collect" from /dev/tdx_guest (doesn't work that way)
- Veritas doesn't collect from running hardware - it computes expected
  values from OCP release artifacts (kata RPMs, edk2 firmware, etc.)

Now follows the documented approach:
https://docs.redhat.com/en/documentation/openshift_sandboxed_containers/1.12

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Veritas outputs firmware reference values as a JSON array:
[{"name": "mr_td", "value": [...]}, ...]

But the trustee-chart RVPS ConfigurationPolicy template expects
an object format:
{"mr_td": [...], "rtmr_1": [...], ...}

Transform the veritas output using jq:
  [.[] | {(.name): .value}] | add

This fixes the RVPS policy error:
  can't evaluate field mr_td in type []interface {}

Also added jq to prerequisites check.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@butler54 butler54 requested a review from a team June 1, 2026 14:45
@dmc5179
Copy link
Copy Markdown

dmc5179 commented Jun 1, 2026

Do we need to add the "-r" option to the initial yq command? I'm running this on a Fedora 43 machine with yq 3.4.3 and I get

yq '.data["reference-values.json"]' /tmp/tmp.aWF0Y4PiOw/rvps-reference-values.yaml | jq '[.[] | {(.name): .value}] | add'
jq: error (at <stdin>:1): Cannot iterate over string ("[\n  {\n  ...)

But if I add the "-r" I proper output.

butler54 and others added 2 commits June 2, 2026 09:07
yq v3 (kislyuk/yq) outputs JSON strings with quotes by default,
so the embedded JSON in the YAML ConfigMap stays quoted and jq
receives a string instead of an array. Adding -r outputs the raw
string, which both yq v3 and v4 handle correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@butler54
Copy link
Copy Markdown
Collaborator Author

butler54 commented Jun 2, 2026

Good catch — this is a yq v3 vs v4 compatibility issue. yq v3 (kislyuk/yq) outputs JSON strings with quotes by default, so the embedded JSON stays quoted and jq receives a string instead of an array. yq v4 (mikefarah/yq) outputs raw scalars by default so it worked on macOS.

Fixed in ea4e977 — added -r flag to the yq command, which works correctly on both versions.

butler54 and others added 2 commits June 2, 2026 09:58
Generalize collect-firmware-refvals.sh to support both platforms via
--platform flag (baremetal default, azure optional). This replaces
get-pcr.sh for Azure deployments — veritas pulls the same dm-verity
image, verifies its signature via cosign, and extracts PCR values.

Azure: outputs to ~/.coco-pattern/measurements.json (pcrStash secret)
Baremetal: outputs to ~/.coco-pattern/firmware-reference-values.json

Also adds yq -r fix for v3/v4 cross-compatibility and a new
'make collect-azure-refvals' Makefile target.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace get-pcr.sh call with collect-firmware-refvals.sh --platform azure
in wrapper.sh. Add missing reference value collection step to
wrapper-multicluster.sh (was never collecting PCR values for Vault).
Update RHDP README with prerequisites, env vars, and all deployment modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@butler54 butler54 merged commit f12a4a0 into validatedpatterns:main Jun 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants