test(mem): pin "could not look" apart from "nothing there" in netstat - #16
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The question this settles
dispatch_windows_netstat_returns_okfed a stub reader — an empty ISF over ablank 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:
With no symbols over a blank image, the build number can't be determined, so no
_TCP_ENDPOINToverlay 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:
netstat_surfaces_a_failed_bootstrap_as_an_errornetstat_reports_a_completed_but_empty_scan_as_a_rowOne thing worth fixing upstream
The second test needed a provider a physical scan can actually traverse.
SyntheticPhysMemreports no ranges, andPhysicalMemoryProvider::total_sizederives from summing them — so it's zero, and any scan walks
(0, 0)andsees nothing. memf-core's public test builder therefore cannot exercise a scan
path at all.
Hence the local
RangedMemwrapper that advertises an extent. memf-windowscarries an identical private wrapper for its own tests — exporting a ranged
synthetic provider from
memf-core::test_builderswould let both drop it.The build number itself comes from an
NtBuildLabfragment written into theimage, exercising the symbol-free fallback rather than a crafted ISF.
Verification
cargo fmt --all -- --check— cleancargo clippy --workspace --lib --bins -- -D warnings— cleancargo test --workspace— 212 suites, 0 failures