SHA256 from `PACKAGES` is not checked against the downloaded file
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- R
- 星标
- 30
- 派生
- 19
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
r-lib/pkgcache 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 32/100
-
upkeep
难度 4/5 3-5 天 新手友好度 25/100
-
feature
难度 4/5 3-5 天 新手友好度 35/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
hubverse-org/hubDevs#83 ·
-
data_bio2rarify - doc - dimensions wrong可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
leppott/BioMonTools#162 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 78/100
-
publications
难度 1/5 1 小时以内 新手友好度 85/100
epiforecasts/epiforecasts.github.io#161 ·
维护者通常 1 天内回复