#!/usr/bin/env bash # # build-scope-tree.sh [--big] -- a synthetic extracted backup that exercises the scan scope # (policy code-risky-v1 of whp-scan-scope; the cases come from the six security-review rounds of the # WHP scanscope package). No customer data. /cpmove-scope/... is the layout of an extract. # # --big also add a SPARSE 2001 MiB clean mp4 (just above the 2000 MiB limit): it must show up in # oversize_unscanned_files (named staff-review warning), never on the clamscan list. # # The EXPECT_* lists below are the contract tests check, one path per line relative to . set -euo pipefail ROOT="${1:?usage: build-scope-tree.sh [--big]}" BIG=false; [[ "${2:-}" == "--big" ]] && BIG=true T="$ROOT/cpmove-scope" H="$T/homedir" mkdir -p "$T/userdata" "$H/public_html/hd" "$H/public_html/uploads" "$H/tmp/site" "$H/tmp/work" "$H/etc" \ "$H/mail/example.com/alice/cur" "$H/logs" # userdata: the main docroot and an addon docroot that lives under ~/tmp (served, so a web root) cat > "$T/userdata/example.com" < "$T/userdata/site.example.com" < "$H/public_html/index.php" # code printf '\xff\xd8\xff\xe0' > "$H/public_html/polyglot.jpg" # polyglot: JPEG magic + php (media under 20 MiB is always scanned) printf '\xff\xd8\xff\xe0JFIF clean' > "$H/public_html/clean-small.jpg" # small media under a web root: scanned too echo 'payload' > "$H/tmp/work/payload.txt" ln -s ../tmp/work/payload.txt "$H/public_html/link.jpg" # web-root symlink: its TARGET is scanned echo ' "$H/tmp/site/page.php" # docroot-under-tmp: web root echo 'plain data in a docroot under tmp' > "$H/tmp/site/notes.txt" # ... so even data is scanned there printf 'AddHandler application/x-httpd-php .jpg\n' > "$H/public_html/hd/.htaccess" # handler directory: everything below is in scope printf '\xff\xd8\xff\xe0JFIF in a handler dir' > "$H/public_html/hd/handled.jpg" echo 'upload blob' > "$H/public_html/uploads/blob.dat" # uploads dir: scanned unless verified media printf 'X5O!P%%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > "$H/public_html/eicar.php" # a real ClamAV hit # --- skipped by policy --- echo 'log line' > "$H/logs/access.log" # data outside a web root echo 'a=1' > "$H/etc/data.txt" echo 'Subject: hi' > "$H/mail/example.com/alice/cur/1700000000.M1P1.host,S=12:2,S" # mail (skipped with --skip-mail) { printf '\x00\x00\x00\x18ftypmp42'; head -c 22000000 /dev/zero; } > "$H/public_html/video.mp4" # clean media over 20 MiB: skipped (class media) if $BIG; then { printf '\x00\x00\x00\x18ftypmp42'; } > "$H/public_html/huge.mp4" truncate -s 2001M "$H/public_html/huge.mp4" # sparse, above the 2000 MiB limit fi cat > "$ROOT/EXPECT_LISTED" < "$ROOT/EXPECT_NOT_LISTED" < "$ROOT/EXPECT_MAIL"