Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit a5d831b

Browse files
Alex-Carter01Alex Carter
authored andcommitted
CC: Add image signature tests for SEV
Inserts resource information to kbs for signing adds example cosign and policy files to be used along with signing tests Add currently one test for: signed imagage with no required measurement Fixes: #5412
1 parent 69baf08 commit a5d831b

4 files changed

Lines changed: 80 additions & 3 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-----BEGIN PUBLIC KEY-----
2+
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1gHGbfk1AqOweLEM8HfT0bmfQE3b
3+
9fcp/LU75FMfxVZXmNVtUprsHM1thuuiBKOofv8KV7TrFl4p8NJCiXUkhA==
4+
-----END PUBLIC KEY-----
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"default": [
3+
{
4+
"type": "insecureAcceptAnything"
5+
}
6+
],
7+
"transports": {
8+
"docker": {
9+
"quay.io/kata-containers/confidential-containers": [
10+
{
11+
"type": "signedBy",
12+
"keyType": "GPGKeys",
13+
"keyPath": "/run/image-security/simple_signing/pubkey.gpg"
14+
}
15+
],
16+
"quay.io/kata-containers/confidential-containers:cosign-signed": [
17+
{
18+
"type": "sigstoreSigned",
19+
"keyPath": "/run/image-security/cosign/cosign.pub"
20+
}
21+
],
22+
"quay.io/kata-containers/confidential-containers:cosign-signed-key2": [
23+
{
24+
"type": "sigstoreSigned",
25+
"keyPath": "/run/image-security/cosign/cosign.pub"
26+
}
27+
]
28+
}
29+
}
30+
}

integration/kubernetes/confidential/sev.bats

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,22 @@ delete_pods() {
150150
local encrypted_pod_name=$(esudo kubectl get pod -o wide | grep encrypted-image-tests | awk '{print $1;}' || true)
151151
local unencrypted_pod_name=$(esudo kubectl get pod -o wide | grep unencrypted-image-tests | awk '{print $1;}' || true)
152152
local encrypted_pod_name_es=$(esudo kubectl get pod -o wide | grep encrypted-image-tests-es | awk '{print $1;}' || true)
153+
local signed_pod_name=$(esudo kubectl get pod -o wide | grep signed-image-tests | awk '{print $1;}' || true)
153154

154-
# Delete both encrypted and unencrypted pods
155+
# Delete encrypted, unencrypted, and signed pods
155156
esudo kubectl delete -f \
156157
"${TEST_DIR}/unencrypted-image-tests.yaml" 2>/dev/null || true
157158
esudo kubectl delete -f \
158159
"${TEST_DIR}/encrypted-image-tests.yaml" 2>/dev/null || true
159160
esudo kubectl delete -f \
160161
"${TEST_DIR}/encrypted-image-tests-es.yaml" 2>/dev/null || true
161-
162+
esudo kubectl delete -f \
163+
"${TEST_DIR}/signed-image-tests.yaml" 2>/dev/null || true
164+
162165
[ -z "${encrypted_pod_name}" ] || (kubernetes_wait_for_pod_delete_state "${encrypted_pod_name}" || true)
163166
[ -z "${unencrypted_pod_name}" ] || (kubernetes_wait_for_pod_delete_state "${unencrypted_pod_name}" || true)
164167
[ -z "${encrypted_pod_name_es}" ] || (kubernetes_wait_for_pod_delete_state "${encrypted_pod_name_es}" || true)
168+
[ -z "${signed_pod_name}" ] || (kubernetes_wait_for_pod_delete_state "${signed_pod_name}" || true)
165169
}
166170

