diff --git a/Cargo.lock b/Cargo.lock index 751d4f04..a913c52d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -917,15 +917,6 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" -[[package]] -name = "arbitrary" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "arc-swap" version = "1.9.2" @@ -1531,7 +1522,7 @@ dependencies = [ "arrayvec", "cc", "cfg-if", - "constant_time_eq 0.4.2", + "constant_time_eq", "cpufeatures 0.3.1", ] @@ -1670,25 +1661,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bzip2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" -dependencies = [ - "bzip2-sys", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.13+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" -dependencies = [ - "cc", - "pkg-config", -] - [[package]] name = "c-kzg" version = "2.1.8" @@ -1949,12 +1921,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "constant_time_eq" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" - [[package]] name = "constant_time_eq" version = "0.4.2" @@ -2211,12 +2177,6 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" -[[package]] -name = "deflate64" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2" - [[package]] name = "defmt" version = "1.1.1" @@ -2307,17 +2267,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_arbitrary" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "derive_more" version = "2.1.1" @@ -2977,11 +2926,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", - "js-sys", "libc", "r-efi 5.3.0", "wasip2", - "wasm-bindgen", ] [[package]] @@ -3887,27 +3834,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" -[[package]] -name = "lzma-rs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" -dependencies = [ - "byteorder", - "crc", -] - -[[package]] -name = "lzma-sys" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "macro-string" version = "0.2.0" @@ -5218,9 +5144,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.45" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ "aws-lc-rs", "log", @@ -6625,6 +6551,12 @@ dependencies = [ "webrtc-util 0.12.0", ] +[[package]] +name = "typed-path" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e" + [[package]] name = "typenum" version = "1.20.1" @@ -7516,15 +7448,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "xz2" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" -dependencies = [ - "lzma-sys", -] - [[package]] name = "yasna" version = "0.5.2" @@ -7663,32 +7586,16 @@ dependencies = [ [[package]] name = "zip" -version = "2.4.2" +version = "9.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50" +checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e" dependencies = [ - "aes", - "arbitrary", - "bzip2", - "constant_time_eq 0.3.1", "crc32fast", - "crossbeam-utils", - "deflate64", - "displaydoc", "flate2", - "getrandom 0.3.4", - "hmac", "indexmap 2.14.1", - "lzma-rs", "memchr", - "pbkdf2", - "sha1", - "thiserror 2.0.20", - "time", - "xz2", - "zeroize", - "zopfli", - "zstd", + "nix 0.31.3", + "typed-path", ] [[package]] @@ -7702,43 +7609,3 @@ name = "zmij" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" - -[[package]] -name = "zopfli" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249" -dependencies = [ - "bumpalo", - "crc32fast", - "log", - "simd-adler32", -] - -[[package]] -name = "zstd" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "7.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.16+zstd.1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/Cargo.toml b/Cargo.toml index 0ba1d2cb..23ff68de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ serde_json = "1" # Archive extraction for auto-upgrade flate2 = "1" tar = "0.4" -zip = "2" +zip = { version = "9", default-features = false, features = ["deflate-flate2"] } # SHA-256 hashing for binary cache integrity sha2 = "0.10" diff --git a/src/upgrade/apply.rs b/src/upgrade/apply.rs index 88bdd8ee..a95f84f9 100644 --- a/src/upgrade/apply.rs +++ b/src/upgrade/apply.rs @@ -776,13 +776,22 @@ mod tests { /// Helper: create a zip archive containing a fake binary. fn create_zip_archive(dir: &Path, binary_name: &str, content: &[u8]) -> PathBuf { + create_zip_archive_with_method(dir, binary_name, content, zip::CompressionMethod::Stored) + } + + /// Helper: create a zip archive containing a fake binary compressed with `method`. + fn create_zip_archive_with_method( + dir: &Path, + binary_name: &str, + content: &[u8], + method: zip::CompressionMethod, + ) -> PathBuf { use std::io::Write; let archive_path = dir.join("test.zip"); let file = File::create(&archive_path).unwrap(); let mut zip_writer = zip::ZipWriter::new(file); - let options = zip::write::SimpleFileOptions::default() - .compression_method(zip::CompressionMethod::Stored); + let options = zip::write::SimpleFileOptions::default().compression_method(method); zip_writer.start_file(binary_name, options).unwrap(); zip_writer.write_all(content).unwrap(); zip_writer.finish().unwrap(); @@ -835,6 +844,33 @@ mod tests { assert_eq!(fs::read(&extracted).unwrap(), content); } + #[test] + fn test_extract_binary_from_deflated_zip() { + let dir = tempfile::tempdir().unwrap(); + let content = b"fake-deflated-binary-content".repeat(1024); + let archive = create_zip_archive_with_method( + dir.path(), + "ant-node", + &content, + zip::CompressionMethod::Deflated, + ); + + // Release zips use Deflate, so check the entry really is compressed. + { + let mut zip_archive = zip::ZipArchive::new(File::open(&archive).unwrap()).unwrap(); + let entry = zip_archive.by_index(0).unwrap(); + assert_eq!(entry.compression(), zip::CompressionMethod::Deflated); + assert!(entry.compressed_size() < entry.size()); + } + + let dest = tempfile::tempdir().unwrap(); + let result = AutoApplyUpgrader::extract_binary(&archive, dest.path()); + assert!(result.is_ok()); + + let extracted = result.unwrap(); + assert_eq!(fs::read(&extracted).unwrap(), content); + } + #[test] fn test_extract_binary_from_tar_gz_nested_path() { let dir = tempfile::tempdir().unwrap();