From e7773f0c81a2790e030cdf2151f29bfe03d6ff57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 15:15:07 +0000 Subject: [PATCH 1/2] Bump zip from 8.6.0 to 9.0.0 Bumps [zip](https://github.com/zip-rs/zip2) from 8.6.0 to 9.0.0. - [Release notes](https://github.com/zip-rs/zip2/releases) - [Changelog](https://github.com/zip-rs/zip2/blob/master/CHANGELOG.md) - [Commits](https://github.com/zip-rs/zip2/compare/v8.6.0...v9.0.0) --- updated-dependencies: - dependency-name: zip dependency-version: 9.0.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25d1f4b221..877182d128 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2089,7 +2089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" dependencies = [ "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2995,9 +2995,9 @@ dependencies = [ [[package]] name = "zip" -version = "8.6.0" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +checksum = "711e8c9646791c49b7eb799a19c4ae70a9b8372ddc6a1fa4778defd1e2aa5d5e" dependencies = [ "crc32fast", "flate2", diff --git a/Cargo.toml b/Cargo.toml index acbbe4672a..7471ca960f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ once_cell = "=1.21.3" rayon = "=1.12.0" tar = "=0.4.46" flate2 = "=1.1.9" -zip = { version = "=8.6.0", default-features = false, features = ["deflate"] } +zip = { version = "=9.0.0", default-features = false, features = ["deflate"] } fs2 = "=0.4.3" same-file = "=1.0.6" libc = "=0.2.182" From 58dfab1cd7051808a0954fcb3648b583c4b121ef Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Dec 2026 16:19:41 +0000 Subject: [PATCH 2/2] Read zip 9 entry names through the fallible API zip 9.0.0 makes ZipFile::name(), ZipArchive::file_names() and name_for_index() return a Result. The error comes only from decoding a non-UTF-8 name as CP437, and that branch cannot fail on real input, so each call site passes the error up the way it already reports an unreadable entry. A jar whose name cannot be decoded is still read raw, and counts as possibly signed so it gets the stricter checks. Tests unwrap. Assisted-by: Claude Code:claude-opus-5-5 --- .../tests/e2e_gradle_agent_build.rs | 2 +- .../tests/e2e_nuget_dotnet_build.rs | 2 +- .../tests/e2e_redirect_gradle_build.rs | 4 ++-- .../tests/gradle_agent_cli.rs | 4 ++-- .../tests/maven_build_common/mod.rs | 2 +- .../tests/maven_production/mod.rs | 2 +- .../tests/vendor/vendor_failure_paths.rs | 3 ++- .../tests/vex_pdm_hatch_common/mod.rs | 2 +- .../tests/vex_pipenv_pip_common/mod.rs | 2 +- .../src/hosted/wheel_record.rs | 1 + .../src/patch/jar_manifest.rs | 5 +++-- .../src/patch/jar_members.rs | 11 +++++++--- .../socket-patch-core/src/vendor/berry_zip.rs | 4 ++-- crates/socket-patch-core/src/vendor/pypi.rs | 3 ++- .../socket-patch-core/src/vendor/pypi_uv.rs | 2 +- .../src/vendor/registry_fetch.rs | 20 +++++++++++++++---- .../vendor/test_support/service_fixture.rs | 2 +- crates/socket-patch-core/src/vendor/verify.rs | 9 +++++---- 18 files changed, 51 insertions(+), 29 deletions(-) diff --git a/crates/socket-patch-cli/tests/e2e_gradle_agent_build.rs b/crates/socket-patch-cli/tests/e2e_gradle_agent_build.rs index ac8df42d47..8c84a4ef49 100644 --- a/crates/socket-patch-cli/tests/e2e_gradle_agent_build.rs +++ b/crates/socket-patch-cli/tests/e2e_gradle_agent_build.rs @@ -88,7 +88,7 @@ fn patch_jar(jar: &[u8]) -> Vec { let mut entry = archive.by_index(i).unwrap(); let mut buf = Vec::new(); entry.read_to_end(&mut buf).unwrap(); - let name = entry.name().to_string(); + let name = entry.name().unwrap().into_owned(); let buf = if name == NOTICE { patched_notice() } else if name == VICTIM_CLASS_MEMBER { diff --git a/crates/socket-patch-cli/tests/e2e_nuget_dotnet_build.rs b/crates/socket-patch-cli/tests/e2e_nuget_dotnet_build.rs index 548dbcd5a2..6318ffea47 100644 --- a/crates/socket-patch-cli/tests/e2e_nuget_dotnet_build.rs +++ b/crates/socket-patch-cli/tests/e2e_nuget_dotnet_build.rs @@ -333,7 +333,7 @@ fn patched_nupkg(upstream: &[u8], patched: &[u8]) -> Vec { let mut replaced = false; for i in 0..archive.len() { let mut f = archive.by_index(i).unwrap(); - let name = f.name().to_string(); + let name = f.name().unwrap().into_owned(); if name == ".signature.p7s" || f.is_dir() { continue; } diff --git a/crates/socket-patch-cli/tests/e2e_redirect_gradle_build.rs b/crates/socket-patch-cli/tests/e2e_redirect_gradle_build.rs index c3155708f1..c18a9b6af9 100644 --- a/crates/socket-patch-cli/tests/e2e_redirect_gradle_build.rs +++ b/crates/socket-patch-cli/tests/e2e_redirect_gradle_build.rs @@ -117,7 +117,7 @@ fn patched_jar() -> Vec { let mut entry = archive.by_index(i).unwrap(); let mut buf = Vec::new(); entry.read_to_end(&mut buf).unwrap(); - let name = entry.name().to_string(); + let name = entry.name().unwrap().into_owned(); let buf = if name == NOTICE { patched_notice() } else if name == VICTIM_CLASS_MEMBER { @@ -1543,7 +1543,7 @@ fn served_consumer() -> Served { let mut entry = archive.by_index(i).unwrap(); let mut buf = Vec::new(); entry.read_to_end(&mut buf).unwrap(); - members.push((entry.name().to_string(), buf)); + members.push((entry.name().unwrap().into_owned(), buf)); } members.push((CONSUMER_PATCHED_MEMBER.to_string(), b"patched\n".to_vec())); let upstream_pom = central_file(&repo_path(CONSUMER, CONSUMER_VERSION, None, "pom")); diff --git a/crates/socket-patch-cli/tests/gradle_agent_cli.rs b/crates/socket-patch-cli/tests/gradle_agent_cli.rs index 8bb9b2021b..677db97e83 100644 --- a/crates/socket-patch-cli/tests/gradle_agent_cli.rs +++ b/crates/socket-patch-cli/tests/gradle_agent_cli.rs @@ -83,7 +83,7 @@ fn service_jar() -> Vec { let mut entry = archive.by_index(i).unwrap(); let mut buf = Vec::new(); entry.read_to_end(&mut buf).unwrap(); - let name = entry.name().to_string(); + let name = entry.name().unwrap().into_owned(); let buf = if name == NOTICE { b"patched\n".to_vec() } else { @@ -1132,7 +1132,7 @@ fn tampered_service_jar_writes_nothing() { let mut entry = honest.by_index(i).unwrap(); let mut buf = Vec::new(); entry.read_to_end(&mut buf).unwrap(); - tampered.start_file(entry.name(), opts).unwrap(); + tampered.start_file(entry.name().unwrap(), opts).unwrap(); tampered.write_all(&buf).unwrap(); } if symlink_mode { diff --git a/crates/socket-patch-cli/tests/maven_build_common/mod.rs b/crates/socket-patch-cli/tests/maven_build_common/mod.rs index b60ca60260..4bb9a101d1 100644 --- a/crates/socket-patch-cli/tests/maven_build_common/mod.rs +++ b/crates/socket-patch-cli/tests/maven_build_common/mod.rs @@ -527,7 +527,7 @@ pub fn jar_with_member(jar: &[u8], name: &str, bytes: &[u8]) -> Vec { let mut replaced = false; for i in 0..archive.len() { let mut entry = archive.by_index(i).unwrap(); - let entry_name = entry.name().to_string(); + let entry_name = entry.name().unwrap().into_owned(); if entry.is_dir() { writer.add_directory(entry_name, opts).unwrap(); continue; diff --git a/crates/socket-patch-cli/tests/maven_production/mod.rs b/crates/socket-patch-cli/tests/maven_production/mod.rs index 48a15d037b..fd6a18d914 100644 --- a/crates/socket-patch-cli/tests/maven_production/mod.rs +++ b/crates/socket-patch-cli/tests/maven_production/mod.rs @@ -645,7 +645,7 @@ fn members(jar: &[u8], what: &str) -> BTreeMap> { } let mut bytes = Vec::new(); entry.read_to_end(&mut bytes).unwrap(); - out.insert(entry.name().to_string(), bytes); + out.insert(entry.name().unwrap().into_owned(), bytes); } out } diff --git a/crates/socket-patch-cli/tests/vendor/vendor_failure_paths.rs b/crates/socket-patch-cli/tests/vendor/vendor_failure_paths.rs index 936a04ae4d..944c758b6e 100644 --- a/crates/socket-patch-cli/tests/vendor/vendor_failure_paths.rs +++ b/crates/socket-patch-cli/tests/vendor/vendor_failure_paths.rs @@ -1253,7 +1253,8 @@ fn rezip(whl: &[u8]) -> Vec { let mut entry = src.by_index(i).unwrap(); let mut bytes = Vec::new(); entry.read_to_end(&mut bytes).unwrap(); - out.start_file(entry.name().to_string(), opts).unwrap(); + out.start_file(entry.name().unwrap().into_owned(), opts) + .unwrap(); out.write_all(&bytes).unwrap(); } let alt = out.finish().unwrap().into_inner(); diff --git a/crates/socket-patch-cli/tests/vex_pdm_hatch_common/mod.rs b/crates/socket-patch-cli/tests/vex_pdm_hatch_common/mod.rs index fecfd71b1e..7be12ca14a 100644 --- a/crates/socket-patch-cli/tests/vex_pdm_hatch_common/mod.rs +++ b/crates/socket-patch-cli/tests/vex_pdm_hatch_common/mod.rs @@ -932,7 +932,7 @@ pub fn tamper_wheel(cwd: &Path) { let mut saw_module = false; for i in 0..archive.len() { let mut member = archive.by_index(i).unwrap(); - let name = member.name().to_string(); + let name = member.name().unwrap().into_owned(); let mut bytes = Vec::new(); member.read_to_end(&mut bytes).unwrap(); if name == MODULE { diff --git a/crates/socket-patch-cli/tests/vex_pipenv_pip_common/mod.rs b/crates/socket-patch-cli/tests/vex_pipenv_pip_common/mod.rs index 524c44296a..abd612bd56 100644 --- a/crates/socket-patch-cli/tests/vex_pipenv_pip_common/mod.rs +++ b/crates/socket-patch-cli/tests/vex_pipenv_pip_common/mod.rs @@ -959,7 +959,7 @@ pub fn tamper_wheel(cwd: &Path) { let mut saw_module = false; for i in 0..archive.len() { let mut member = archive.by_index(i).unwrap(); - let name = member.name().to_string(); + let name = member.name().unwrap().into_owned(); let mut bytes = Vec::new(); member.read_to_end(&mut bytes).unwrap(); if name == MODULE { diff --git a/crates/socket-patch-core/src/hosted/wheel_record.rs b/crates/socket-patch-core/src/hosted/wheel_record.rs index 85ca03f76a..2ee8f9d896 100644 --- a/crates/socket-patch-core/src/hosted/wheel_record.rs +++ b/crates/socket-patch-core/src/hosted/wheel_record.rs @@ -69,6 +69,7 @@ fn parse_wheel_record(bytes: &[u8]) -> Option { let mut archive = zip::ZipArchive::new(std::io::Cursor::new(bytes)).ok()?; // The wheel's own dist-info sits at the root, never nested. let dist_info = archive.file_names().find_map(|name| { + let name = name.ok()?; let stem = name.strip_suffix("/RECORD")?; (stem.ends_with(".dist-info") && !stem.contains('/')).then(|| stem.to_string()) })?; diff --git a/crates/socket-patch-core/src/patch/jar_manifest.rs b/crates/socket-patch-core/src/patch/jar_manifest.rs index ab936952aa..ae12d1a318 100644 --- a/crates/socket-patch-core/src/patch/jar_manifest.rs +++ b/crates/socket-patch-core/src/patch/jar_manifest.rs @@ -487,7 +487,7 @@ pub(crate) mod fixture { let opts = zip::write::SimpleFileOptions::default(); for i in 0..zip.len() { let mut entry = zip.by_index(i).unwrap(); - let name = entry.name().to_string(); + let name = entry.name().unwrap().into_owned(); if name.ends_with('/') || !keep(&name) { continue; } @@ -628,7 +628,8 @@ mod tests { fn the_fixture_is_a_resigned_jar() { let names = |jar: &[u8]| -> Vec { let zip = zip::ZipArchive::new(std::io::Cursor::new(jar)).unwrap(); - let mut names: Vec = zip.file_names().map(str::to_string).collect(); + let mut names: Vec = + zip.file_names().map(|n| n.unwrap().into_owned()).collect(); names.retain(|n| n.starts_with("META-INF/") && !n.ends_with('/')); names.sort(); names diff --git a/crates/socket-patch-core/src/patch/jar_members.rs b/crates/socket-patch-core/src/patch/jar_members.rs index 4711e1f82f..f564e9f27c 100644 --- a/crates/socket-patch-core/src/patch/jar_members.rs +++ b/crates/socket-patch-core/src/patch/jar_members.rs @@ -216,7 +216,8 @@ impl Jar { mut each: impl FnMut(&[u8], usize), ) -> Result<(), JarError> { for index in 0..self.zip.len() { - let decoded = self.zip.name_for_index(index); + // A name the reader cannot decode is read raw below. + let decoded = self.zip.name_for_index(index).and_then(Result::ok); if let Some(name) = decoded.filter(|name| self.zip.index_for_name(name) == Some(index)) { if !name.ends_with('/') { @@ -291,7 +292,11 @@ impl Jar { /// Whether the jar holds a signature file (`META-INF/*.SF`, `.RSA`, /// `.DSA`, `.EC`). pub(crate) fn has_signature_file(&self) -> bool { - self.zip.file_names().any(crate::vendor::jvm::is_signature) + // A name the reader cannot decode counts as one: the signed jar's + // checks are the stricter path. + self.zip + .file_names() + .any(|name| name.map_or(true, |name| crate::vendor::jvm::is_signature(&name))) } /// Inflate the member `name` into `sink`, within the pass's budget. @@ -1030,7 +1035,7 @@ mod tests { let decoded: Vec = zip::ZipArchive::new(std::io::Cursor::new(&bytes)) .unwrap() .file_names() - .map(str::to_string) + .map(|n| n.unwrap().into_owned()) .collect(); assert!(!decoded.iter().any(|name| name == NAME), "{decoded:?}"); let mut jar = Jar::of_bytes(&bytes).unwrap(); diff --git a/crates/socket-patch-core/src/vendor/berry_zip.rs b/crates/socket-patch-core/src/vendor/berry_zip.rs index 0cd59e6268..f5e2bde63c 100644 --- a/crates/socket-patch-core/src/vendor/berry_zip.rs +++ b/crates/socket-patch-core/src/vendor/berry_zip.rs @@ -489,7 +489,7 @@ mod tests { let zip_bytes = rebuild_cache_zip(&tgz, "@scope/pkg").unwrap(); let mut zip = zip::ZipArchive::new(std::io::Cursor::new(zip_bytes)).unwrap(); let names: Vec = (0..zip.len()) - .map(|i| zip.by_index(i).unwrap().name().to_string()) + .map(|i| zip.by_index(i).unwrap().name().unwrap().into_owned()) .collect(); assert_eq!( names, @@ -508,7 +508,7 @@ mod tests { entry.compression(), zip::CompressionMethod::Stored, "{}: every entry stored (the c0)", - entry.name() + entry.name().unwrap() ); } } diff --git a/crates/socket-patch-core/src/vendor/pypi.rs b/crates/socket-patch-core/src/vendor/pypi.rs index 9e13a8d6be..343a07fbb2 100644 --- a/crates/socket-patch-core/src/vendor/pypi.rs +++ b/crates/socket-patch-core/src/vendor/pypi.rs @@ -12769,7 +12769,8 @@ wheels = [{url = "https://files.pythonhosted.org/six.whl", hash = "sha256:upstre let mut entry = src.by_index(i).unwrap(); let mut bytes = Vec::new(); entry.read_to_end(&mut bytes).unwrap(); - out.start_file(entry.name().to_string(), opts).unwrap(); + out.start_file(entry.name().unwrap().into_owned(), opts) + .unwrap(); out.write_all(&bytes).unwrap(); } let alt = out.finish().unwrap().into_inner(); diff --git a/crates/socket-patch-core/src/vendor/pypi_uv.rs b/crates/socket-patch-core/src/vendor/pypi_uv.rs index d9158c09b7..78425e70d6 100644 --- a/crates/socket-patch-core/src/vendor/pypi_uv.rs +++ b/crates/socket-patch-core/src/vendor/pypi_uv.rs @@ -2375,7 +2375,7 @@ pub(super) fn wheel_metadata_text(bytes: &[u8]) -> Option { let mut metadata_name: Option = None; for i in 0..archive.len() { let entry = archive.by_index(i).ok()?; - let name = entry.name(); + let name = entry.name().ok()?; // A wheel's metadata lives at `-.dist-info/METADATA`, one // level below the root — never nested inside another directory. if let Some(stem) = name.strip_suffix("/METADATA") { diff --git a/crates/socket-patch-core/src/vendor/registry_fetch.rs b/crates/socket-patch-core/src/vendor/registry_fetch.rs index cf9bd09696..d2e4af2938 100644 --- a/crates/socket-patch-core/src/vendor/registry_fetch.rs +++ b/crates/socket-patch-core/src/vendor/registry_fetch.rs @@ -451,7 +451,13 @@ fn plan_zip( if file.is_dir() { continue; } - let raw = PathBuf::from(file.name()); + let raw = match file.name() { + Ok(name) => PathBuf::from(name.as_ref()), + Err(e) => { + plan.header_refusal = Some((i, format!("unreadable zip entry name: {e}"))); + break; + } + }; let rel = if strip_first { match strip_first_component(&raw) { Some(rel) => rel, @@ -837,7 +843,10 @@ pub(crate) fn go_h1_of_zip(bytes: &[u8]) -> Result { if file.is_dir() { continue; // go module zips carry files only } - let name = file.name().to_string(); + let name = file + .name() + .map_err(|e| format!("unreadable module zip entry name: {e}"))? + .into_owned(); if name.contains('\n') { return Err("module zip entry name contains a newline".to_string()); } @@ -947,7 +956,10 @@ pub(crate) fn extract_zip_with_prefix_skipping( if file.is_dir() { continue; } - let name = file.name().to_string(); + let name = file + .name() + .map_err(|e| format!("unreadable module zip entry name: {e}"))? + .into_owned(); let Some(rel) = name.strip_prefix(prefix) else { return Err(format!( "module zip entry `{name}` lies outside `{prefix}` — refusing the artifact" @@ -2540,7 +2552,7 @@ mod tests { if file.is_dir() { continue; } - let name = file.name().to_string(); + let name = file.name().unwrap().into_owned(); // `tree_of` reads no mode off a non-Unix disk (it reports 0), // so the oracle expects none there either. let mode = if !cfg!(unix) { diff --git a/crates/socket-patch-core/src/vendor/test_support/service_fixture.rs b/crates/socket-patch-core/src/vendor/test_support/service_fixture.rs index 0893a9fb3a..ffc0e8b7c2 100644 --- a/crates/socket-patch-core/src/vendor/test_support/service_fixture.rs +++ b/crates/socket-patch-core/src/vendor/test_support/service_fixture.rs @@ -125,7 +125,7 @@ fn jar_members(jar: &[u8]) -> Result>, String> { } let mut bytes = Vec::new(); entry.read_to_end(&mut bytes).map_err(|e| e.to_string())?; - members.insert(entry.name().to_string(), bytes); + members.insert(entry.name().unwrap().into_owned(), bytes); } Ok(members) } diff --git a/crates/socket-patch-core/src/vendor/verify.rs b/crates/socket-patch-core/src/vendor/verify.rs index 93fdcd46b5..ecbd69eb92 100644 --- a/crates/socket-patch-core/src/vendor/verify.rs +++ b/crates/socket-patch-core/src/vendor/verify.rs @@ -937,11 +937,12 @@ fn read_zip_within( let mut entry = zip.by_index(i).map_err(|_| ZipError::Unreadable)?; if strict { let non_canonical = || ZipError::NonCanonical; - if entry.is_symlink() || entry.name().starts_with('/') { + let name = entry.name().map_err(|_| ZipError::Unreadable)?; + if entry.is_symlink() || name.starts_with('/') { return Err(non_canonical()); } - let key = crate::patch::package::canonical_member_key(entry.name()) - .ok_or_else(non_canonical)?; + let key = + crate::patch::package::canonical_member_key(&name).ok_or_else(non_canonical)?; // Directories share the key space: a dir `six.py/` next to a // file `SIX.py` collides on disk too. if !seen.insert(key) { @@ -966,7 +967,7 @@ fn read_zip_within( }; return Err(ZipError::TooLarge(budget.exceeded(unpacked))); } - let name = entry.name().to_string(); + let name = entry.name().map_err(|_| ZipError::Unreadable)?.into_owned(); let mut bytes = Vec::new(); // +1 so an entry that would exceed the remaining budget reads one // byte past it and is rejected, rather than truncating silently.