Skip to content

test(mem): pin "could not look" apart from "nothing there" in netstat - #16

Merged
h4x0r merged 1 commit into
mainfrom
fix/netstat-bootstrap-vs-empty
Aug 4, 2026
Merged

test(mem): pin "could not look" apart from "nothing there" in netstat#16
h4x0r merged 1 commit into
mainfrom
fix/netstat-bootstrap-vs-empty

Conversation

@h4x0r

@h4x0r h4x0r commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The question this settles

dispatch_windows_netstat_returns_ok fed a stub reader — an empty ISF over a
blank synthetic image — and asserted the call succeeds. It broke when
memf-windows went 0.3 → 0.4, and the tempting reading was that the library had
regressed.

It hadn't. memf-windows 0.4 draws exactly the distinction that matters, and
says so in the source:

// Fail loud on a failed bootstrap: an undetectable build or a build with no
// overlay must surface, never masquerade as an empty ("0 connections") result.
// Only a genuine per-object miss degrades to empty (below).

With no symbols over a blank image, the build number can't be determined, so no
_TCP_ENDPOINT overlay can be selected and nothing can be scanned. That is
"could not look", and an error is the right answer. The stale artifact was the
test's premise: it asserted success for a reader that models a failed bootstrap.

Why it matters beyond a red check

An examiner handed an empty connection table may reasonably conclude the
machine had no network connections
. That's a false finding when the truth
is that the scan never ran — the difference between a finding and a fabrication
in a report.

Both halves are pinned

Asserting only the error would leave the other half free to regress, so:

test asserts
netstat_surfaces_a_failed_bootstrap_as_an_error undeterminable build reaches the caller as an error naming the stage that could not run
netstat_reports_a_completed_but_empty_scan_as_a_row a scan that does run and finds nothing is not an error — it's the informational row, which must say why it's empty rather than merely being empty

One thing worth fixing upstream

The second test needed a provider a physical scan can actually traverse.
SyntheticPhysMem reports no ranges, and PhysicalMemoryProvider::total_size
derives from summing them — so it's zero, and any scan walks (0, 0) and
sees nothing. memf-core's public test builder therefore cannot exercise a scan
path at all.

Hence the local RangedMem wrapper that advertises an extent. memf-windows
carries an identical private wrapper for its own tests
— exporting a ranged
synthetic provider from memf-core::test_builders would let both drop it.

The build number itself comes from an NtBuildLab fragment written into the
image, exercising the symbol-free fallback rather than a crafted ISF.

Verification

  • cargo fmt --all -- --check — clean
  • cargo clippy --workspace --lib --bins -- -D warnings — clean
  • cargo test --workspace212 suites, 0 failures

`dispatch_windows_netstat_returns_ok` fed a stub reader -- empty ISF over a
blank synthetic image -- and asserted the call succeeds. It broke when
memf-windows went 0.3 -> 0.4, and the tempting reading was that the library
had regressed.

It had not. memf-windows 0.4 draws exactly the distinction that matters and
documents it:

    // Fail loud on a failed bootstrap: an undetectable build or a build with
    // no overlay must surface, never masquerade as an empty ("0 connections")
    // result. Only a genuine per-object miss degrades to empty (below).

With no symbols and a blank image the build number cannot be determined, so no
_TCP_ENDPOINT overlay can be chosen and nothing can be scanned. That is "could
not look", and an error is the correct answer. The stale artifact was the
test's premise: it asserted success for a reader that models a failed
bootstrap.

Why this matters beyond a red check: an examiner handed an empty connection
table may reasonably conclude the machine had no network connections. That is
a false finding when the truth is that the scan never ran, and it is the
difference between a finding and a fabrication in a report.

So the contract is now pinned from both sides, because asserting only the
error would leave the other half free to regress:

  * netstat_surfaces_a_failed_bootstrap_as_an_error - undeterminable build
    reaches the caller as an error naming the stage that could not run.
  * netstat_reports_a_completed_but_empty_scan_as_a_row - a scan that DOES run
    and finds nothing is not an error; it is the informational placeholder
    row, which must say why it is empty rather than merely being empty.

The second test needed a provider that a physical scan can traverse.
`SyntheticPhysMem` reports no ranges, and `PhysicalMemoryProvider::total_size`
derives from summing them, so it is zero and any scan walks `(0, 0)` and sees
nothing -- the public test builder cannot exercise a scan path at all. Hence
the local `RangedMem` wrapper, which advertises an extent. memf-windows
carries an identical private wrapper for its own tests; memf-core exporting
one would let both drop it.

The build number itself comes from an `NtBuildLab` fragment written into the
image, using the symbol-free fallback path rather than a crafted ISF.
@h4x0r
h4x0r merged commit abd4740 into main Aug 4, 2026
15 of 17 checks passed
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