SHA256 from `PACKAGES` is not checked against the downloaded file
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
Look at package-cache.R lines 275-282 where sha256 is replaced, and packages-gz.R lines 466-470 where the race happens. The fix involves adding a hash check after download_one_of() returns, before accepting the file. Also ensure the SHA256sum: field is parsed correctly, stripping whitespace and newlines. Test by simulating a mismatch with a mock download source.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The sha256 that pkgdepends passes to async_copy_or_add() is never compared with the download. After download_one_of() returns, it is replaced by the hash of whatever arrived:
For CRAN macOS binaries, download_one_of() races the CRAN mirror against mac.cran.dev and keeps the first to finish, so a stale file on mac.cran.dev gets installed even if it does not match PACKAGES:
This is currently the case for adbcdrivermanager 0.24.0-3 on macOS with R 4.6. Since the zstd mix-up (r-lib/pkgdepends#485, r-lib/pak#915), the file on cran.rstudio.com is gzip again and matches PACKAGES (3b73522a…), while mac.cran.dev still serves the zstd file (2bd7d854…). Our CI got the mac.cran.dev copy and failed with "unknown archive type".
A check would also need the hash parsed correctly. The SHA256sum: field in CRAN's macOS PACKAGES is folded onto a continuation line. Base R's read.dcf() returns the bare hash, but the parsed value here keeps the line break and indentation:
pak::pkg_download(
"adbcdrivermanager",
dest_dir = tempfile(),
platforms = "aarch64-apple-darwin23",
r_versions = "4.6",
dependencies = FALSE
)$sha256
#> [1] "\n 3b73522a5d65d7dad8ddcbfed2045da6d61ae25458d3c973f55928d937166ed5"
Could a download that does not match the expected hash be rejected, so the other source is used instead? If that sounds reasonable, I'm happy to propose a PR.
- Lingua principale
- R
- Stelle
- 30
- Fork
- 19
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di r-lib/pkgcache
-
`pkgcache:::is_ppm_linux_repo_url()` does not recognize manylinux_2_28 as a valid binary distroAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
PPM and ARM images for LinuxAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
-
Improve extra CRAN metadataApertaupkeep
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di r-lib/pkgcache
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
hubverse-org/hubDevs#83 ·
-
data_bio2rarify - doc - dimensions wrongForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
leppott/BioMonTools#162 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
-
publications
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
epiforecasts/epiforecasts.github.io#161 ·
I maintainer di solito rispondono entro 1 giorno