diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df0038f9..27a324c2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -403,6 +403,11 @@ jobs: - name: Use specific dependency versions for Rust 1.70 compatibility. run: | cargo update --package=once_cell --precise=1.20.3 + # tempfile 3.27 pulled edition-2024 getrandom, which Cargo 1.70 can't parse. + cargo update --package=tempfile --precise=3.23.0 + # js-sys 0.3.72 has no `std` feature, and later versions require a + # wasm-bindgen newer than the Rust 1.70 resolver would otherwise pick. + cargo update --package=js-sys --precise=0.3.80 cargo update --package=uuid --precise=1.20.0 # Don't use --all-features because some of the features have dependencies @@ -421,7 +426,7 @@ jobs: - uses: ./.github/actions/install-rust with: toolchain: nightly - - run: cargo install cargo-fuzz --vers "^0.11" + - run: cargo install cargo-fuzz --version 0.13.2 --locked - run: cargo fetch working-directory: ./fuzz - run: cargo fuzz build --dev diff --git a/cap-primitives/src/fs/manually/open.rs b/cap-primitives/src/fs/manually/open.rs index 20a4b546..83129071 100644 --- a/cap-primitives/src/fs/manually/open.rs +++ b/cap-primitives/src/fs/manually/open.rs @@ -8,7 +8,6 @@ use crate::fs::{ }; #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))] use rustix::fs::OFlags; -use std::borrow::Cow; use std::ffi::OsStr; use std::path::{Component, Path, PathBuf}; use std::{fs, io, mem}; diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 7a6c3397..1730a223 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1426,111 +1426,15 @@ fn trailing_slash_symlink() { let sandbox = check!(tmpdir.open_dir("sandbox")); for path in ["hidden", "hidden/", "indirect", "indirect/"] { - error!( - sandbox.open_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.read_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.canonicalize(path), - "a path led outside of the filesystem" - ); - } -} - -/// Similar to `trailing_slash_symlink`, but populates the test directory -/// outside the sandbox, so it can cover more cases. -#[test] -fn trailing_slash_symlink_more() { - let tmpdir = tempfile::tempdir().unwrap(); - - check!(std::fs::create_dir(tmpdir.path().join("sandbox"))); - #[cfg(unix)] - { - check!(std::os::unix::fs::symlink( - "../outside", - tmpdir.path().join("sandbox/hidden") - )); - check!(std::os::unix::fs::symlink( - "hidden/", - tmpdir.path().join("sandbox/indirect") - )); - check!(std::os::unix::fs::symlink( - "/.", - tmpdir.path().join("sandbox/root_link") - )); - } - #[cfg(windows)] - { - check!(std::os::windows::fs::symlink_dir( - "../outside", - tmpdir.path().join("sandbox/hidden") - )); - check!(std::os::windows::fs::symlink_dir( - "hidden/", - tmpdir.path().join("sandbox/indirect") - )); - check!(std::os::windows::fs::symlink_dir( - "/.", - tmpdir.path().join("sandbox/root_link") - )); - } - #[cfg(not(any(unix, windows)))] - { - compile_error!("not implemented yet"); - } - - let tmpdir = check!(Dir::open_ambient_dir(tmpdir.path(), ambient_authority())); - - let sandbox = check!(tmpdir.open_dir("sandbox")); - - for path in [ - "hidden", - "hidden/", - "indirect", - "indirect/", - "root_link", - "root_link/", - ] { - error!( - sandbox.open_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.read_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.canonicalize(path), - "a path led outside of the filesystem" - ); - } -} - -/// Test interactions between symlinks and trailing slashes. -#[test] -fn trailing_slash_symlink() { - let tmpdir = tmpdir(); - - check!(tmpdir.create_dir("sandbox")); - check!(symlink_dir("../outside", &tmpdir, "sandbox/hidden")); - check!(symlink_dir("hidden/", &tmpdir, "sandbox/indirect")); - - let sandbox = check!(tmpdir.open_dir("sandbox")); - - for path in ["hidden", "hidden/", "indirect", "indirect/"] { - error!( + error_contains!( sandbox.open_dir(path), "a path led outside of the filesystem" ); - error!( + error_contains!( sandbox.read_dir(path), "a path led outside of the filesystem" ); - error!( + error_contains!( sandbox.canonicalize(path), "a path led outside of the filesystem" ); @@ -1591,15 +1495,15 @@ fn trailing_slash_symlink_more() { "root_link", "root_link/", ] { - error!( + error_contains!( sandbox.open_dir(path), "a path led outside of the filesystem" ); - error!( + error_contains!( sandbox.read_dir(path), "a path led outside of the filesystem" ); - error!( + error_contains!( sandbox.canonicalize(path), "a path led outside of the filesystem" );