Repository navigation
feat(aea,download): add random-access AEA and HTTP range readers - #1408
Merged
blacktop merged 4 commits intoNov 17, 2026
Merged
Conversation
Write and WriteRoot share one temp-file, sync and rename sequence. Write keeps operating on plain paths; WriteRoot runs the same steps confined to an os.Root the caller already holds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reader authenticates the root header and cluster header chain, then decrypts only the segments a ReadAt touches, with a bounded plaintext cache. The prologue parser, root validation and cluster walk are factored out of decrypt (readPrologue, validateRoot, walkSegments) and shared by both paths. ReadMetadata reads AEA metadata from an io.ReaderAt, and Metadata.SymmetricKey resolves an embedded or FCS-wrapped key. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An io.ReaderAt for sparse remote access: 64 KiB pages in an 8 MiB LRU, large reads sent as direct ranges of up to 4 MiB. Every response must be a 206 whose Content-Range, length and ETag match the request; a full-body 200 is rejected unread. Transport failures and 5xx, 429 and 408 responses are retried twice. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
FuzzNewReader feeds arbitrary archives to the prologue parser. FuzzWalkSegments authenticates a cluster header built from the fuzz input, so the segment bounds checks are exercised rather than stopped at the HMAC. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
|
||
| type osFS struct{} | ||
|
|
||
| func (osFS) Lstat(name string) (os.FileInfo, error) { return os.Lstat(name) } |
|
|
||
| func (osFS) Lstat(name string) (os.FileInfo, error) { return os.Lstat(name) } | ||
| func (osFS) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { | ||
| return os.OpenFile(name, flag, perm) |
| func (osFS) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { | ||
| return os.OpenFile(name, flag, perm) | ||
| } | ||
| func (osFS) Remove(name string) error { return os.Remove(name) } |
| return os.OpenFile(name, flag, perm) | ||
| } | ||
| func (osFS) Remove(name string) error { return os.Remove(name) } | ||
| func (osFS) Rename(oldname, newname string) error { return os.Rename(oldname, newname) } |
| return os.OpenFile(name, flag, perm) | ||
| } | ||
| func (osFS) Remove(name string) error { return os.Remove(name) } | ||
| func (osFS) Rename(oldname, newname string) error { return os.Rename(oldname, newname) } |
| } | ||
|
|
||
| func decrypt(in, out string, symmetricKey []byte) (string, error) { | ||
| f, err := os.Open(in) |
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.
Adds two random-access readers and one atomic-write helper. Nothing user-visible changes here; this is the groundwork for reading single files out of a remote filesystem image (discussed in #1375), which follows in #1409.
Three commits:
refactor(atomicfile):WriteRootwrites atomically inside anos.Root, sharing one implementation withWrite, whose behaviour is unchanged.feat(aea):aea.Reader, a random-accessio.ReaderAtover an AEA1 symmetric archive. It authenticates the root header and the cluster header chain, then decrypts only the segments that are read, with a plaintext cache capped at the existing 32 MiB decrypt budget. The prologue parser, root validation and cluster walk are factored out ofdecrypt(readPrologue,validateRoot,walkSegments) and shared by both paths. Also addsReadMetadata(io.ReaderAt, size), whichInfonow wraps, andMetadata.SymmetricKey, whichDecryptnow uses.feat(download):RangeReader, anio.ReaderAtover HTTP with 64 KiB pages in an 8 MiB LRU. Every response must be a 206 whoseContent-Range, length and ETag match the request; a full-body 200 is rejected unread. Transport failures and 5xx, 429 and 408 responses are retried twice.Notes for review:
aea.decryptbehaves as before but now runs through the shared helpers and reads withReadAtinstead ofSeek.aea.Readerdoes not verify unread segments or the archive padding. Everything it returns is authenticated.RangeReadersits beside theranger-based ZIP reader and does not replace it: that one never evicts and does not validate responses, and the ZIP path wants large sequential blocks.aea.Reader,RangeReaderandWriteRoothave no callers outside tests until feat(extract): read remote APFS files through HTTP ranges #1409.Testing
go build ./...andgo testforinternal/atomicfile,internal/download,pkg/aea,internal/commands/extractandcmd/ipsw/cmd/...pass on this branch.test(aea)commit):FuzzNewReaderover arbitrary archives, andFuzzWalkSegments, which authenticates a cluster header built from the fuzz input so the segment bounds checks are reached. Ran about 30 s and 40 s (85 thousand and 2.9 million executions) with no failures.pkg/aeadecrypt tests pass unchanged apart from one call site whose signature changed.Not run:
make fmtin full (gofmtandgo vetare clean on the changed files).AI Assistance
Planned and written by GPT 6.1 Sol + Claude Fable 5.2. Reviewed manually.
🤖 Generated with Claude Code