btrfs-progs: tests: add a test case for filename sanitization
This test case checks: - If a regular btrfs-image dump has the unsanitized filenames - If a sanitized btrfs-image dump has filenames properly censored Signed-off-by: Qu Wenruo <wqu@suse.com>
This commit is contained in:
parent
031282b85a
commit
fbdb8dfdee
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
# Verify "btrfs-image -s" sanitizes the filenames correctly
|
||||
|
||||
source "$TEST_TOP/common" || exit
|
||||
source "$TEST_TOP/common.convert" || exit
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev
|
||||
|
||||
declare -a filenames=("%%top_secret%%" "@@secret@@" "||confidential||")
|
||||
tmp=$(_mktemp "image-filename")
|
||||
|
||||
run_check_mkfs_test_dev
|
||||
run_check_mount_test_dev
|
||||
for i in ${filenames[@]}; do
|
||||
run_check $SUDO_HELPER touch "$TEST_MNT/$i"
|
||||
done
|
||||
run_check_umount_test_dev
|
||||
|
||||
run_check "$TOP/btrfs-image" "$TEST_DEV" "$tmp"
|
||||
_log "strings found inside the regular dump:"
|
||||
strings "$tmp" >> "$RESULTS"
|
||||
for i in ${filenames[@]}; do
|
||||
if ! grep -q "$i" "$tmp"; then
|
||||
rm -f -- "$tmp"
|
||||
_fail "regular dump sanitized the filenames"
|
||||
fi
|
||||
done
|
||||
run_check "$TOP/btrfs-image" -s "$TEST_DEV" "$tmp"
|
||||
_log "strings found inside the sanitize dump:"
|
||||
strings "$tmp" >> "$RESULTS"
|
||||
for i in ${filenames[@]}; do
|
||||
if grep -q "$i" "$tmp"; then
|
||||
rm -f -- "$tmp"
|
||||
_fail "filenames not properly sanitized"
|
||||
fi
|
||||
done
|
||||
rm -f -- "$tmp"
|
Loading…
Reference in New Issue