fix(anydoc): upgrade patched zip dependency to 9 (#4437)

main
lyingbug 2026-10-17 22:24:54 +08:00 committed by GitHub
parent 8776a2d92d
commit 345855b59c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 55 additions and 8 deletions

View File

@ -49,16 +49,20 @@ if [ -z "$anydoc_version" ]; then
exit 1
fi
# document_to_markdown is private in published anydoc. Copy the pinned version
# and re-export that one function so anydoc-go can keep the official serializer.
# Include a patch revision so changes to our patches invalidate existing copies
# even when the upstream anydoc version stays the same.
anydoc_patch_id="$anydoc_version-zip9-v1"
# Copy the pinned version, expose the official serializer, and upgrade zip to
# the fixed major version (upstream anydoc 0.2.4 still requires zip ^8.6.0).
prepare_patched_anydoc() {
local dest="$crate_dir/patched-anydoc"
# The marker records which version was patched: after a version bump the
# The marker records the upstream version and patch revision: after a bump the
# copy left by the previous build is the wrong crate, and reusing it would
# fail deep inside cargo's patch resolution instead of here. Cargo.toml is
# required too: a truncated leftover with only the marker would otherwise
# skip the copy and fail with "failed to read .../Cargo.toml".
if [ -f "$dest/.weknora-patched" ] && [ "$(cat "$dest/.weknora-patched")" = "$anydoc_version" ] && [ -f "$dest/Cargo.toml" ]; then
if [ -f "$dest/.weknora-patched" ] && [ "$(cat "$dest/.weknora-patched")" = "$anydoc_patch_id" ] && [ -f "$dest/Cargo.toml" ]; then
return
fi
@ -91,7 +95,24 @@ prepare_patched_anydoc() {
fi
sed -i.bak 's/^use render::markdown::document_to_markdown;/pub use render::markdown::document_to_markdown;/' "$dest/src/lib.rs"
rm -f "$dest/src/lib.rs.bak"
printf '%s\n' "$anydoc_version" > "$dest/.weknora-patched"
# RUSTSEC-2026-0367/0368/0369 have no fix in zip 8.x. Only change zip's
# version, preserving its deflate feature and disabled default features.
# Fail on upstream manifest changes rather than silently leaving zip unpatched.
if ! awk '
/^\[/ { in_zip = ($0 == "[dependencies.zip]") }
in_zip && /^version = / {
if ($0 != "version = \"8.6.0\"") exit 1
$0 = "version = \"9\""
patched++
}
{ print }
END { if (patched != 1) exit 1 }
' "$dest/Cargo.toml" > "$dest/Cargo.toml.tmp"; then
echo "error: anydoc $anydoc_version no longer has the expected zip 8.6.0 dependency" >&2
exit 1
fi
mv "$dest/Cargo.toml.tmp" "$dest/Cargo.toml"
printf '%s\n' "$anydoc_patch_id" > "$dest/.weknora-patched"
rm -rf "$crate_dir/.anydoc-unpack" "$crate_dir/.anydoc-$anydoc_version.crate"
}

23
third_party/anydoc-go/Cargo.lock generated vendored
View File

@ -206,6 +206,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cfg_aliases"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]]
name = "chacha20"
version = "0.10.2"
@ -773,6 +779,18 @@ dependencies = [
"simd-adler32",
]
[[package]]
name = "nix"
version = "0.31.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
dependencies = [
"bitflags 2.13.1",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]]
name = "nom"
version = "8.0.0"
@ -1431,14 +1449,15 @@ checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
[[package]]
name = "zip"
version = "8.6.0"
version = "9.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b"
checksum = "a954114b47a54df49f83d2722814e86b23d4bb1b54a1b90fb7d92b41619ddc22"
dependencies = [
"crc32fast",
"flate2",
"indexmap",
"memchr",
"nix",
"typed-path",
"zopfli",
]

View File

@ -27,6 +27,7 @@ cbindgen = "0.29"
# document_to_markdown is crate-private in published anydoc. The build script
# copies the pinned version above and re-exports that one function so we can
# keep the official GFM serializer after rewriting asset images to External URLs.
# It also raises anydoc's zip requirement to 9 for RUSTSEC-2026-0367/0368/0369.
[patch.crates-io]
anydoc = { path = "patched-anydoc" }

View File

@ -206,7 +206,13 @@ The 0.2.4 lockfile removes calamine and five exclusive dependencies, retains
([upstream fix](https://github.com/RustCrypto/stream-ciphers/pull/580)); other
transitive versions are retained.
`cargo audit` on 2026-09-29 reports no vulnerabilities and one allowed warning:
The local patch raises anydoc 0.2.4's `zip` requirement from `8.6.0` to `9`,
with `9.0.4` pinned in `Cargo.lock`. This fixes
`RUSTSEC-2026-0367`, `RUSTSEC-2026-0368`, and `RUSTSEC-2026-0369`; zip 8.x has
no patched release. The patch cache marker includes a revision so existing
`patched-anydoc/` copies are regenerated when the local patches change.
`cargo audit` on 2026-10-17 reports no vulnerabilities and one allowed warning:
`ttf-parser` 0.25.1 is
unmaintained (`RUSTSEC-2026-0192`), pulled in transitively by the PDF stack. It
is not a vulnerability and nothing here can fix it, so warnings report without