Repository navigation
Commit 605c534
authored
fix: add support for sha512-only archives (#306)
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
-----
Attempted fix for #305.
Resolve digests through a small preference list (strongest first: `SHA512`, then `SHA256`) instead of hardcoding one field, and carry the hash kind alongside the digest so downloads are verified and cached with the matching algorithm. This covers:
- the Release index table (`Packages` digest),
- the per-package digest (the `.deb`), and
- the `Acquire-By-Hash` path merged from main, which now builds `by-hash/<algo>/<digest>` URLs from the resolved field rather than assuming `by-hash/SHA256/`.
Archives only guarantee a by-hash directory for the *strongest* hash they advertise, so the by-hash URL must be built from that one -- thanks @FinnRG for catching this. Since the preference list is strongest-first, the resolved field is already the right one, and a single ordering serves both purposes.
As of this writing Stonking publishes SHA512 only, in the base suite and in `-security`/`-updates` alike, so the whole suite resolves via SHA512. Resolute and earlier remain SHA256-only
An archive advertising *both* digests, content is now verified and cached under its SHA512 digest rather than its SHA256 one. Cache entries written by an older chisel are keyed by SHA256, so they go cold and are fetched once more, then expire normally (which, at the moment means they don't expire #261, but that's a separate issue). Nothing gets corrupted. Importantly, at present no archive Chisel targets advertises both digests (Resolute is `SHA256`-only, Stonking is `SHA512`-only), so in practice this is not a behaviour change.
### Testing
Added unit tests for the new behaviour and tested manually against the Stonking archive. The by-hash tests cover the four archive shapes: a by-hash directory for the strongest hash only, directories for several hashes (as Stonking actually publishes), a directory for a weaker hash only (a buggy archive, falls back to the named path), and no by-hash directories at all.
### Out of scope
Something i've deliberately decided is out of scope but really **should be fixed** in a followup: The manifest's per-package digest still reads `SHA256`, so on a SHA512-only archive it still errors. Most `chisel cut`'s still work unless the user requests the manifest to be cut too.1 parent 97c0d1d commit 605c534
5 files changed
Lines changed: 439 additions & 49 deletions
File tree
- internal
- archive
- testarchive
- cache
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
283 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
| |||
328 | 331 | | |
329 | 332 | | |
330 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
331 | 372 | | |
332 | | - | |
333 | 373 | | |
334 | | - | |
| 374 | + | |
335 | 375 | | |
336 | 376 | | |
337 | 377 | | |
| |||
345 | 385 | | |
346 | 386 | | |
347 | 387 | | |
348 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
349 | 393 | | |
350 | | - | |
351 | | - | |
| 394 | + | |
| 395 | + | |
352 | 396 | | |
353 | 397 | | |
354 | 398 | | |
| |||
358 | 402 | | |
359 | 403 | | |
360 | 404 | | |
361 | | - | |
| 405 | + | |
362 | 406 | | |
363 | 407 | | |
364 | 408 | | |
| |||
399 | 443 | | |
400 | 444 | | |
401 | 445 | | |
402 | | - | |
403 | | - | |
| 446 | + | |
404 | 447 | | |
405 | 448 | | |
406 | 449 | | |
| |||
0 commit comments