Repository navigation
A6: ZIP archive screening - #2392
neuromechanist merged 12 commits into
Conversation
…nce' into feature/issue-2185-zip-reader
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2392Version: 🤖 Updated on each push. |
|
Merge gate (lead): head 14da31c. Every remote check passes after one rerun of integration shard 3, which failed in an unrelated compute end-to-end test (compute-user-e2e-cli: a webhook stand-in with no subscription). Review: round 1 panel, 2 important parser findings (entries hidden by an undercounted end record; a NaN size that could hang the inflater) and 5 more fixed; round 2 delta found 1 important (the directory must end at its end record), fixed in 05b48f7 and verified by the lead. The lead's mutation of the ZIP64 end-record size check survived, and the test added in 14da31c now catches it. Local entries outside the central directory, and local-versus-central names, are documented as out of scope with the reason. |
eab1533
into
feature/issue-2182-epic-pq-evidence
Part of #2367. Part of #2182.
Card A6 of the publication-queue plan: a
.zipis screened by its entry names, and small inner recordings in a format with a registered reader are read by that reader. Anything not read is reported under its inner format aszip:<ext>.What changed
shared/readers/zip.ts: the end record from the last page of the archive (the rest of the last 64 KiB, and a maximal comment, only when it is not there), ZIP64 locator and end record, then the central directory, capped at 4 MiB and 50,000 entries (partial,limitpast either). Split archives arepartial(unsupported-version); a missing or inconsistent end record ispartial(corrupt); an archive of unknown size ispartial(limit).scanPathsas<archive>!/<entry>; inner readers get the same path. The path rules' hits are folded to one finding per kind per archive, with the number of entries it stands for in the new optionalFinding.entries(a count, never a name).path-subject-labelstill fires.DecompressionStream("deflate-raw")(16 KiB of input at a time), only as far as the inner reader reads, and never past the declared size: more output than declared iscorrupt(the zip bomb case). Inflated bytes of all entries share the reader'smaxInflatedBytes.not-applicable, a nested.zip) counts aszip:<ext>; encrypted entries are counted so and make the archivepartial(encrypted). The archive iscompleteonly when every inner entry that was read was read completely (inner partial reasons, companion gaps, limits and time all carry through). A failed read of the archive itself is a failed read of the archive.formatCoverage, applied as if the archive's content sat undersourcedata/; macOS resource forks (__MACOSX/,._name) are screened by name and never read.ReaderResult.unscreened(new, optional):readRecordingsadds it tonotApplicable, which every caller already counts as unscreened, sozip:<ext>reachesunscreened_formatswith no caller change.ZIP_READER. The reader imports the registry only as types; the registry hands it its functions (ZipKit), so there is no module cycle and the inner registry excludes ZIP (one level of nesting).encrypted,corrupt,limit,time,unsupported-versionandcompanion-missingalready have their copy entries.Name=in[Subject Demographics]goes throughreadSubjectId, the rule SNIRFSubjectIDand EEGLABsubjectshare. A name-like word of letters only staysnirx-subject-name(identifier); other text with a name-like word in it (letters fused with digits, an underscore-joined participant and session code) is the new kindnirx-subject-freetext(review, with itsKIND_COPYentry); the BIDS label and short codes are nothing. Operator and experimenter fields keep their rule.scripts/dev/reader-fp-measure-remote.ts: fullhttps://keys (Zenodo content links), a name column, 429/503 back-off, and a total ofunscreenedinside files.Tests
test/readers-zip.test.ts(29 tests): Info-ZIP fixtures built from the repository's EDF fixtures (test/fixtures/zip/README.mdrecords commands, the throwaway password and SHA-256): inner EDF findings andzip:.xdf, nesting, ZIP64 (zip -fz), encrypted (zip -P), truncation, a crafted bomb (declares 1 KiB, inflates to 100 MiB). Archives a stock tool cannot make are written byte for byte in the test (methods, caps, split, 50,000 entries).test/identifier-fleet.test.ts: an archive's inner findings andzip:.xdfreach the record; nested and encrypted archives.Gates on the head:
bun run typecheckclean;bun run lint"Checked 209 files ... No fixes applied."; biome on every touched file clean;bun test test/readers-zip.test.ts test/identifier-fleet.test.ts test/readers-nirx.test.ts test/identifier-coverage-contract.test.ts test/identifier-screen-report.test.ts test/identifier-scan.test.ts test/readers-snirf.test.ts427 pass, 0 fail. Pure tier (before the merge of A9): 28,002 pass, 6 fail; 2 were registry lists inidentifier-coverage-contract.test.ts(fixed here), the other 4 also fail on the base (account-copy-parityagainst the local website checkout,git-annex-remoteUUID retry) or were load timeouts that pass alone (completion-argv-guard). Live tier not awaited (phase-PR gate).False-positive gate (owner rule): met under the lead's ruling
461 public archives from 254 records: 412 Zenodo EEG/MEG/iEEG/fNIRS/EMG dataset records (up to 3 zips each) and 49 OpenNeuro zips (ds001810 sourcedata, ds003702 derivatives), central directories read by HTTP range requests, nothing downloaded whole. 409 read (400 complete, 9 partial: 7
limit, 1corrupt, 1companion-missing); 52 refused by Zenodo with 429. Bytes per complete archive p50/p90/max: 46 KB / 189 KB / 3.3 MB. Rates are per 100 read archives, recomputed for the fold (one path finding per kind per archive) and with the NIRx record (3 archives) measured again after the NIRx fix..infName=(shapeA99_A9_A9_A+9); after the NIRx fix it isnirx-subject-freetext(review).image-or-document-file,tooling-debris,path-subject-label) are exempt from this reader's 5-per-100 review gate. They are the dataset-level path rules applied to entry names, now one finding per kind per archive, and their volume is handled by the batch acknowledgment.