osc-veritas 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Beraldo Leal
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: osc-veritas
3
+ Version: 0.1.2
4
+ Summary: Reference value extraction for CoCo attestation
5
+ Author-email: Beraldo Leal <bleal@redhat.com>
6
+ License-Expression: Apache-2.0
7
+ Requires-Python: >=3.11
8
+ License-File: LICENSE
9
+ Provides-Extra: snp
10
+ Requires-Dist: sev-snp-measure; extra == "snp"
11
+ Dynamic: license-file
@@ -0,0 +1,201 @@
1
+ # veritas
2
+
3
+ > Not the woodworking kind. This one computes attestation truth.
4
+
5
+ Extracts attestation reference values for OpenShift Sandboxed
6
+ Containers from OCP release artifacts and Red Hat registry images.
7
+
8
+ Point it at an OCP version, get the values Trustee needs.
9
+
10
+ For baremetal, veritas resolves the extensions image from the OCP
11
+ release payload and verifies its signature with `oc adm release info
12
+ --verify`. For Azure, artifacts are pulled from the Red Hat registry
13
+ and signature verified via cosign. No cluster access is required.
14
+
15
+ ## Why
16
+
17
+ Trustee needs RVPS reference values to verify confidential workloads.
18
+ These values come from the exact firmware, kernel, and initrd shipped
19
+ in each OCP release. Veritas pulls those artifacts directly from the
20
+ release payload (pinned by digest), computes the hashes, and outputs
21
+ them ready for Trustee.
22
+
23
+ ## Supported platforms
24
+
25
+ | Platform | TEE | Artifact source |
26
+ |---|---|---|
27
+ | Azure | TDX, SNP | osc-dm-verity-image (pre-computed PCRs) |
28
+ | Baremetal | TDX, SNP | kata-containers and edk2-ovmf RPMs from rhel-coreos-extensions |
29
+
30
+ ## Prerequisites
31
+
32
+ - `oc`: resolves and extracts the rhel-coreos-extensions image from the OCP release
33
+ - `skopeo`: queries the registry for image digests
34
+ - `cosign` >= 2.0: verifies Red Hat image signatures (Azure only)
35
+ - `tdx-measure`: computes TDX runtime measurement registers (Baremetal TDX only, `cargo install --git https://github.com/virtee/tdx-measure tdx-measure-cli`)
36
+
37
+ ## Install
38
+
39
+ ```
40
+ # Base install (Azure, Baremetal TDX)
41
+ pip install .
42
+
43
+ # With SNP support (adds sev-snp-measure)
44
+ pip install .[snp]
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ ```
50
+ # Baremetal TDX
51
+ veritas --platform baremetal --tee tdx --ocp-version 4.20.15 \
52
+ --authfile pull-secret.json \
53
+ --initdata initdata.toml
54
+
55
+ # Azure TDX
56
+ veritas --platform azure --tee tdx \
57
+ --authfile pull-secret.json \
58
+ --initdata initdata.toml
59
+ ```
60
+
61
+ Output is written to the current directory by default.
62
+ Use `-o` to specify a different directory.
63
+
64
+ ### BoT version compatibility
65
+
66
+ Veritas generates reference values in the format expected by Red Hat
67
+ build of Trustee (BoT). The format changed in BoT 1.2 (OSC 1.13):
68
+
69
+ ```bash
70
+ # For OSC 1.13+ (BoT 1.2) - default
71
+ veritas --platform baremetal --tee tdx --ocp-version 4.20.15
72
+
73
+ # For OSC 1.12 and earlier (BoT 1.1)
74
+ veritas --platform baremetal --tee tdx --ocp-version 4.20.15 --bot-version 1.1
75
+ ```
76
+
77
+ The format difference is transparent at the API level but incompatible
78
+ between versions. Verify your OSC/BoT version and use the matching
79
+ `--bot-version` flag.
80
+
81
+ > [!NOTE]
82
+ > The defaults match standard kata configurations and OCP artifacts.
83
+ > If your environment uses different settings (VM memory size, kernel
84
+ > command line, CPU features), see the platform docs for additional
85
+ > flags that ensure the RVPS values match your setup.
86
+ > See [Baremetal](BAREMETAL.md) and [Azure](AZURE.md) for
87
+ > platform-specific options and examples.
88
+
89
+ ## Computing all supported versions
90
+
91
+ Different z-stream releases may ship different artifacts, producing
92
+ different hashes. To cover all supported versions in a single RVPS
93
+ ConfigMap, veritas merges them into one value list per key:
94
+
95
+ ```json
96
+ {
97
+ "name": "tdx_pcr09",
98
+ "value": [
99
+ "f831563c60f456009066a9fe...",
100
+ "23ab4e921bc667fbb6703e9f..."
101
+ ]
102
+ }
103
+ ```
104
+
105
+ The attestation policy uses set membership (`in`), so any of the
106
+ listed values will pass verification.
107
+
108
+ `compute-all.py` automates this across all supported z-stream
109
+ versions. It reads a support matrix JSON that defines the minimum
110
+ supported version per platform, queries the registries to discover
111
+ every z-stream from that minimum onward, and runs veritas once per
112
+ platform/tee with all versions merged.
113
+
114
+ ```
115
+ # See which versions would be processed
116
+ python3 scripts/compute-all.py --support-matrix osc-support-1.11.json --dry-run
117
+
118
+ # Run all platforms
119
+ python3 scripts/compute-all.py --support-matrix osc-support-1.11.json --authfile pull-secret.json
120
+
121
+ # Run a single platform
122
+ python3 scripts/compute-all.py --support-matrix osc-support-1.11.json --platform azure --authfile pull-secret.json
123
+
124
+ # Save output to a specific directory
125
+ python3 scripts/compute-all.py --support-matrix osc-support-1.11.json --authfile pull-secret.json -o results/
126
+ ```
127
+
128
+ The support matrix maps platforms to their minimum z-stream versions.
129
+ For baremetal, these are OCP versions. For azure, these are OSC
130
+ operator versions (the dm-verity image is tied to the operator
131
+ release, not OCP). See `osc-support-*.json` for the current matrix.
132
+
133
+ ## Default policy coverage
134
+
135
+ Maps each value checked by the [upstream default Rego policy](https://github.com/confidential-containers/trustee/blob/main/attestation-service/src/token/ear_default_policy_cpu.rego) to what veritas can provide today. Each cell shows the RVPS key name and whether veritas computes it, the policy hardcodes it, or it's still missing.
136
+
137
+ | Policy check | Baremetal TDX (SHA-384) | Baremetal SNP (SHA-384) | Azure TDX (SHA-256) | Azure SNP (SHA-256) |
138
+ |---|---|---|---|---|
139
+ | 💾 Firmware (OVMF) | ✅ mr_td | ~~part of measur.~~ | ✅ mr_td | ~~snp_pcr03 (part of measur.)~~ |
140
+ | 💾 Launch digest | - | ✅ snp_launch_measurement | - | ✅ measurement |
141
+ | 💾 Kernel | ✅ tdvfkernel | ~~part of measur.~~ | - | - |
142
+ | 💾 Kernel cmdline | ✅ tdvfkernelparams | ~~part of measur.~~ | - | - |
143
+ | 💾 Initrd | ~~part of rtmr_2~~ | ~~part of measur.~~ | ✅ tdx_pcr09 | ✅ snp_pcr09 |
144
+ | 💾 Runtime register 1 | ✅ rtmr_1 | - | - | - |
145
+ | 💾 Runtime register 2 | ✅ rtmr_2 | - | - | - |
146
+ | 💾 UKI bundle | - | - | ✅ tdx_pcr11 | ✅ snp_pcr11 |
147
+ | 💾 Credentials | ~~pcr12~~ | - | ~~tdx_pcr12~~ | ~~snp_pcr12~~ |
148
+ | ⚙️ Init data | ~~init_data (mr_config_id)~~ | ~~init_data~~ | ~~tdx_pcr08~~ | ~~snp_pcr08~~ |
149
+ | 📋 TEE type | *"81000000"* | - | *"81000000"* | - |
150
+ | 📋 Vendor ID | *"939a72..."* | - | *"939a72..."* | - |
151
+ | 📋 TCB status | *"UpToDate"* | - | - | - |
152
+ | 📋 Collateral expiry | *"0"* | - | - | - |
153
+ | 📋 Debug policy | *false* | *false* | - | - |
154
+ | 📋 Migration policy | - | *false* | - | - |
155
+ | 🔒 CPU features (xfam) | ✅ xfam (--hw-xfam-allow) | - | ✅ xfam (--hw-xfam-allow) | - |
156
+ | 🔒 TCB version | - | 🔴 reported_tcb_* | - | 🔴 reported_tcb_* |
157
+ | 🔒 SMT policy | - | 🔴 platform_smt_enabled | - | 🔴 smt_enabled |
158
+ | 🔒 TSME | - | 🔴 platform_tsme_enabled | - | 🔴 tsme_enabled |
159
+ | 🔒 Guest ABI | - | 🔴 policy_abi_major/minor | - | 🔴 abi_major/minor |
160
+ | 🔒 Single socket | - | 🔴 policy_single_socket | - | 🔴 single_socket |
161
+ | 🔒 SMT allowed | - | 🔴 policy_smt_allowed | - | 🔴 smt_allowed |
162
+
163
+ ✅ veritas computes (or accepts via CLI)<br>
164
+ 🔴 not yet provided<br>
165
+ ~~strikethrough~~ not individually checked (may be part of a combined value)<br>
166
+ \- does not exist
167
+
168
+ 💾 software: pre-computable from artifacts<br>
169
+ ⚙️ user config<br>
170
+ 📋 policy checks against hardcoded values (no RVPS reference needed)<br>
171
+ 🔒 hardware: platform-specific (see `--hw-*` flags)
172
+
173
+ ### Being removed from upstream policy
174
+
175
+ These checks are being removed from the upstream default Rego policy.
176
+ Veritas does not output them.
177
+
178
+ | Policy check | Reason for removal |
179
+ |---|---|
180
+ | 🔒 SEAM module (mr_seam) | Redundant with tcb_status. TDX module hash is published by [Intel](https://github.com/intel/confidential-computing.tdx.tdx-module/releases) but impractical to discover from the BIOS vendor. |
181
+ | 🔒 TCB SVN (tcb_svn) | Already implicitly checked by the DCAP verifier as part of tcb_status. |
182
+
183
+ ## Disconnected environments
184
+
185
+ See [DISCONNECTED.md](DISCONNECTED.md) for guidance on running veritas
186
+ in air-gapped environments, including registry mirrors and signature
187
+ verification options.
188
+
189
+ ## Known limitations
190
+
191
+ See [Baremetal](BAREMETAL.md) and [Azure](AZURE.md) for
192
+ platform-specific limitations.
193
+
194
+ ## TODO
195
+
196
+ - [ ] CI: validate RVPS keys against policy using OPA (detect missing keys and unused keys)
197
+
198
+ ## License
199
+
200
+ Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE)
201
+ for details.
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "osc-veritas"
7
+ version = "0.1.2"
8
+ description = "Reference value extraction for CoCo attestation"
9
+ authors = [{name = "Beraldo Leal", email = "bleal@redhat.com"}]
10
+ requires-python = ">=3.11"
11
+ license = "Apache-2.0"
12
+
13
+ [project.scripts]
14
+ veritas = "veritas.__main__:main"
15
+
16
+ [project.optional-dependencies]
17
+ snp = ["sev-snp-measure"]
18
+
19
+ [tool.pytest.ini_options]
20
+ addopts = "--tb=line --junitxml=report.xml"
21
+ junit_family = "xunit1"
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: osc-veritas
3
+ Version: 0.1.2
4
+ Summary: Reference value extraction for CoCo attestation
5
+ Author-email: Beraldo Leal <bleal@redhat.com>
6
+ License-Expression: Apache-2.0
7
+ Requires-Python: >=3.11
8
+ License-File: LICENSE
9
+ Provides-Extra: snp
10
+ Requires-Dist: sev-snp-measure; extra == "snp"
11
+ Dynamic: license-file
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/osc_veritas.egg-info/PKG-INFO
5
+ src/osc_veritas.egg-info/SOURCES.txt
6
+ src/osc_veritas.egg-info/dependency_links.txt
7
+ src/osc_veritas.egg-info/entry_points.txt
8
+ src/osc_veritas.egg-info/requires.txt
9
+ src/osc_veritas.egg-info/top_level.txt
10
+ src/veritas/__init__.py
11
+ src/veritas/__main__.py
12
+ src/veritas/container.py
13
+ src/veritas/models.py
14
+ src/veritas/xfam.py
15
+ src/veritas/platforms/__init__.py
16
+ src/veritas/platforms/azure.py
17
+ src/veritas/platforms/baremetal.py
18
+ src/veritas/platforms/base.py
19
+ src/veritas/platforms/utils.py
20
+ src/veritas/vendor/__init__.py
21
+ src/veritas/vendor/td_payload_qemu_hash.py
22
+ src/veritas/vendor/td_shim_tee_info_hash.py
23
+ tests/test_baremetal.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ veritas = veritas.__main__:main
@@ -0,0 +1,3 @@
1
+
2
+ [snp]
3
+ sev-snp-measure
File without changes
@@ -0,0 +1,163 @@
1
+ """Extract CoCo reference values for Trustee RVPS."""
2
+
3
+ import argparse
4
+ import logging
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ from veritas.models import format_trustee
9
+ from veritas.platforms import EXTRACTORS
10
+
11
+ log = logging.getLogger(__name__)
12
+
13
+ RVPS_FILENAME = "rvps-reference-values.yaml"
14
+
15
+
16
+ def main():
17
+ parser = argparse.ArgumentParser(description=__doc__)
18
+ parser.add_argument("--platform", required=True, choices=EXTRACTORS.keys())
19
+ parser.add_argument("--tee", default="tdx", choices=["tdx", "snp"])
20
+ parser.add_argument("--authfile", help="Registry auth file for pulling images")
21
+ parser.add_argument("--ocp-version", action="append", dest="ocp_versions",
22
+ help="OCP version (repeatable, e.g. --ocp-version 4.20.6 --ocp-version 4.20.15)")
23
+ parser.add_argument("--image-tag", action="append", dest="image_tags",
24
+ help="Image tag (azure only, repeatable). Can be a version (e.g. 1.12.1) "
25
+ "or git commit hash (e.g. 062b4c37...). Defaults to latest")
26
+ parser.add_argument("--image-repo",
27
+ help="[Deprecated] Use --mirror-registry instead. "
28
+ "Full image repository override for the azure dm-verity image.")
29
+ parser.add_argument("--kernel-cmdline",
30
+ help="Override kernel command line (baremetal only). "
31
+ "When set, computes a single measurement value instead of "
32
+ "one per CPU count. Default: kata default cmdline with nr_cpus=1..N")
33
+ parser.add_argument("--max-cpu-count", type=int, default=32,
34
+ help="Max nr_cpus to generate cmdline variants for (default: 32, "
35
+ "ignored when --kernel-cmdline is set)")
36
+ parser.add_argument("--mem-size", type=int, default=2048,
37
+ help="VM memory size in MB for tdvfkernel hash (default: 2048, "
38
+ "kata default). Only affects baremetal TDX.")
39
+ parser.add_argument("--kata-rpm",
40
+ help="Path to a local kata-containers RPM. When set, uses this "
41
+ "RPM instead of the one from the OCP release extensions image. "
42
+ "An --ocp-version is still required to resolve the edk2 RPM.")
43
+ parser.add_argument("--gpu", action="store_true",
44
+ help="Generate measurements for GPU pods (uses kata-cc-nvidia-gpu.initrd "
45
+ "and GPU-specific cmdline). When used with --kernel-cmdline, picks the "
46
+ "GPU initrd. Without --kernel-cmdline, auto-generates both GPU and non-GPU.")
47
+ parser.add_argument("--initdata", action="append", dest="initdata_paths",
48
+ help="Path to initdata.toml for hash computation (repeatable)")
49
+
50
+ parser.add_argument("--hw-xfam-allow", action="append", dest="hw_xfam_allow",
51
+ help="XFAM CPU feature enabled for the TD (TDX only, repeatable). "
52
+ "e.g. --hw-xfam-allow x87 --hw-xfam-allow sse --hw-xfam-allow avx")
53
+ disconnected = parser.add_argument_group("Disconnected environments")
54
+ disconnected.add_argument("--mirror-registry",
55
+ help="Registry mirror host to use in place of public registries. "
56
+ "Assumes the mirror preserves the original image path structure, "
57
+ "as produced by oc-mirror. Used for the dm-verity image (azure) "
58
+ "and the OCP release payload and extensions image (baremetal). "
59
+ "Example: my-acr.azurecr.io")
60
+ disconnected.add_argument("--cosign-pub-key",
61
+ help="Path to a local cosign public key PEM file. When set, skips the "
62
+ "download of the Red Hat cosign key from security.access.redhat.com. "
63
+ "Required in disconnected environments.")
64
+ disconnected.add_argument("--skip-tlog", action="store_true",
65
+ help="Skip transparency log (Rekor) verification when verifying "
66
+ "image signatures. Use in disconnected environments where Rekor "
67
+ "is not accessible. The cosign signature is still verified "
68
+ "against the public key.")
69
+ disconnected.add_argument("--rekor-url",
70
+ help="Rekor server URL for signature verification (default: Red Hat Rekor instance)")
71
+ disconnected.add_argument("--rekor-pub-key-url",
72
+ help="Rekor public key URL for signature verification (default: Red Hat TUF server)")
73
+ parser.add_argument("--data-key", default="reference_value",
74
+ help="ConfigMap data key name (default: reference_value)")
75
+ parser.add_argument("--cm-name", default="trusteeconfig-rvps-reference-values",
76
+ help="ConfigMap metadata.name (default: trusteeconfig-rvps-reference-values)")
77
+ parser.add_argument("--bot-version", default="1.2", choices=["1.1", "1.2"],
78
+ help="Red Hat build of Trustee format version (default: 1.2 for OSC 1.13+). "
79
+ "Use 1.1 for OSC 1.12 and earlier")
80
+ parser.add_argument("-o", "--output", default=".",
81
+ help="Output directory (default: current directory)")
82
+ parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output")
83
+ args = parser.parse_args()
84
+
85
+ logging.basicConfig(
86
+ level=logging.DEBUG if args.verbose else logging.INFO,
87
+ format="%(levelname)s: %(message)s",
88
+ )
89
+
90
+ try:
91
+ extractor_cls = EXTRACTORS[args.platform]
92
+ kwargs = {"tee": args.tee, "authfile": args.authfile}
93
+ if args.mirror_registry:
94
+ kwargs["mirror_registry"] = args.mirror_registry
95
+ if args.platform == "baremetal":
96
+ if args.ocp_versions:
97
+ kwargs["ocp_versions"] = args.ocp_versions
98
+ kwargs["kernel_cmdline"] = args.kernel_cmdline
99
+ kwargs["max_cpu_count"] = args.max_cpu_count
100
+ kwargs["mem_size"] = args.mem_size * 1024 * 1024
101
+ kwargs["kata_rpm"] = args.kata_rpm
102
+ kwargs["gpu"] = args.gpu
103
+ else: # azure
104
+ if args.image_tags:
105
+ kwargs["image_tags"] = args.image_tags
106
+ if args.rekor_url:
107
+ kwargs["rekor_url"] = args.rekor_url
108
+ if args.rekor_pub_key_url:
109
+ kwargs["rekor_pub_key_url"] = args.rekor_pub_key_url
110
+ if args.image_repo:
111
+ log.warning("--image-repo is deprecated, use --mirror-registry instead.")
112
+ kwargs["image_repo"] = args.image_repo
113
+ if args.cosign_pub_key:
114
+ kwargs["cosign_pub_key"] = args.cosign_pub_key
115
+ if args.skip_tlog:
116
+ kwargs["skip_tlog"] = args.skip_tlog
117
+ extractor = extractor_cls(**kwargs)
118
+ values = extractor.extract()
119
+ if args.initdata_paths:
120
+ values.append(extractor.compute_initdata(args.initdata_paths))
121
+ if args.hw_xfam_allow:
122
+ if args.tee != "tdx":
123
+ log.warning("--hw-xfam-allow is only relevant for TDX, ignoring")
124
+ else:
125
+ from veritas.models import ReferenceValue
126
+ from veritas.xfam import compute_xfam
127
+ xfam_hex = compute_xfam(args.hw_xfam_allow)
128
+ algo = "sha256" if args.platform == "azure" else "sha384"
129
+ values.append(ReferenceValue(
130
+ name="xfam",
131
+ values=[xfam_hex],
132
+ category="hardware",
133
+ description="Extended features mask (XSAVE CPU features enabled for the TD)",
134
+ algorithm=algo,
135
+ source="--hw-xfam-allow " + " ".join(args.hw_xfam_allow),
136
+ ))
137
+ if args.tee == "tdx" and not args.hw_xfam_allow:
138
+ log.warning(
139
+ "No --hw-xfam-allow provided. The default attestation "
140
+ "policy checks xfam and will FAIL without it. Pass --hw-xfam-allow "
141
+ "with the CPU features enabled for the TD, or customize the policy "
142
+ "to skip the xfam check."
143
+ )
144
+ except RuntimeError as e:
145
+ log.error("%s", e)
146
+ sys.exit(1)
147
+
148
+ output_dir = Path(args.output)
149
+ output_dir.mkdir(parents=True, exist_ok=True)
150
+
151
+ rvps_path = output_dir / RVPS_FILENAME
152
+ versions = args.ocp_versions or args.image_tags
153
+ skipped = getattr(extractor, "skipped_versions", None)
154
+ rvps_path.write_text(format_trustee(values, extractor.platform, args.tee,
155
+ versions=versions, skipped=skipped,
156
+ data_key=args.data_key,
157
+ cm_name=args.cm_name,
158
+ bot_version=args.bot_version))
159
+ log.info("Written %s", rvps_path)
160
+
161
+
162
+ if __name__ == "__main__":
163
+ main()