167171
run_kbs() {
@@ -177,6 +181,11 @@ run_kbs() {
177181

178182
pushd simple-kbs
179183
git checkout -b "branch_${simple_kbs_tag}" "${simple_kbs_tag}"
184+
185+
#copy resources
186+
cp ${TESTS_REPO_DIR}/integration/kubernetes/confidential/fixtures/policy.json resources/
187+
cp ${TESTS_REPO_DIR}/integration/kubernetes/confidential/fixtures/cosign.pub resources/
188+
180189
esudo docker-compose build
181190

182191
esudo docker-compose up -d
@@ -315,6 +324,7 @@ setup_file() {
315324

316325
generate_service_yaml "unencrypted-image-tests" "${IMAGE_REPO}:unencrypted"
317326
generate_service_yaml "encrypted-image-tests" "${IMAGE_REPO}:encrypted"
327+
generate_service_yaml "signed-image-tests" "quay.io/kata-containers/confidential-containers:cosign-signed"
318328

319329
# SEV-ES policy is 7:
320330
# - NODBG (1): Debugging of the guest is disallowed when set
@@ -339,10 +349,24 @@ setup() {
339349
EOF
340350
}
341351

352+
setup_cosign_signatures_files() {
353+
mysql -u${KBS_DB_USER} -p${KBS_DB_PW} -h ${KBS_DB_HOST} -D ${KBS_DB} <<EOF
354+
INSERT INTO secrets VALUES (10, 'key_id1', '${ENCRYPTION_KEY}', 10);
355+
INSERT INTO keysets VALUES (10, 'KEYSET-1', '["key_id1"]', 10);
356+
# see https://github.com/confidential-containers/simple-kbs/blob/8507253e9060fb081fd1eac7bf2841ebf02c0847/db/db-mysql.sql#L140
357+
# INSERT INTO resources VALUES (10, 0, resource_type, resource_path, 10);
358+
INSERT INTO resources SET resource_type="Policy", resource_path="policy.json";
359+
INSERT INTO resources SET resource_type="Cosign Key", resource_path="cosign.pub";
360+
EOF
361+
}
362+
342363
@test "$test_tag Test SEV unencrypted container launch success" {
343364
# Turn off pre-attestation. It is not necessary for an unencrypted image.
344365
esudo sed -i 's/guest_pre_attestation = true/guest_pre_attestation = false/g' ${SEV_CONFIG}
345366

367+
# Turn off signature verification
368+
esudo sed -i 's/agent.enable_signature_verification=true/agent.enable_signature_verification=false/g' ${SEV_CONFIG}
369+
346370
# Start the service/deployment/pod
347371
esudo kubectl apply -f "${TEST_DIR}/unencrypted-image-tests.yaml"
348372

@@ -516,6 +540,25 @@ EOF
516540

517541

518542

543+
@test "$test_tag Test signed image with no required measurement" {
544+
# Add resource files to
545+
setup_cosign_signatures_files
546+
547+
#change kernel command line for signature validation
548+
esudo sed -i 's/agent.enable_signature_verification=false/agent.enable_signature_verification=true/g' ${SEV_CONFIG}
549+
550+
# Start the service/deployment/pod
551+
552+
esudo kubectl apply -f "${TEST_DIR}/signed-image-tests.yaml"
553+
554+
# Retrieve pod name, wait for it to come up, retrieve pod ip
555+
pod_name=$(esudo kubectl get pod -o wide | grep signed-image-tests | awk '{print $1;}')
556+
kubernetes_wait_for_pod_ready_state "$pod_name" 20
557+
pod_ip=$(esudo kubectl get pod -o wide | grep signed-image-tests | awk '{print $6;}')
558+
559+
print_service_info
560+
}
561+
519562
teardown_file() {
520563
echo "###############################################################################"
521564
echo -e "TEARDOWN - STARTED\n"

versions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ externals:
7272
simple-kbs:
7373
description: "Simple KBS that hosts key storage with release policies"
7474
url: "https://github.com/confidential-containers/simple-kbs.git"
75-
tag: "0.1.1"
75+
tag: "v0.1.2"
7676

7777
sonobuoy:
7878
description: "Tool to run kubernetes e2e conformance tests"

0 commit comments

Comments
 (0)