2023-01-09 02:54:41 -05:00
|
|
|
name: Constellation verify
|
|
|
|
description: "Verify a Constellation cluster."
|
|
|
|
|
|
|
|
inputs:
|
|
|
|
osImage:
|
|
|
|
description: "The OS image used in the cluster."
|
|
|
|
required: true
|
|
|
|
cloudProvider:
|
|
|
|
description: "The cloud provider used in the cluster."
|
|
|
|
required: true
|
2023-08-04 09:43:51 -04:00
|
|
|
kubeconfig:
|
|
|
|
description: "The kubeconfig file for the cluster."
|
|
|
|
required: true
|
2023-08-09 12:58:46 -04:00
|
|
|
cosignPassword:
|
|
|
|
required: true
|
|
|
|
description: "The password for the cosign private key."
|
|
|
|
cosignPrivateKey:
|
|
|
|
required: true
|
|
|
|
description: "The cosign private key."
|
2023-01-09 02:54:41 -05:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: "composite"
|
|
|
|
steps:
|
2023-03-21 12:35:07 -04:00
|
|
|
- name: Expand version path
|
|
|
|
id: expand-version
|
|
|
|
uses: ./.github/actions/shortname
|
|
|
|
with:
|
|
|
|
shortname: ${{ inputs.osImage }}
|
|
|
|
|
2023-06-06 04:32:22 -04:00
|
|
|
- name: Constellation fetch measurements
|
2023-05-12 05:06:49 -04:00
|
|
|
shell: bash
|
|
|
|
run: |
|
2023-06-06 04:32:22 -04:00
|
|
|
if [[ ${{ steps.expand-version.outputs.stream }} == "debug" ]]
|
2023-05-12 05:06:49 -04:00
|
|
|
then
|
2023-06-06 04:32:22 -04:00
|
|
|
constellation config fetch-measurements --insecure
|
2023-05-12 05:06:49 -04:00
|
|
|
else
|
2023-06-06 04:32:22 -04:00
|
|
|
constellation config fetch-measurements
|
2023-05-12 05:06:49 -04:00
|
|
|
fi
|
2023-01-18 04:15:58 -05:00
|
|
|
|
2023-01-09 02:54:41 -05:00
|
|
|
- name: Constellation verify
|
|
|
|
shell: bash
|
2023-02-14 03:15:01 -05:00
|
|
|
run: constellation verify --cluster-id $(jq -r ".clusterID" constellation-id.json) --force
|
2023-08-04 09:43:51 -04:00
|
|
|
|
|
|
|
- name: Verify all nodes
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
KUBECONFIG: ${{ inputs.kubeconfig }}
|
|
|
|
run: |
|
2023-08-09 12:58:46 -04:00
|
|
|
clusterID=$(jq -r ".clusterID" constellation-id.json)
|
2023-08-04 09:43:51 -04:00
|
|
|
nodes=$(kubectl get nodes -o json | jq -r ".items[].metadata.name")
|
|
|
|
|
|
|
|
for node in $nodes ; do
|
|
|
|
verificationPod=$(kubectl get pods --field-selector spec.nodeName=${node} -n kube-system | grep "verification-service" | cut -d' ' -f1)
|
|
|
|
|
|
|
|
mapfile -t verificationPod <<< "$verificationPod"
|
|
|
|
|
|
|
|
if [[ ${#verificationPod[@]} -ne 1 ]]; then
|
|
|
|
echo "Expected 1 verification pod for node ${node}, found ${#verificationPodArray[@]}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-08-09 12:58:46 -04:00
|
|
|
echo "Verifying pod ${verificationPod} on node ${node}"
|
2023-08-04 09:43:51 -04:00
|
|
|
|
|
|
|
kubectl wait -n kube-system "pod/${verificationPod}" --for=condition=ready --timeout=5m
|
|
|
|
kubectl port-forward -n kube-system "pods/${verificationPod}" 9090:9090 &
|
|
|
|
forwarderPID=$!
|
|
|
|
sleep 5
|
|
|
|
|
2023-08-09 12:58:46 -04:00
|
|
|
verifyOut=$(constellation verify --cluster-id "${clusterID}" --force --node-endpoint localhost:9090)
|
2023-08-04 09:43:51 -04:00
|
|
|
|
|
|
|
kill $forwarderPID
|
2023-08-09 12:58:46 -04:00
|
|
|
|
|
|
|
if [[ ${{ inputs.cloudProvider }} != "azure" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Extracting TCB versions for API update"
|
|
|
|
startMAAToken="Microsoft Azure Attestation Token:"
|
|
|
|
endMAAToken="Verification OK"
|
|
|
|
sed -n "/${startMAAToken}/,/${endMAAToken}/ { /${startMAAToken}/d; /${endMAAToken}/d; p }" <<< "${verifyOut}" > "maa-claims-${node}.json"
|
|
|
|
done
|
|
|
|
|
|
|
|
- name: Login to AWS
|
|
|
|
if: github.ref_name == 'main' && inputs.cloudProvider == 'azure'
|
|
|
|
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
|
|
|
|
with:
|
|
|
|
role-to-assume: arn:aws:iam::795746500882:role/GitHubConstellationImagePipeline
|
|
|
|
aws-region: eu-central-1
|
|
|
|
|
|
|
|
- name: Upload extracted TCBs
|
|
|
|
if: github.ref_name == 'main' && inputs.cloudProvider == 'azure'
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
COSIGN_PASSWORD: ${{ inputs.cosignPassword }}
|
|
|
|
COSIGN_PRIVATE_KEY: ${{ inputs.cosignPrivateKey }}
|
|
|
|
run: |
|
|
|
|
for file in $(ls maa-claims-*.json); do
|
|
|
|
path=$(realpath "${file}")
|
|
|
|
cat "${path}"
|
|
|
|
bazel run //hack/configapi -- --maa-claims-path "${path}"
|
2023-08-04 09:43:51 -04:00
|
|
|
done
|