-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This tests the allowed mount points for tmpfs mounts and /dev/shm size.
- Loading branch information
Showing
4 changed files
with
126 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
substitutions: | ||
'_IMAGE_NAME': '' | ||
'_IMAGE_PROJECT': '' | ||
'_CLEANUP': 'true' | ||
'_VM_NAME_PREFIX': 'cs-mounts-test' | ||
'_ZONE': 'us-central1-a' | ||
'_WORKLOAD_IMAGE': 'us-west1-docker.pkg.dev/confidential-space-images-dev/cs-integ-test-images/mounts_workload:latest' | ||
|
||
steps: | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CreateVMWithMountsAllowed | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['create_vm.sh','-i', '${_HARDENED_IMAGE_NAME}', | ||
'-p', '${_IMAGE_PROJECT}', | ||
'-m', '^~^tee-image-reference=${_WORKLOAD_IMAGE}~tee-container-log-redirect=true~tee-mount=type=tmpfs,source=tmpfs,destination=/tmp/sized,size=222000~tee-dev-shm-size=128000', | ||
'-n', '${_VM_NAME_PREFIX}-${BUILD_ID}-allowed', | ||
'-z', '${_ZONE}', | ||
] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CreateVMWithMountsDenied | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['create_vm.sh','-i', '${_HARDENED_IMAGE_NAME}', | ||
'-p', '${_IMAGE_PROJECT}', | ||
'-m', '^~^tee-image-reference=${_WORKLOAD_IMAGE}~tee-container-log-redirect=true~tee-mount=type=tmpfs,source=tmpfs,destination=/disallowed', | ||
'-n', '${_VM_NAME_PREFIX}-${BUILD_ID}-denied', | ||
'-z', '${_ZONE}', | ||
] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CheckMountsAllowed | ||
env: | ||
- '_VM_NAME_PREFIX=$_VM_NAME_PREFIX' | ||
- 'BUILD_ID=$BUILD_ID' | ||
- '_ZONE=$_ZONE' | ||
script: | | ||
#!/bin/bash | ||
set -euo pipefail | ||
source util/read_serial.sh | ||
sleep 45 | ||
SERIAL_OUTPUT=$(read_serial ${_VM_NAME_PREFIX}-${BUILD_ID}-allowed ${_ZONE}) | ||
echo $SERIAL_OUTPUT | ||
if echo $SERIAL_OUTPUT | grep -q "tmpfs.*220.*/tmp/sized" | ||
then | ||
echo "- Mount launch policy verified" | ||
else | ||
echo "FAILED: Mount launch policy verification for sized tmpfs" | ||
echo 'TEST FAILED' > /workspace/status.txt | ||
echo $SERIAL_OUTPUT | ||
fi | ||
if echo $SERIAL_OUTPUT | grep -q "shm.*128000.*/dev/shm" | ||
then | ||
echo "- Mount launch policy verified" | ||
else | ||
echo "FAILED: Mount launch policy verification /dev/shm size" | ||
echo 'TEST FAILED' > /workspace/status.txt | ||
echo $SERIAL_OUTPUT | ||
fi | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CheckMountsDenied | ||
env: | ||
- '_VM_NAME_PREFIX=$_VM_NAME_PREFIX' | ||
- 'BUILD_ID=$BUILD_ID' | ||
- '_ZONE=$_ZONE' | ||
script: | | ||
#!/bin/bash | ||
set -euo pipefail | ||
source util/read_serial.sh | ||
sleep 45 | ||
SERIAL_OUTPUT=$(read_serial ${_VM_NAME_PREFIX}-${BUILD_ID}-denied ${_ZONE}) | ||
if echo $SERIAL_OUTPUT | grep -q "policy only allows mounts in the following paths" | ||
then | ||
echo "- Mount launch policy verified" | ||
else | ||
echo "FAILED: Mount launch policy verification for disallowed mounts" | ||
echo 'TEST FAILED' > /workspace/status.txt | ||
echo $SERIAL_OUTPUT | ||
fi | ||
waitFor: ['CreateVMWithMountsDenied'] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CleanUpVMWithMountsAllowed | ||
entrypoint: 'bash' | ||
env: | ||
- 'CLEANUP=$_CLEANUP' | ||
args: ['cleanup.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}-allowed', '${_ZONE}'] | ||
waitFor: ['CheckMountsAllowed'] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CleanUpVMWithMountsDenied | ||
entrypoint: 'bash' | ||
env: | ||
- 'CLEANUP=$_CLEANUP' | ||
args: ['cleanup.sh', '${_VM_NAME_PREFIX}-${BUILD_ID}-denied', '${_ZONE}'] | ||
waitFor: ['CheckMountsDenied'] | ||
|
||
# Must come after cleanup. | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
id: CheckFailure | ||
entrypoint: 'bash' | ||
env: | ||
- 'BUILD_ID=$BUILD_ID' | ||
args: ['check_failure.sh'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#!/bin/sh | ||
|
||
df -h | ||
df | ||
|
||
ls -lathr / | ||
|
||
ls -lathr /my-new-disk | ||
|
||
mkdir /my-new-disk/sldifj | ||
ls -lathr /run/tmp | ||
ls -lathr /var/tmp | ||
ls -lathr /tmp |