Skip to main content

Getting started with custom image and host compliance checks

info

Custom compliance checks let you create customized internal compliance checks for images and hosts.

Windows check Users folder#

note

Check if the folder c:\Users exists

IF EXIST C:\Users Echo test permission failure && exit 1

File exists#

note

Check if file /tmp/foo.txt exists

if [ ! -f /tmp/foo.txt ]; then
echo "File not found!"
exit 1
fi

File permission#

note

File permission must be correct

if [ $(stat -c %a /bin/busybox) -eq 755 ]; then
echo 'test permission failure' && exit 1;
fi

User joker#

note

User joker should not exist!

if grep -Fxq "joker" /etc/passwd
then
echo "user joker found!"
exit 1
else
echo "user joker not found!"
fi

Hosts file exists#

note

Check hosts file exists (Linux)

if [ ! -f /etc/hosts ]; then
echo "File not found!"
exit 1
fi

User batman#

note

User batman must exist!

if grep -Fxq "batman" /etc/passwd
then
echo yes
else
echo "user not found!"
exit 1
fi

Check for GPL license (alpine)#

note

Check if the alpine image has a GPL license

if grep 'GPL' ~/licenses.txt
then
echo "Found GPL license :("
exit 1
else
echo "No GPL license found :)"
exit 0
fi
Last updated on by Charlie Sestito