2022-01-25 15:54:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#########################################################################################
|
|
|
|
# Setup for PC Client Reference Integrity Manifest (RIM) tests
|
2024-07-22 10:03:09 +00:00
|
|
|
# usage rim_setup.sh -p <profile> -t <test> [-u] [-n]
|
2022-01-25 15:54:54 +00:00
|
|
|
#########################################################################################
|
|
|
|
|
2024-07-22 10:03:09 +00:00
|
|
|
# Load env variables
|
|
|
|
. /hirs/.ci/docker/.env
|
2024-06-07 10:28:25 +00:00
|
|
|
|
2024-07-22 10:03:09 +00:00
|
|
|
profile=laptop
|
|
|
|
test=default
|
|
|
|
ciTestEventLog=$HIRS_CI_TEST_EVENT_LOG_FILE
|
|
|
|
|
|
|
|
# By default save the artifacts in EFI and do not upload to the ACA
|
|
|
|
UPLOAD_ARTIFACTS=NO
|
|
|
|
PUT_ARTIFACTS_IN_ESP=YES
|
|
|
|
|
|
|
|
# Process parameters Argument handling
|
|
|
|
POSITIONAL_ARGS=()
|
|
|
|
ORIGINAL_ARGS=("$@")
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
case $1 in
|
|
|
|
-p|--profile)
|
|
|
|
shift # past argument
|
|
|
|
profile=$1
|
|
|
|
shift # past parameter
|
|
|
|
;;
|
|
|
|
-t|--test)
|
|
|
|
shift # past argument
|
|
|
|
test=$1
|
|
|
|
shift # past parameter
|
|
|
|
;;
|
|
|
|
-u|--upload)
|
|
|
|
UPLOAD_ARTIFACTS=YES
|
|
|
|
shift # past argument
|
|
|
|
;;
|
|
|
|
-n|--no-efi)
|
|
|
|
PUT_ARTIFACTS_IN_ESP=NO
|
|
|
|
shift # past argument
|
|
|
|
;;
|
|
|
|
-*|--*)
|
|
|
|
echo "rim_setup.sh: Unknown option $1"
|
|
|
|
shift # past argument
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
POSITIONAL_ARGS+=("$1") # save positional arg
|
|
|
|
# shift # past argument
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2024-06-07 10:28:25 +00:00
|
|
|
# Profile selections
|
2024-07-22 10:03:09 +00:00
|
|
|
profileDir="$HIRS_CI_REPO_ROOT/.ci/system-tests/profiles/$profile"
|
2022-02-03 21:58:11 +00:00
|
|
|
defaultDir="$profileDir/default"
|
2024-07-22 10:03:09 +00:00
|
|
|
testDir="$profileDir/$test"
|
2022-01-26 15:24:29 +00:00
|
|
|
eventLog="$testDir"/"$profile"_"$test"_binary_bios_measurements
|
2022-02-03 20:30:10 +00:00
|
|
|
swidDir="$testDir/swidtags"
|
|
|
|
rimDir="$testDir/rims"
|
|
|
|
pcrScript="$testDir/"$profile"_"$test"_setpcrs.sh"
|
2022-02-04 22:02:50 +00:00
|
|
|
|
2022-02-03 20:30:10 +00:00
|
|
|
echo "Test is using RIM files from $profile : $test"
|
2022-01-25 15:54:54 +00:00
|
|
|
|
2024-07-22 10:03:09 +00:00
|
|
|
# Ensure rim folders under efi are set up and cleared
|
|
|
|
$HIRS_CI_REPO_ROOT/.ci/system-tests/container/efi_setup.sh -r
|
2022-01-25 15:54:54 +00:00
|
|
|
|
2024-06-07 10:28:25 +00:00
|
|
|
# Step 1: Copy binary_bios_measurement file
|
2024-06-07 17:27:08 +00:00
|
|
|
if [ ! -e "$eventLog" ]; then
|
2024-07-22 10:03:09 +00:00
|
|
|
eventLog=$HIRS_CI_TEST_DEFAULT_EVENT_LOG
|
2024-06-07 17:27:08 +00:00
|
|
|
fi
|
2024-06-07 10:28:25 +00:00
|
|
|
echo "eventLog used was $eventLog"
|
|
|
|
cp "$eventLog" "$ciTestEventLog"
|
2022-01-25 15:54:54 +00:00
|
|
|
|
|
|
|
# Step 2: Copy Base RIM files to the TCG folder
|
2024-07-22 10:03:09 +00:00
|
|
|
# a: See if test specific swidtag folder exists, if not use the default folder
|
2022-02-03 20:30:10 +00:00
|
|
|
if [[ ! -d $swidDir ]]; then
|
|
|
|
swidDir=$defaultDir/swidtags;
|
|
|
|
fi
|
|
|
|
pushd $swidDir > /dev/null
|
2022-01-25 15:54:54 +00:00
|
|
|
if [[ ! -f ".gitignore" ]]; then
|
|
|
|
for swidtag in * ; do
|
2024-07-22 10:03:09 +00:00
|
|
|
if [ "$PUT_ARTIFACTS_IN_ESP" = YES ]; then
|
|
|
|
echo "Saving $swidtag to $HIRS_CI_EFI_PATH_SWIDTAG"
|
|
|
|
cp $swidtag $HIRS_CI_EFI_PATH_SWIDTAG
|
|
|
|
fi
|
|
|
|
if [ "$UPLOAD_ARTIFACTS" = YES ]; then
|
|
|
|
echo "Uploading $swidtag to $SERVER_RIM_POST"
|
2024-07-25 18:57:30 +00:00
|
|
|
curl -k -F "file=@$swidtag" $SERVER_RIM_POST > /dev/null 2>&1
|
2024-07-22 10:03:09 +00:00
|
|
|
fi
|
2022-01-25 15:54:54 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
popd > /dev/null
|
2024-07-22 10:03:09 +00:00
|
|
|
# Step 3: Copy Support RIM files to the TCG folder in the same manner
|
2022-02-03 20:30:10 +00:00
|
|
|
if [[ ! -d $rimDir ]]; then
|
|
|
|
rimDir=$defaultDir/rims;
|
|
|
|
fi
|
|
|
|
pushd $rimDir > /dev/null
|
2022-01-25 15:54:54 +00:00
|
|
|
if [[ ! -f ".gitignore" ]]; then
|
|
|
|
for rim in * ; do
|
2024-07-22 10:03:09 +00:00
|
|
|
if [ "$PUT_ARTIFACTS_IN_ESP" = YES ]; then
|
|
|
|
echo "Saving $rim to $HIRS_CI_EFI_PATH_RIM"
|
|
|
|
cp $rim $HIRS_CI_EFI_PATH_RIM
|
|
|
|
fi
|
|
|
|
if [ "$UPLOAD_ARTIFACTS" = YES ]; then
|
|
|
|
echo "Uploading $rim to $SERVER_RIM_POST"
|
2024-07-25 18:57:30 +00:00
|
|
|
curl -k -F "file=@$rim" $SERVER_RIM_POST > /dev/null 2>&1
|
2024-07-22 10:03:09 +00:00
|
|
|
fi
|
2022-01-25 15:54:54 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
#Step 4, run the setpcr script to make the TPM emulator hold values that correspond the binary_bios_measurement file
|
2022-02-03 20:30:10 +00:00
|
|
|
if [[ ! -f $pcrScript ]]; then
|
2024-07-22 10:03:09 +00:00
|
|
|
pcrScript=$HIRS_CI_TEST_DEFAULT_SETPCRS_SH
|
2022-02-03 20:30:10 +00:00
|
|
|
fi
|
|
|
|
sh $pcrScript;
|
2022-01-25 15:54:54 +00:00
|
|
|
|