inside_the_archive.rs

crates/veilvoice-verify/tests/inside_the_archive.rs

veilvoice-verify · 498 lines · read the source here · or on GitHub

Roadmap item 164. Reading a release archive from the inside, checked against the list the release job actually writes.

Why this test exists

check::archive hashes every member of a .tar.gz or a .zip and compares the result against CONTENTS.sha256. Both ends of that comparison are produced by different code on different machines: the list by tools/release/contents.py, running on the publishing runner under Python's tarfile and zipfile; the hashes by two readers written here, running on whatever the reader downloaded to.

The failure that matters is not a crash. It is the two ends disagreeing quietly about a member's name -- a leading ./, a backslash, a path rebuilt from ustar's prefix field -- so that every file reads as MISSING and a perfectly sound release is refused. Or the same disagreement in the other direction, where a name lines up by accident and a file nobody published is passed over.

So nothing here is a stand-in. The archives are built by tar and by Python's zipfile, which is what built every archive this project has ever published; the list is written by the real generator; and the readers are the ones a download is checked with.

The names are the interesting part

Each release staged here carries a path long enough to force tar out of the plain header and into a L record or a pax header, a file in a subdirectory, and a dotfile. Those are the three shapes that have actually been got wrong, here and in the generator (see F-102).

Why it is allowed to skip

It needs Python and tar, for the reason release_manifest.rs gives at length: their absence is a fact about the machine rather than a defect in the release job, and the release workflow itself cannot be without them.

WHAT THIS FILE CONTAINS

498 lines defining 14 functions (0 public), 0 types and 2 constants. Everything below is read out of the source, so it cannot disagree with the code.

WHAT CALLS WHAT

The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
    n_repository["repository<br/>line 45"]
    n_python["python<br/>line 54"]
    n_have["have<br/>line 61"]
    n_room["room<br/>line 70"]
    n_stage["stage<br/>line 91"]
    n_generate["generate<br/>line 104"]
    n_agrees["agrees<br/>line 130"]
    n_spelling_this_tar_knows["spelling_this_tar_knows<br/>line 192"]
    n_a_tarball_holds_what_the_release_job_published["a_tarball_holds_what_the_release_job_<br/>published<br/>line 226"]
    n_a_zip_holds_what_the_release_job_published["a_zip_holds_what_the_release_job_<br/>published<br/>line 292"]
    n_a_changed_or_added_file_inside_the_archive_is_caught["a_changed_or_added_file_inside_the_<br/>archive_is_caught<br/>line 340"]
    n_a_file_taken_out_of_the_archive_is_reported["a_file_taken_out_of_the_archive_is_<br/>reported<br/>line 404"]
    n_an_archive_this_cannot_read_says_so["an_archive_this_cannot_read_says_so<br/>line 456"]
    n_rubbish_in_place_of_an_archive_is_refused["rubbish_in_place_of_an_archive_is_<br/>refused<br/>line 484"]
    n_a_changed_or_added_file_inside_the_archive_is_caught --> n_generate
    n_a_changed_or_added_file_inside_the_archive_is_caught --> n_have
    n_a_changed_or_added_file_inside_the_archive_is_caught --> n_python
    n_a_changed_or_added_file_inside_the_archive_is_caught --> n_room
    n_a_changed_or_added_file_inside_the_archive_is_caught --> n_stage
    n_a_file_taken_out_of_the_archive_is_reported --> n_generate
    n_a_file_taken_out_of_the_archive_is_reported --> n_have
    n_a_file_taken_out_of_the_archive_is_reported --> n_python
    n_a_file_taken_out_of_the_archive_is_reported --> n_room
    n_a_file_taken_out_of_the_archive_is_reported --> n_stage
    n_a_tarball_holds_what_the_release_job_published --> n_agrees
    n_a_tarball_holds_what_the_release_job_published --> n_generate
    n_a_tarball_holds_what_the_release_job_published --> n_have
    n_a_tarball_holds_what_the_release_job_published --> n_python
    n_a_tarball_holds_what_the_release_job_published --> n_room
    n_a_tarball_holds_what_the_release_job_published --> n_spelling_this_tar_knows
    n_a_tarball_holds_what_the_release_job_published --> n_stage
    n_a_zip_holds_what_the_release_job_published --> n_agrees
    n_a_zip_holds_what_the_release_job_published --> n_generate
    n_a_zip_holds_what_the_release_job_published --> n_python
    n_a_zip_holds_what_the_release_job_published --> n_room
    n_a_zip_holds_what_the_release_job_published --> n_stage
    n_an_archive_this_cannot_read_says_so --> n_room
    n_generate --> n_repository
    n_rubbish_in_place_of_an_archive_is_refused --> n_room
    click n_repository href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L45" "open the source"
    click n_python href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L54" "open the source"
    click n_have href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L61" "open the source"
    click n_room href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L70" "open the source"
    click n_stage href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L91" "open the source"
    click n_generate href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L104" "open the source"
    click n_agrees href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L130" "open the source"
    click n_spelling_this_tar_knows href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L192" "open the source"
    click n_a_tarball_holds_what_the_release_job_published href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L226" "open the source"
    click n_a_zip_holds_what_the_release_job_published href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L292" "open the source"
    click n_a_changed_or_added_file_inside_the_archive_is_caught href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L340" "open the source"
    click n_a_file_taken_out_of_the_archive_is_reported href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L404" "open the source"
    click n_an_archive_this_cannot_read_says_so href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L456" "open the source"
    click n_rubbish_in_place_of_an_archive_is_refused href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-verify/tests/inside_the_archive.rs#L484" "open the source"
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_repository,n_python,n_have,n_room,n_stage,n_generate,n_agrees,n_spelling_this_tar_knows,n_a_tarball_holds_what_the_release_job_published,n_a_zip_holds_what_the_release_job_published,n_a_changed_or_added_file_inside_the_archive_is_caught,n_a_file_taken_out_of_the_archive_is_reported,n_an_archive_this_cannot_read_says_so,n_rubbish_in_place_of_an_archive_is_refused helper
    subgraph chart_key ["Key"]
        direction LR
        key_helper["helper: private to this file"]
    end
    class key_helper helper

This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.

ITEMS

ItemLineDocumentation
repository fn45The repository root, from this test's own location.
python fn54A Python to run, if this machine has one.
have fn61Whether a program is on this machine at all.
room fn70Somewhere to build a release, removed by the caller.
LONG const87A path long enough that tar cannot fit it in a header's 100-byte name.
stage fn91Build one release directory, the shape the release job stages.
generate fn104Run the real generator over a staging directory.
agrees fn130Assert that an archive holds exactly what the generated list says it does.
SHAPES const181The three ways a tar writes a long name, and what each tar calls them.
spelling_this_tar_knows fn192Which spelling of a format this machine's tar will accept, if any.
a_tarball_holds_what_the_release_job_published fn226A gzipped tar, in each of the three ways tar writes a long name.
a_zip_holds_what_the_release_job_published fn292A zip, deflated and stored, read from its central directory.
a_changed_or_added_file_inside_the_archive_is_caught fn340A file changed inside the archive is named, and an added one is too.
a_file_taken_out_of_the_archive_is_reported fn404A published file missing from the archive is reported as missing.
an_archive_this_cannot_read_says_so fn456An archive this reader cannot open says so, rather than reporting nothing.
rubbish_in_place_of_an_archive_is_refused fn484A file that is not an archive at all is refused, not passed over.