SHA256 from `PACKAGES` is not checked against the downloaded file
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 65/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- R
- Estrelas
- 30
- Forks
- 19
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de r-lib/pkgcache
-
`pkgcache:::is_ppm_linux_repo_url()` does not recognize manylinux_2_28 as a valid binary distroAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
-
PPM and ARM images for LinuxAberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 32/100
-
Improve extra CRAN metadataAbertaupkeep
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
-
feature
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
Todas as issues de r-lib/pkgcache
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
hubverse-org/hubDevs#83 ·
-
data_bio2rarify - doc - dimensions wrongTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
leppott/BioMonTools#162 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
r-lib/rig#535 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100