From 49224bf980bec46e4949519e89f8450fe40e792b Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Sat, 14 Dec 2024 23:07:19 -0500 Subject: [PATCH] Bump `zip` to maintained 2.0 versions The `zip` crate switched maintainers about a year ago. `ripunzip` is currently on the old crate which is on version 0.6.6. Luckily, bumping `zip` didn't involve any egregious code changes. The test suite still passes as well. --- Cargo.lock | 202 ++++++++++++++++++++++++++++++------------ Cargo.toml | 2 +- src/unzip/mod.rs | 24 +++-- test_utils/Cargo.toml | 2 +- test_utils/src/lib.rs | 8 +- 5 files changed, 167 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08edaf1..182d905 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -151,12 +151,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bitflags" version = "1.3.2" @@ -313,7 +307,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", ] [[package]] @@ -343,9 +337,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.1.5" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core-foundation" @@ -372,6 +366,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.4.2" @@ -482,6 +491,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "deflate64" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" + [[package]] name = "deranged" version = "0.3.11" @@ -499,7 +514,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", ] [[package]] @@ -513,6 +528,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "either" version = "1.13.0" @@ -674,7 +700,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", ] [[package]] @@ -1050,12 +1076,28 @@ dependencies = [ "rand_chacha", ] +[[package]] +name = "lockfree-object-pool" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" + [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[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 = "matchers" version = "0.1.0" @@ -1199,7 +1241,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", ] [[package]] @@ -1226,27 +1268,14 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core", - "subtle", -] - [[package]] name = "pbkdf2" -version = "0.11.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ "digest", "hmac", - "password-hash", - "sha2", ] [[package]] @@ -1324,9 +1353,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -1510,7 +1539,7 @@ dependencies = [ "ripunzip_test_utils", "tempfile", "test-log", - "thiserror", + "thiserror 1.0.63", "wildmatch", "zip", ] @@ -1639,7 +1668,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", ] [[package]] @@ -1677,17 +1706,6 @@ dependencies = [ "digest", ] -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -1703,6 +1721,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "slab" version = "0.4.9" @@ -1769,9 +1793,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -1846,7 +1870,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", ] [[package]] @@ -1864,7 +1888,16 @@ version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.63", +] + +[[package]] +name = "thiserror" +version = "2.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93605438cbd668185516ab499d589afb7ee1859ea3d5fc8f6b0755e1c7443767" +dependencies = [ + "thiserror-impl 2.0.7", ] [[package]] @@ -1875,7 +1908,18 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d8749b4531af2117677a5fcd12b1348a3fe2b81e36e61ffeac5c4aa3273e36" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -2145,7 +2189,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", "wasm-bindgen-shared", ] @@ -2179,7 +2223,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2413,45 +2457,87 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.90", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] name = "zip" -version = "0.6.6" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" dependencies = [ "aes", - "byteorder", + "arbitrary", "bzip2", "constant_time_eq", "crc32fast", "crossbeam-utils", + "deflate64", + "displaydoc", "flate2", "hmac", + "indexmap", + "lzma-rs", + "memchr", "pbkdf2", + "rand", "sha1", + "thiserror 2.0.7", "time", + "zeroize", + "zopfli", "zstd", ] +[[package]] +name = "zopfli" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +dependencies = [ + "bumpalo", + "crc32fast", + "lockfree-object-pool", + "log", + "once_cell", + "simd-adler32", +] + [[package]] name = "zstd" -version = "0.11.2+zstd.1.5.2" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ - "libc", "zstd-sys", ] diff --git a/Cargo.toml b/Cargo.toml index ccec41f..ba1a605 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ reqwest = { version = "0.11.13", features = ["blocking"] } tempfile = "3.3.0" thiserror = "1.0.37" wildmatch = "2.1.1" -zip = "0.6.3" +zip = "2.2" [dev-dependencies] hexdump = "0.1.1" diff --git a/src/unzip/mod.rs b/src/unzip/mod.rs index 8f16ef5..8b7fdd4 100644 --- a/src/unzip/mod.rs +++ b/src/unzip/mod.rs @@ -351,7 +351,7 @@ fn unzip_serial_or_parallel<'a, T: Read + Seek + 'a>( let myzip: &mut zip::ZipArchive = &mut get_ziparchive_clone(); let file: ZipFile = match &options.password { None => myzip.by_name(&name)?, - Some(string) => myzip.by_name_decrypt(&name, string.as_bytes())??, + Some(string) => myzip.by_name_decrypt(&name, string.as_bytes())?, }; let r = extract_file( file, @@ -379,7 +379,7 @@ fn extract_file_by_index<'a, T: Read + Seek + 'a>( let myzip: &mut zip::ZipArchive = &mut get_ziparchive_clone(); let file: ZipFile = match password { None => myzip.by_index(i)?, - Some(string) => myzip.by_index_decrypt(i, string.as_bytes())??, + Some(string) => myzip.by_index_decrypt(i, string.as_bytes())?, }; extract_file(file, output_directory, progress_reporter, directory_creator) } @@ -392,6 +392,7 @@ fn extract_file( ) -> Result<(), anyhow::Error> { let name = file .enclosed_name() + .as_deref() .map(Path::to_string_lossy) .unwrap_or_else(|| Cow::Borrowed("")) .to_string(); @@ -409,11 +410,11 @@ fn extract_file_inner( let name = file .enclosed_name() .ok_or_else(|| std::io::Error::new(ErrorKind::Unsupported, "path not safe to extract"))?; + let display_name = name.display().to_string(); let out_path = match output_directory { Some(output_directory) => output_directory.join(name), - None => PathBuf::from(name), + None => name, }; - let display_name = name.display().to_string(); progress_reporter.extraction_starting(&display_name); log::debug!( "Start extract of file at {:x}, length {:x}, name {}", @@ -504,7 +505,7 @@ mod tests { }; use tempfile::tempdir; use test_log::test; - use zip::unstable::write::FileOptionsExt; + use zip::{unstable::write::FileOptionsExt, write::ExtendedFileOptions}; use zip::{write::FileOptions, ZipWriter}; struct UnzipSomeFilter; @@ -537,7 +538,11 @@ mod tests { create_zip(file, include_a_txt, Some(options)) } - fn create_zip(w: impl Write + Seek, include_a_txt: bool, custom_options: Option) { + fn create_zip( + w: impl Write + Seek, + include_a_txt: bool, + custom_options: Option>, + ) { let mut zip = ZipWriter::new(w); let options = custom_options.unwrap_or_else(|| { FileOptions::default() @@ -545,13 +550,14 @@ mod tests { .unix_permissions(0o755) }); - zip.add_directory("test/", Default::default()).unwrap(); + zip.add_directory::<_, ExtendedFileOptions>("test/", Default::default()) + .unwrap(); if include_a_txt { - zip.start_file("test/a.txt", options).unwrap(); + zip.start_file("test/a.txt", options.clone()).unwrap(); zip.write_all(b"Contents of A\n").unwrap(); } - zip.start_file("b.txt", options).unwrap(); + zip.start_file("b.txt", options.clone()).unwrap(); zip.write_all(b"Contents of B\n").unwrap(); zip.start_file("test/c.txt", options).unwrap(); zip.write_all(b"Contents of C\n").unwrap(); diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index a6d391b..3c901ca 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -23,4 +23,4 @@ log = "0.4.17" once_cell = "1.16.0" regex = "1.7.0" strum = { version = "0.24", features = ["derive"] } -zip = "0.6.3" +zip = "2.2" diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 92514f8..02e2aaf 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -24,7 +24,10 @@ use httptest::{responders::*, Expectation, Server}; use once_cell::sync::Lazy; use regex::Regex; use strum::IntoEnumIterator; -use zip::{write::FileOptions, ZipWriter}; +use zip::{ + write::{ExtendedFileOptions, FileOptions}, + ZipWriter, +}; /// How to respond to a range-aware request. pub enum RangeAwareResponseType { @@ -282,7 +285,7 @@ fn file_generator(file_size: FileSize) -> impl FnMut() -> String { fn create_zip(w: impl Write + Seek, zip_params: &ZipParams) { let mut zip = ZipWriter::new(w); - let options = FileOptions::default() + let options = FileOptions::::default() .compression_method(zip_params.compression) .unix_permissions(0o755); @@ -299,6 +302,7 @@ fn create_zip(w: impl Write + Seek, zip_params: &ZipParams) { }; for i in 0..zip_params.num_files { + let options = options.clone(); zip.start_file(format!("{i}.txt"), options).unwrap(); zip.write_all(file_generator.next().unwrap()().as_bytes()) .unwrap();