extract: opt-in mail tree (IMPORT_INCLUDE_MAIL=true) + mail_included marker

WHP's cPanel mailbox import needs cpmove-*/homedir/mail, which extract.sh
always excluded: in sanitization-container mode every mailbox was queued
with no Maildir and "verified" empty (B5, whp02 canary 2026-10-20).

- IMPORT_INCLUDE_MAIL=true (exactly "true"; default off) keeps the mail
  tree in the extract. Default behaviour is unchanged. The DANGEROUS
  symlink strips still apply inside the mail tree (scan-symlinks.php lists
  every archive entry).
- scan-files.php --skip-mail (passed by entrypoint.sh with the opt-in):
  clamscan --exclude-dir for the mail tree, the file count skips it, and a
  hit inside it is never quarantined. Logged with the reason: mail is
  copied verbatim into the customer's own mailbox and verified against the
  source, and multi-GB maildirs would dominate the run.
- report.json gains "mail_included" (true only with the opt-in) so the
  panel can tell this image from an older one, which never writes the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-10-20 09:04:44 -07:00
1 parent 08b995a29c
commit 8217397154
5 files changed
+111 -22

No files matched your search

+15 -1
View File
@@ -121,9 +121,23 @@ ClamAV signature DBs).
bash tests/build-fixtures.sh
```
Two tarballs land under `tests/fixtures/`:
Three tarballs land under `tests/fixtures/`:
- `cpmove-clean.tar.gz` — a benign cpmove with a WordPress MyISAM dump.
- `cpmove-alfa.tar.gz` — same shape PLUS an ALFA-style symlink to /etc.
- `cpmove-mail.tar.gz` — same shape PLUS a mail tree (two Maildirs, one
empty) with an ALFA-style symlink inside it.
### Host-side regression tests
```bash
bash tests/run-tests.sh
```
Runs `extract.sh` and `scan-files.php` straight from the checkout (bash,
php-cli, python3, GNU tar; `clamscan` is stubbed). Covers the mail-tree
opt-in (`IMPORT_INCLUDE_MAIL=true`): skipped by default, extracted when
opted in, dangerous symlinks inside it still stripped, and never scanned
or quarantined by `scan-files.php --skip-mail`.
### Run against the clean fixture