Repository navigation
test(module): pin the loader's and archive extractor's refusal reasons - #108
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): test(module): pin the loader's and archive extractor's refusal reasons. The pull request titled "test(module): pin the loader's and archive extractor's refusal reasons" is a pure refactor plus test tightening. In `crates/tinybus/src/module/loader.rs`, the duplicated ABI descriptor prefix checks are consolidated into `gate_prefix`, called by both `load` and `gate_descriptor`, and the manifest null-pointer/cap/JSON checks move into a documented `unsafe fn manifest_from` with the 1 MiB limit named `MAX_MANIFEST_BYTES`. In `crates/tinybus/src/module/loader_tests.rs`, a `refusal` helper replaces `is_err()`, the descriptor gate test asserts specific messages, and two new tests pin each prefix and manifest refusal reason. In `crates/tinybus/src/module/github_tests.rs`, three zip extraction tests now assert "unsafe path" and "unsupported entry type" while keeping their filesystem post-condition checks. The author reports no behavior change; the description lane agrees the description matches the diff, noting the manifest function now runs unconditionally but that this was already the case for non-strict loads. No trusted check evidence in this review confirms test execution or passage, and no push delta could be established. Review snapshot
Completeness: Complete What changedIn `crates/tinybus/src/module/loader.rs`, the magic, revision, size-range, and minimum-size checks now exist once in `gate_prefix`, invoked by `load` on the prefix read through the symbol and by `gate_descriptor` on the full descriptor, same order and messages; the manifest null-pointer, cap, and JSON checks move into a documented `unsafe fn manifest_from` with the cap as `MAX_MANIFEST_BYTES`. In `crates/tinybus/src/module/loader_tests.rs`, a `refusal` helper replaces `is_err()`, the existing descriptor gate test asserts specific messages, and two new tests cover each prefix and manifest refusal reason including the boundary sizes. In `crates/tinybus/src/module/github_tests.rs`, three zip refusal tests now assert specific error text and keep verifying that offending files were not created. Features
Tests
FindingsNo active actionable findings. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
20c1716 to
9bf9e50
Compare
The ABI prefix checks were written twice, once in load and once in gate_descriptor, and the manifest-slice checks lived inline in load, so none of them could be tested without a real library. They move into gate_prefix and manifest_from, each reason gets a unit test, and the existing descriptor and zip refusal tests now assert which refusal they got instead of only that one happened.
9bf9e50 to
f392a3f
Compare
Summary
Mostly tests. The module loader's refusals were right but untested per reason, and several existing tests only checked that some error happened:
load, against the prefix read through the symbol, and again ingate_descriptor. Only the copy ingate_descriptorwas reachable from a test, and only two of its reasons were exercised, withis_err().load, so they needed a real dynamic library to test.zip_archives_refuse_paths_outside_the_destination,zip_archives_refuse_symlink_entriesandzip_archives_refuse_special_file_entriesassertedis_err(). Any failure, including an unreadable file, made them pass.Change
gate_prefix(path, magic, revision, size)holds the four prefix checks once;loadcalls it on the prefix andgate_descriptoron the full descriptor. Same order, same messages.manifest_from(path, slice)(anunsafe fnwith a documented contract) holds the null/cap/JSON checks; the 1 MiB cap is now the named constantMAX_MANIFEST_BYTES.the_descriptor_prefix_is_refused_for_each_reasonandthe_manifest_slice_is_refused_for_each_reasonassert each refusal message. The oversized case is refused before any byte is read, so the test needs no 1 MiB buffer.Validation
cargo test -p tinybus --features modules --lib -- module::loader:: zip_archives_refuse:gate_prefixthe_descriptor_prefix_is_refused_for_each_reasonFAILED (the loader accepted a wrong revision)Behaviour change
None. The checks, their order and their messages are unchanged; only where they are written moved.