diff options
author | Julian Phillips <phillips.julian@gmail.com> | 2019-07-18 02:18:12 +0300 |
---|---|---|
committer | Julian Phillips <phillips.julian@gmail.com> | 2019-07-18 02:18:12 +0300 |
commit | 84dd0248876e99d1c92d8ff64cbd8c6306048356 (patch) | |
tree | 1c75087353e1ef4864ec68611d36b02a7113d6b7 /include/tests_crypto | |
parent | 2576bc8fcafaf2a0bfe6342d25a4dbff91987e2b (diff) |
[CRYP-7930] Modify to use 'lsblk' and 'cryptsetup'
There are several challenges with the existing method of using
/etc/crypttab:
1)encrypted rootfs partitions are not typically listed in this
file (users are prompted for password in early boot instead)
2)the 'luks' option is the default option so it is possible for
/etc/crypttab entries to never have this set explicitly and any
block device configured as such will be missed currently
3)any device mounted manually, or using any other mechanism aside
from /etc/crypttab will be missed
This commit executes 'cryptsetup isLuks' on every block device in
the system to determine whether it is a LUKS device. This handles
all 3 cases mentioned above.
Test case wording was also updated to reflect the fact that it
only checks for LUKS entrypted block devices. So, plain dm-crypt
and TrueCrypt/VeraCrypt block device encryption is not detected.
Nor is any file system level encryption such as eCryptfs, EncFs,
gocryptfs.
Diffstat (limited to 'include/tests_crypto')
-rw-r--r-- | include/tests_crypto | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/include/tests_crypto b/include/tests_crypto index ecb19d2f..4f7f1ff4 100644 --- a/include/tests_crypto +++ b/include/tests_crypto @@ -126,34 +126,28 @@ ReportSuggestion ${TEST_NO} "Check available certificates for expiration" fi fi + # ################################################################################# # # Test : CRYP-7930 - # Description : Determine if system uses disk or file encryption - Register --test-no CRYP-7930 --weight L --network NO --category security --description "Determine if system uses disk or file encryption" + # Description : Determine if system uses LUKS block device encryption + if [ ! "${LSBLKBINARY}" = "" -a ! "${CRYPTSETUPBINARY}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi + Register --test-no CRYP-7930 --preqs-met ${PREQS_MET} --weight L --network NO --root-only YES --category security --description "Determine if system uses LUKS block device encryption" if [ ${SKIPTEST} -eq 0 ]; then - FILE="${ROOTDIR}etc/crypttab" - if [ -f ${FILE} ]; then - LogText "Result: crypttab file (${FILE}) exists" - DATA=$(${GREPBINARY} "^[a-z]" ${FILE} | ${TRBINARY} -cd '[:alnum:]_\-=,\n\t ' | ${SEDBINARY} 's/[[:blank:]]/__space__/g') - for LINE in ${DATA}; do - LINE=$(echo ${LINE} | ${SEDBINARY} 's/__space__/ /g') - if ContainsString "luks," "${LINE}"; then - PARTITION=$(echo ${LINE} | ${AWKBINARY} '{print $1}' | ${AWKBINARY} -F_ '{print $1}') - LogText "Result: Found LUKS encryption on partition ${PARTITION}" - Report "encryption[]=luks,partition,${PARTITION}" - fi - done - unset DATA LINE PARTITION - else - LogText "Result: crypttab file (${FILE}) does not exist" - fi + FOUND=0 + for BLOCK_DEV in $(${LSBLKBINARY} --noheadings -o PATH); do + if ${CRYPTSETUPBINARY} isLuks ${BLOCK_DEV}; then + LogText "Result: Found LUKS encrypted block device: ${BLOCK_DEV}" + Report "encryption[]=luks,block_device,${BLOCK_DEV}" + ((FOUND++)) + fi + done + Display --indent 2 --text "- Found ${FOUND} LUKS encrypted block devices." --result OK --color WHITE + unset BLOCK_DEV fi # ################################################################################# -# - WaitForKeyPress # |