Skip to content

test(task): ignore an external scanner's copy in the hostile filename test - #199

Draft
greenhat616 wants to merge 1 commit into
test/hardening-34-port-racefrom
test/hardening-35-scanner-tmp
Draft

greenhat616 wants to merge 1 commit into
test/hardening-34-port-racefrom
test/hardening-35-scanner-tmp

Conversation

@greenhat616

Copy link
Copy Markdown
Owner

Test fix for the download strategy hardening stack. It is stacked on #198, and that branch is its base. The design note is in §14.25.

Why

test_save_into_rejects_hostile_filenames asserted that the download directory held only evil.bin. On the maintainer's Windows machine it failed in 2 of 30 runs: the directory also held EVIL.BIN.DOWNLOADING.tmp, right after evil.bin.downloading was renamed to evil.bin.

Nothing in bolt-load builds that name:

  • the temp file is <dest>.downloading, lowercase and without .tmp;
  • async_fs::rename calls std::fs::rename (MoveFileExW) directly and creates no extra name;
  • this test uses the in-memory SimpleTestAdapter and starts no HTTP server;
  • tempfile names its files .tmp<random>.

So another process is suspected, such as an antivirus: Kaspersky runs on that machine. This is unconfirmed. Confirming it would need an AV exclusion or a Process Monitor trace.

What

  • Stronger checks. The test now verifies that evil.bin has the expected content (hash and length), that evil.bin.downloading is gone, and that nothing escaped to the parent directory.
  • A narrow filter. When it lists the directory, it ignores only evil.bin.downloading.tmp, case-insensitively, the one name that was observed. It does so only on Windows, and never as *.tmp. The rest must be exactly ["evil.bin"].
  • What the filter can hide: only the product writing that exact name on Windows, and the product never builds .tmp names. On every other platform no extra entry is allowed.
  • resource_changed.rs already checks only the product's own names, so it is unchanged.

Review

Reviewed with /ccg:review, using the codex backend only (a single-model review).

PASS (94/100). It confirmed that no product path builds the name, with async-fs 2.2.0 delegating to std::fs::rename and tempfile 3.27.0 naming files .tmp<random>. It also confirmed that the test stays meaningful and deterministic.

Both of its findings are applied:

  • Minor: the design note had said "test servers write no files", which is wrong. It now says this test starts no server, and it calls the cause suspected rather than identified.
  • Suggestion: the filter is narrowed to the observed name, on Windows only.

Checks

On +nightly-2026-11-06:

  • the test, run 30 times: 30 passed (2 of 30 failed before);
  • cargo fmt --all -- --check;
  • clippy, all features and all targets, with -D warnings;
  • bolt-load lib: 577 tests pass with all features, 546 with default features;
  • after the review edits: fmt, clippy and the test itself.

@greenhat616
greenhat616 added this pull request to stack #213 November 11, 2026 15:23
@greenhat616
greenhat616 removed this pull request from stack #213 November 11, 2026 15:24
@greenhat616
greenhat616 added this pull request to stack #190 November 11, 2026 15:24
@greenhat616
greenhat616 force-pushed the test/hardening-35-scanner-tmp branch from 986d025 to ff67c05 Compare November 13, 2026 07:44
@greenhat616
greenhat616 marked this pull request as draft November 13, 2026 08:55
… test

On one Windows machine the hostile filename test failed in 2 of 30
runs: next to evil.bin, just renamed from evil.bin.downloading, the
directory also held EVIL.BIN.DOWNLOADING.tmp. Nothing in bolt-load
builds that name, so another process, likely an antivirus, is
suspected but not confirmed. The test now checks evil.bin's content
and that the temporary file is gone, and on Windows ignores only that
observed name when it lists the directory; any other entry still fails
it.
@greenhat616
greenhat616 force-pushed the test/hardening-35-scanner-tmp branch from ff67c05 to b8fac9e Compare November 13, 2026 22:25
@greenhat616
greenhat616 removed this pull request from stack #190 November 13, 2026 22:28
@greenhat616
greenhat616 added this pull request to stack #215 November 13, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant