Skip to content

Commit b107516

Browse files
authored
Merge pull request #129 from lmilleri/update-bm-install
Update helper installation script
2 parents 44992af + 26ea62d commit b107516

7 files changed

Lines changed: 199 additions & 64 deletions

File tree

scripts/install-helpers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ These are helper scripts to setup Trustee operator on OpenShift cluster
44

55
## Prerequisites
66

7-
- `oc`, `jq` and `openssl` CLI
7+
- `oc`, `jq`, `git` and `openssl` CLI
88

99
## How to use the installation script
1010

scripts/install-helpers/attestation-policy.yaml

Lines changed: 115 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,135 @@ metadata:
55
namespace: trustee-operator-system
66
data:
77
default.rego: |
8-
package policy
9-
import future.keywords.every
8+
package policy
109
11-
default allow = false
10+
import rego.v1
1211
13-
allow {
14-
every k, v in input {
15-
judge_field(k, v)
16-
}
12+
# This policy validates multiple TEE platforms
13+
# The policy is meant to capture the TCB requirements
14+
# for confidential containers.
15+
16+
# This policy is used to generate an EAR Appraisal.
17+
# Specifically it generates an AR4SI result.
18+
# More informatino on AR4SI can be found at
19+
# <https://datatracker.ietf.org/doc/draft-ietf-rats-ar4si/>
20+
21+
# For the `executables` trust claim, the value 33 stands for
22+
# "Runtime memory includes executables, scripts, files, and/or
23+
# objects which are not recognized."
24+
default executables := 33
25+
26+
# For the `hardware` trust claim, the value 97 stands for
27+
# "A Verifier does not recognize an Attester's hardware or
28+
# firmware, but it should be recognized."
29+
default hardware := 97
30+
31+
# For the `configuration` trust claim the value 36 stands for
32+
# "Elements of the configuration relevant to security are
33+
# unavailable to the Verifier."
34+
default configuration := 36
35+
36+
##### Sample
37+
38+
# For the `executables` trust claim, the value 3 stands for
39+
# "Only a recognized genuine set of approved executables have
40+
# been loaded during the boot process."
41+
executables := 3 if {
42+
# The sample attester does not report any launch digest.
43+
# This is an example of how a real platform might validate executables.
44+
input.sample.launch_digest in data.reference.launch_digest
1745
}
1846
19-
judge_field(input_key, input_value) {
20-
has_key(data.reference, input_key)
21-
reference_value := data.reference[input_key]
22-
match_value(reference_value, input_value)
47+
# For the `hardware` trust claim, the value 2 stands for
48+
# "An Attester has passed its hardware and/or firmware
49+
# verifications needed to demonstrate that these are genuine/
50+
# supported.
51+
hardware := 2 if {
52+
input.sample.svn in data.reference.svn
2353
}
2454
25-
judge_field(input_key, input_value) {
26-
not has_key(data.reference, input_key)
55+
##### SNP
56+
executables := 3 if {
57+
# In the future, we might calculate this measurement here various components
58+
input.snp.measurement in data.reference.snp_launch_measurement
2759
}
2860
29-
match_value(reference_value, input_value) {
30-
not is_array(reference_value)
31-
input_value == reference_value
61+
hardware := 2 if {
62+
# Check the reported TCB to validate the ASP FW
63+
input.snp.reported_tcb_bootloader in data.reference.snp_bootloader
64+
input.snp.reported_tcb_microcode in data.reference.snp_microcode
65+
input.snp.reported_tcb_snp in data.reference.snp_snp_svn
66+
input.snp.reported_tcb_tee in data.reference.snp_tee_svn
3267
}
3368
34-
match_value(reference_value, input_value) {
35-
is_array(reference_value)
36-
array_include(reference_value, input_value)
69+
# For the 'configuration' trust claim 2 stands for
70+
# "The configuration is a known and approved config."
71+
#
72+
# For this, we compare all the configuration fields.
73+
configuration := 2 if {
74+
input.snp.policy_debug_allowed == 0
75+
input.snp.policy_migrate_ma == 0
76+
input.snp.platform_smt_enabled in data.reference.snp_smt_enabled
77+
input.snp.platform_tsme_enabled in data.reference.snp_tsme_enabled
78+
input.snp.policy_abi_major in data.reference.snp_guest_abi_major
79+
input.snp.policy_abi_minor in data.reference.snp_guest_abi_minor
80+
input.snp.policy_single_socket in data.reference.snp_single_socket
81+
input.snp.policy_smt_allowed in data.reference.snp_smt_allowed
3782
}
3883
39-
array_include(reference_value_array, input_value) {
40-
reference_value_array == []
84+
# For the `configuration` trust claim 3 stands for
85+
# "The configuration includes or exposes no known
86+
# vulnerabilities."
87+
#
88+
# In this check, we do not specifically check every
89+
# configuration value, but we make sure that some key
90+
# configurations (like debug_allowed) are set correctly.
91+
else := 3 if {
92+
input.snp.policy_debug_allowed == 0
93+
input.snp.policy_migrate_ma == 0
4194
}
4295
43-
array_include(reference_value_array, input_value) {
44-
reference_value_array != []
45-
some i
46-
reference_value_array[i] == input_value
96+
##### TDX
97+
executables := 3 if {
98+
# Check the kernel, initrd, and cmdline (including dmverity parameters) measurements
99+
# TODO: add individual CCEL measurements from input.tdx.ccel instead
100+
input.tdx.quote.body.rtmr_1 in data.reference.rtmr_1
101+
input.tdx.quote.body.rtmr_2 in data.reference.rtmr_2
47102
}
48103
49-
has_key(m, k) {
50-
_ = m[k]
104+
hardware := 2 if {
105+
# Check the quote is a TDX quote signed by Intel SGX Quoting Enclave
106+
input.tdx.quote.header.tee_type == "81000000"
107+
input.tdx.quote.header.vendor_id == "939a7233f79c4ca9940a0db3957f0607"
108+
109+
# Check TDX Module version and its hash. Also check OVMF code hash.
110+
input.tdx.quote.body.mr_seam in data.reference.mr_seam
111+
input.tdx.quote.body.tcb_svn in data.reference.tcb_svn
112+
input.tdx.quote.body.mr_td in data.reference.mr_td
113+
# Check TCB status
114+
# input.tdx.tcb_status == "OK"
115+
116+
# Check collateral expiration status
117+
# input.tdx.collateral_expiration_status == "0"
118+
119+
# Check against allowed advisory ids
120+
# allowed_advisory_ids := {"INTEL-SA-00837"}
121+
# attester_advisory_ids := {id | id := input.attester_advisory_ids[_]}
122+
# object.subset(allowed_advisory_ids, attester_advisory_ids)
123+
124+
# Check against disallowed advisory ids
125+
# disallowed_advisory_ids := {"INTEL-SA-00837"}
126+
# attester_advisory_ids := {id | id := input.tdx.advisory_ids[_]} # convert array to set
127+
# intersection := attester_advisory_ids & disallowed_advisory_ids
128+
# count(intersection) == 0
51129
}
130+
131+
configuration := 2 if {
132+
# Check the TD has the expected attributes (e.g., debug not enabled) and features.
133+
input.tdx.td_attributes.debug == false
134+
input.tdx.quote.body.xfam in data.reference.xfam
135+
}
136+
137+
##### AZ SNP TODO
138+
##### AZ TDX TODO
139+
##### SE TODO

scripts/install-helpers/install.sh

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ ITA_KEY="${ITA_KEY:-}"
1010
if [ -n "$ITA_KEY" ]; then
1111
TDX=true
1212
fi
13-
DEFAULT_IMAGE=quay.io/openshift_sandboxed_containers/kbs:v0.10.1
14-
DEFAULT_TRUSTEE_OPERATOR_CSV=trustee-operator.v0.2.0
13+
14+
DEFAULT_IMAGE=quay.io/redhat-user-workloads/ose-osc-tenant/trustee/trustee:345aef3985efea5d4f91ffbffb597cb44087b96a
15+
DEFAULT_TRUSTEE_OPERATOR_CSV=trustee-operator.v0.3.0
1516

1617
if [ -n "$ITA_KEY" ]; then
1718
DEFAULT_IMAGE+="-ita"
@@ -44,6 +45,14 @@ function check_openssl() {
4445
fi
4546
}
4647

48+
# Function to check if the git command is available
49+
function check_git() {
50+
if ! command -v git &>/dev/null; then
51+
echo "git command not found. Please install git."
52+
return 1
53+
fi
54+
}
55+
4756
# Function to wait for the operator deployment object to be ready
4857
function wait_for_deployment() {
4958
local deployment=$1
@@ -238,6 +247,29 @@ function create_trustee_artefacts() {
238247

239248
}
240249

250+
function set_fbc_catalog_image() {
251+
latest_fbc_commit=$(git ls-remote https://github.com/openshift/trustee-fbc.git HEAD | cut -f 1)
252+
ocp_version=$(oc version --output json | jq '.openshiftVersion')
253+
image_prefix=quay.io/redhat-user-workloads/ose-osc-tenant
254+
if [[ "$ocp_version" =~ 4\.15.* ]] ;
255+
then
256+
FBC_IMAGE=$image_prefix/trustee-fbc-4-15/trustee-fbc-4-15
257+
elif [[ "$ocp_version" =~ 4\.16.* ]] ;
258+
then
259+
FBC_IMAGE=$image_prefix/trustee-fbc/trustee-fbc-4-16
260+
elif [[ "$ocp_version" =~ 4\.17.* ]] ;
261+
then
262+
FBC_IMAGE=$image_prefix/trustee-fbc-4-17
263+
elif [[ "$ocp_version" =~ 4\.18.* ]] ;
264+
then
265+
FBC_IMAGE=$image_prefix/trustee-fbc-4-18
266+
else
267+
echo "OCP version "$ocp_version" not supported yet!"
268+
exit 1
269+
fi
270+
export FBC_IMAGE="$FBC_IMAGE:$latest_fbc_commit"
271+
}
272+
241273
# Function to apply the operator manifests
242274
function apply_operator_manifests() {
243275
# Apply the manifests, error exit if any of them fail
@@ -247,7 +279,10 @@ function apply_operator_manifests() {
247279
oc apply -f subs-ga.yaml || return 1
248280
approve_installplan_for_target_csv trustee-operator-system "$TRUSTEE_OPERATOR_CSV" || return 1
249281
else
282+
set_fbc_catalog_image
283+
envsubst < "trustee_catalog.yaml.in" > "trustee_catalog.yaml"
250284
oc apply -f trustee_catalog.yaml || return 1
285+
rm -f trustee_catalog.yaml
251286
oc apply -f subs-upstream.yaml || return 1
252287
fi
253288

@@ -260,7 +295,7 @@ function override_trustee_image() {
260295
oc patch -n trustee-operator-system $CSV --type=json -p="[
261296
{
262297
"op": "replace",
263-
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/1/env/1/value",
298+
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/1/value",
264299
"value": "$TRUSTEE_IMAGE"
265300
}
266301
]"
@@ -399,6 +434,9 @@ check_oc || exit 1
399434
# Check if openssl command is available
400435
check_openssl || exit 1
401436

437+
# Check if git command is available
438+
check_git || exit 1
439+
402440
# If MIRRORING is true, then create the image mirroring config
403441
if [ "$MIRRORING" = true ]; then
404442
echo "Creating image mirroring config"

scripts/install-helpers/kbs-cm.yaml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,42 @@ metadata:
55
name: kbs-config-cm
66
namespace: trustee-operator-system
77
data:
8-
kbs-config.json: |
9-
{
10-
"insecure_http" : true,
11-
"sockets": ["0.0.0.0:8080"],
12-
"auth_public_key": "/etc/auth-secret/publicKey",
13-
"attestation_token_config": {
14-
"attestation_token_type": "CoCo"
15-
},
16-
"repository_config": {
17-
"type": "LocalFs",
18-
"dir_path": "/opt/confidential-containers/kbs/repository"
19-
},
20-
"as_config": {
21-
"work_dir": "/opt/confidential-containers/attestation-service",
22-
"policy_engine": "opa",
23-
"attestation_token_broker": "Simple",
24-
"attestation_token_config": {
25-
"duration_min": 5
26-
},
27-
"rvps_config": {
28-
"store_type": "LocalJson",
29-
"store_config": {
30-
"file_path": "/opt/confidential-containers/rvps/reference-values/reference-values.json"
31-
}
32-
}
33-
},
34-
"policy_engine_config": {
35-
"policy_path": "/opt/confidential-containers/opa/policy.rego"
36-
}
37-
}
8+
kbs-config.toml: |
9+
[http_server]
10+
sockets = ["0.0.0.0:8080"]
11+
insecure_http = true
12+
13+
[admin]
14+
insecure_api = true
15+
auth_public_key = "/etc/auth-secret/publicKey"
16+
17+
[attestation_token]
18+
insecure_key = true
19+
attestation_token_type = "CoCo"
20+
21+
[attestation_service]
22+
type = "coco_as_builtin"
23+
work_dir = "/opt/confidential-containers/attestation-service"
24+
policy_engine = "opa"
25+
26+
[attestation_service.attestation_token_broker]
27+
type = "Ear"
28+
policy_dir = "/opt/confidential-containers/attestation-service/policies"
29+
30+
[attestation_service.attestation_token_config]
31+
duration_min = 5
32+
33+
[attestation_service.rvps_config]
34+
type = "BuiltIn"
35+
36+
[attestation_service.rvps_config.storage]
37+
type = "LocalJson"
38+
file_path = "/opt/confidential-containers/rvps/reference-values/reference-values.json"
39+
40+
[[plugins]]
41+
name = "resource"
42+
type = "LocalFs"
43+
dir_path = "/opt/confidential-containers/kbs/repository"
44+
45+
[policy_engine]
46+
policy_path = "/opt/confidential-containers/opa/policy.rego"

scripts/install-helpers/resource-policy-cm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ data:
88
package policy
99
default allow = false
1010
allow {
11-
input["tee"] != "sample"
11+
input["submods"]["cpu"]["ear.status"] != "contraindicated"
1212
}

scripts/install-helpers/subs-ga.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ spec:
1010
name: trustee-operator
1111
source: redhat-operators
1212
sourceNamespace: openshift-marketplace
13-
startingCSV: trustee-operator.v0.2.0
13+
startingCSV: trustee-operator.v0.3.0

scripts/install-helpers/trustee_catalog.yaml renamed to scripts/install-helpers/trustee_catalog.yaml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
spec:
77
displayName: Trustee Operator Catalog
88
sourceType: grpc
9-
image: quay.io/redhat-user-workloads/ose-osc-tenant/trustee-fbc/trustee-fbc-4-16@sha256:9d3414cf77b353f6345a13e47e5365ab25931ef85afbfb6d778cd9bb818af047
9+
image: ${FBC_IMAGE}
1010
updateStrategy:
1111
registryPoll:
1212
interval: 5m

0 commit comments

Comments
 (0)