From 9a187c87a0bf658d2f7da6b83c784ddfe9c5b459 Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Wed, 18 Nov 2026 18:42:18 +0000 Subject: [PATCH 1/6] ci: nightly Windows run of the bashkit test suites Windows-only path bugs (#2425, #2933) are invisible to Linux CI and fuzzing. New windows-nightly workflow runs the bashkit lib, integration and proptest security suites on windows-latest; it also trial-runs on PRs that edit it. A proptest feeds random path-heavy scripts through testing::CheckedFs and fails on any host-separator path; named windows_containment_* so the PR Windows job runs it too. --- .github/workflows/windows-nightly.yml | 58 +++++++++++++++ .../tests/integration/vfs_separator_tests.rs | 70 +++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 .github/workflows/windows-nightly.yml diff --git a/.github/workflows/windows-nightly.yml b/.github/workflows/windows-nightly.yml new file mode 100644 index 000000000..2790146ee --- /dev/null +++ b/.github/workflows/windows-nightly.yml @@ -0,0 +1,58 @@ +# Decision: bashkit's VFS is `/`-separated on every host (TM-ESC-033), but +# Windows-only path bugs (#2425, #2933) are invisible to Linux CI and to the +# Linux fuzzers, because the Linux host separator already is `/`. PR CI runs +# only targeted Windows filters (`windows_containment`, adoption suites) to +# stay fast. This nightly job runs the bashkit lib and integration suites and +# the proptest security suite on windows-latest, so the rest of the code is +# exercised there too. Tests that compare against host Unix tools (bash, GNU +# coreutils, jq, rg, sqlite3) skip their oracle step off unix. +# +# It also runs on PRs that edit this file, so a change here is trial-run +# before it lands. +name: Windows nightly + +on: + schedule: + # 5 AM UTC daily (after nightly at 4 AM) + - cron: '0 5 * * *' + workflow_dispatch: + pull_request: + paths: + - .github/workflows/windows-nightly.yml + +permissions: + contents: read + +concurrency: + group: windows-nightly-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + windows-tests: + name: Windows full test suite + runs-on: windows-latest + timeout-minutes: 120 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@9522411a9bce8484da960823fc2f46e52f981f71 # 1.100.0 + + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 + with: + shared-key: windows-nightly + + - name: Library tests + run: cargo test -p bashkit --lib --features http_client,realfs + + - name: Integration tests + run: cargo test -p bashkit --test integration --features http_client,realfs + + - name: Property-based security tests + run: cargo test -p bashkit --test proptest_security -- --test-threads=1 diff --git a/crates/bashkit/tests/integration/vfs_separator_tests.rs b/crates/bashkit/tests/integration/vfs_separator_tests.rs index 419bb6699..2748cd53b 100644 --- a/crates/bashkit/tests/integration/vfs_separator_tests.rs +++ b/crates/bashkit/tests/integration/vfs_separator_tests.rs @@ -57,3 +57,73 @@ async fn windows_containment_readlink_f_walks_slash_paths() { ); fs.assert_slash_only("readlink -f"); } + +mod random_scripts { + //! Random path-heavy scripts through `CheckedFs`. On Linux this only + //! proves the harness; on the Windows runners (PR `windows_containment` + //! filter, nightly full suite) any `\`-joined path fails it. + + use super::*; + use proptest::prelude::*; + + fn path() -> impl Strategy { + ( + any::(), + prop::collection::vec(prop::sample::select(vec!["a", "b", "c", ".", ".."]), 1..5), + ) + .prop_map(|(abs, segs)| { + let p = segs.join("/"); + if abs { format!("/{p}") } else { p } + }) + } + + fn command() -> impl Strategy { + ( + prop::sample::select(vec![ + "mkdir -p {p}", + "touch {p}", + "cd {p}", + "cat {p}", + "ls -R {p}", + "find {p}", + "du {p}", + "grep -r x {p}", + "cp -r {p} {q}", + "mv {p} {q}", + "rm -rf {p}", + "realpath {p}", + "readlink -f {p}", + "ln -s {p} {q}", + "echo x > {p}", + "echo x >> {p}", + "wc -l {p}", + "tar -cf {q}.tar {p}", + "echo x > /dev/stderr", + "echo x > /dev/fd/1", + ]), + path(), + path(), + ) + .prop_map(|(tpl, p, q)| tpl.replace("{p}", &p).replace("{q}", &q)) + } + + proptest! { + #![proptest_config(ProptestConfig::with_cases(64))] + + #[test] + fn windows_containment_random_path_scripts_stay_slash_only( + cmds in prop::collection::vec(command(), 1..8) + ) { + let script = format!("mkdir -p /a/b/c; cd /a; {}", cmds.join("; ")); + let rt = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); + let fs = Arc::new(CheckedFs::new()); + let mut bash = Bash::builder().fs(fs.clone()).build(); + let _ = rt.block_on(bash.exec(&script)); + let bad = fs.separator_violations(); + prop_assert!(bad.is_empty(), "script `{}` sent host-separator paths: {:?}", script, bad); + } + } +} From a4ad27ab74683a941967b38e2a4d90fb2c82bbbd Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Wed, 18 Nov 2026 19:01:31 +0000 Subject: [PATCH 2/6] fix(vfs): make the bashkit suites pass on Windows - has_root() instead of is_absolute() for VFS paths; clippy bans is_absolute - EBADF on closed fd reports 'Bad file descriptor' on every host - custom_fs/grep tests build VFS paths with vfs_join - .gitattributes forces LF checkout (CRLF broke skill/workflow fixtures) - spec runner: skip_windows directive; ls backslash case is L-FS-005 - host-tool oracle and Unix process-harness tests ignored off unix --- .gitattributes | 7 ++ crates/bashkit/clippy.toml | 4 +- crates/bashkit/src/builtins/archive.rs | 1 - crates/bashkit/src/builtins/cat.rs | 4 +- crates/bashkit/src/builtins/git/client.rs | 2 +- crates/bashkit/src/builtins/grep.rs | 2 +- crates/bashkit/src/builtins/mod.rs | 2 +- crates/bashkit/src/builtins/path.rs | 2 +- crates/bashkit/src/builtins/python.rs | 2 +- crates/bashkit/src/builtins/rg/mod.rs | 4 +- crates/bashkit/src/builtins/shuf.rs | 4 +- crates/bashkit/src/builtins/sqlite/mod.rs | 6 +- crates/bashkit/src/builtins/test.rs | 2 +- crates/bashkit/src/builtins/textrev.rs | 4 +- crates/bashkit/src/builtins/typescript.rs | 2 +- crates/bashkit/src/command.rs | 4 +- crates/bashkit/src/execution.rs | 4 +- crates/bashkit/src/interpreter/mod.rs | 4 +- .../tests/integration/archive_bzip2_tests.rs | 1 + .../integration/arithmetic_resource_tests.rs | 2 + .../tests/integration/backtick_quote_tests.rs | 1 + .../integration/blackbox_security_tests.rs | 1 + .../tests/integration/byte_stream_tests.rs | 1 + .../competitor_regression_tests.rs | 1 + .../integration/curl_data_compat_tests.rs | 1 + .../tests/integration/custom_fs_tests.rs | 21 +--- .../integration/execution_budget_tests.rs | 2 + .../tests/integration/fmt_resource_tests.rs | 1 + .../function_metadata_security_tests.rs | 1 + .../grep_recursive_security_tests.rs | 5 +- .../integration/indirect_reference_tests.rs | 2 + crates/bashkit/tests/integration/main.rs | 5 +- .../tests/integration/partial_parse_tests.rs | 1 + .../integration/pipeline_admission_tests.rs | 1 + .../tests/integration/pr_resource_tests.rs | 1 + .../bashkit/tests/integration/spec_runner.rs | 9 ++ .../bashkit/tests/integration/spec_tests.rs | 1 + .../integration/streaming_audit_tests.rs | 2 + .../tar_files_from_budget_tests.rs | 1 + .../tests/integration/threat_model_tests.rs | 112 ++++++++++++++++++ .../tests/integration/time_command_tests.rs | 1 + .../bashkit/tests/spec_cases/bash/ls.test.sh | 1 + knowledge/operations/limitations.md | 1 + 43 files changed, 191 insertions(+), 45 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..87ab218cc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# Decision: check out LF on every host. Tests parse shell fixtures, spec cases, +# workflow files and snapshot payloads byte for byte, and a Windows checkout +# with core.autocrlf rewrote them to CRLF (found by the Windows nightly). +* text=auto eol=lf + +# Snapshot fixtures are byte-exact binary formats; never convert them. +crates/bashkit/tests/fixtures/snapshots/** binary diff --git a/crates/bashkit/clippy.toml b/crates/bashkit/clippy.toml index 73e22c279..0ea175d7b 100644 --- a/crates/bashkit/clippy.toml +++ b/crates/bashkit/clippy.toml @@ -3,7 +3,8 @@ # turn `/a` + `b` into `/a\b`. That broke `/dev/stderr` redirects (#2933) and # printed mixed separators (#2425); Linux CI and fuzzing cannot see it because # the host separator there is already `/`. Build VFS paths with -# `crate::fs::vfs_join` instead. Code that really handles host paths (RealFs, +# `crate::fs::vfs_join` instead, and ask `has_root()`, not `is_absolute()`, +# whether a VFS path is absolute. Code that really handles host paths (RealFs, # host mounts, test temp dirs) opts out with a scoped # `#[allow(clippy::disallowed_methods)]` and a reason. disallowed-methods = [ @@ -11,4 +12,5 @@ disallowed-methods = [ { path = "std::path::PathBuf::push", reason = "joins with the host separator (`\\` on Windows); use crate::fs::vfs_join for VFS paths" }, { path = "std::path::PathBuf::set_file_name", reason = "joins with the host separator (`\\` on Windows); build VFS paths with crate::fs::vfs_join" }, { path = "std::path::Path::with_file_name", reason = "joins with the host separator (`\\` on Windows); build VFS paths with crate::fs::vfs_join" }, + { path = "std::path::Path::is_absolute", reason = "false for `/etc/x` on Windows (no drive prefix); VFS paths ask `has_root()`" }, ] diff --git a/crates/bashkit/src/builtins/archive.rs b/crates/bashkit/src/builtins/archive.rs index c9746e0ac..7eca1fc66 100644 --- a/crates/bashkit/src/builtins/archive.rs +++ b/crates/bashkit/src/builtins/archive.rs @@ -905,7 +905,6 @@ fn validate_tar_for_extraction( // and this arm never fired (issue #2425's class). The // `starts_with(extract_base)` arm below still blocked the write. if entry.has_root() - || entry.is_absolute() || entry .components() .any(|component| matches!(component, std::path::Component::ParentDir)) diff --git a/crates/bashkit/src/builtins/cat.rs b/crates/bashkit/src/builtins/cat.rs index deeb2752c..0dfd37fd5 100644 --- a/crates/bashkit/src/builtins/cat.rs +++ b/crates/bashkit/src/builtins/cat.rs @@ -89,7 +89,7 @@ impl Builtin for Cat { raw.try_extend_from_slice(&input.read_to_end().await?)?; } } else { - let path = if Path::new(file).is_absolute() { + let path = if Path::new(file).has_root() { file.clone() } else { vfs_join(ctx.cwd, file).to_string_lossy().into_owned() @@ -166,7 +166,7 @@ async fn stream_plain( } ok } else { - let path = if Path::new(file).is_absolute() { + let path = if Path::new(file).has_root() { file.clone() } else { vfs_join(ctx.cwd, file).to_string_lossy().into_owned() diff --git a/crates/bashkit/src/builtins/git/client.rs b/crates/bashkit/src/builtins/git/client.rs index 6f7cfee90..7f534baab 100644 --- a/crates/bashkit/src/builtins/git/client.rs +++ b/crates/bashkit/src/builtins/git/client.rs @@ -324,7 +324,7 @@ impl GitClient { // Add files for path_str in paths { - let path = if Path::new(path_str).is_absolute() { + let path = if Path::new(path_str).has_root() { PathBuf::from(path_str) } else { vfs_join(repo_path, path_str) diff --git a/crates/bashkit/src/builtins/grep.rs b/crates/bashkit/src/builtins/grep.rs index 7b8e40fb6..baca22d3b 100644 --- a/crates/bashkit/src/builtins/grep.rs +++ b/crates/bashkit/src/builtins/grep.rs @@ -1587,7 +1587,7 @@ async fn try_indexed_search( let mut path_leases = budgeted_vec(ctx)?; for m in &results.matches { ctx.consume_budget_work(1)?; - let candidate = if m.path.is_absolute() { + let candidate = if m.path.has_root() { crate::fs::normalize_path(&m.path) } else { crate::fs::normalize_path(&vfs_join(root, &m.path)) diff --git a/crates/bashkit/src/builtins/mod.rs b/crates/bashkit/src/builtins/mod.rs index c2dace0f8..4e6d3d66b 100644 --- a/crates/bashkit/src/builtins/mod.rs +++ b/crates/bashkit/src/builtins/mod.rs @@ -911,7 +911,7 @@ pub enum ExecutionPlan { /// ``` pub fn resolve_path(cwd: &Path, path_str: &str) -> PathBuf { let path = Path::new(path_str); - let joined = if path.is_absolute() { + let joined = if path.has_root() { path.to_path_buf() } else { vfs_join(cwd, path) diff --git a/crates/bashkit/src/builtins/path.rs b/crates/bashkit/src/builtins/path.rs index a5d5a5f18..965226ebd 100644 --- a/crates/bashkit/src/builtins/path.rs +++ b/crates/bashkit/src/builtins/path.rs @@ -514,7 +514,7 @@ async fn follow_readlink_symlinks( return None; } let link_parent = current.parent().unwrap_or_else(|| Path::new("/")); - let mut next = if target.is_absolute() { + let mut next = if target.has_root() { target } else { vfs_join(link_parent, target) diff --git a/crates/bashkit/src/builtins/python.rs b/crates/bashkit/src/builtins/python.rs index f3c4f7ca4..9c6edd15c 100644 --- a/crates/bashkit/src/builtins/python.rs +++ b/crates/bashkit/src/builtins/python.rs @@ -1001,7 +1001,7 @@ async fn open_vfs_file(path: &Path, mode: FileMode, fs: &Arc) -> /// Resolve a Python path string against cwd if relative. fn resolve_python_path(path_str: &str, cwd: &Path) -> PathBuf { let p = Path::new(path_str); - if p.is_absolute() { + if p.has_root() { p.to_owned() } else { vfs_join(cwd, p) diff --git a/crates/bashkit/src/builtins/rg/mod.rs b/crates/bashkit/src/builtins/rg/mod.rs index bfc1118f7..d92117b95 100644 --- a/crates/bashkit/src/builtins/rg/mod.rs +++ b/crates/bashkit/src/builtins/rg/mod.rs @@ -3704,7 +3704,7 @@ async fn resolve_rg_symlink_target( containment_root: &Path, ) -> Option<(PathBuf, crate::fs::Metadata)> { let target = fs.read_link(link_path).await.ok()?; - let resolved = if target.is_absolute() { + let resolved = if target.has_root() { crate::fs::normalize_path(&target) } else { crate::fs::normalize_path(&vfs_join( @@ -4219,7 +4219,7 @@ async fn try_indexed_search( let mut ignore: Option> = None; let uses_ignore = opts.uses_ignore_files() && !explicit_file_root; for m in &results.matches { - let candidate = if m.path.is_absolute() { + let candidate = if m.path.has_root() { crate::fs::normalize_path(&m.path) } else { crate::fs::normalize_path(&vfs_join(&root, &m.path)) diff --git a/crates/bashkit/src/builtins/shuf.rs b/crates/bashkit/src/builtins/shuf.rs index c3d54bd2d..f50a52d09 100644 --- a/crates/bashkit/src/builtins/shuf.rs +++ b/crates/bashkit/src/builtins/shuf.rs @@ -94,7 +94,7 @@ impl Builtin for Shuf { None => ctx.stdin.map(ToString::to_string).unwrap_or_default(), Some(s) if s == "-" => ctx.stdin.map(ToString::to_string).unwrap_or_default(), Some(file) => { - let path = if Path::new(file).is_absolute() { + let path = if Path::new(file).has_root() { file.clone() } else { vfs_join(ctx.cwd, file).to_string_lossy().into_owned() @@ -122,7 +122,7 @@ impl Builtin for Shuf { }; if let Some(path) = output_path { - let resolved = if path.is_absolute() { + let resolved = if path.has_root() { path.clone() } else { vfs_join(ctx.cwd, &path) diff --git a/crates/bashkit/src/builtins/sqlite/mod.rs b/crates/bashkit/src/builtins/sqlite/mod.rs index a32a09b8f..a137de556 100644 --- a/crates/bashkit/src/builtins/sqlite/mod.rs +++ b/crates/bashkit/src/builtins/sqlite/mod.rs @@ -840,11 +840,7 @@ async fn run_statements( Ok(DotOutcome::Configured) => {} Ok(DotOutcome::Quit) => return Ok(()), Ok(DotOutcome::Read(p)) => { - let abs = if p.is_absolute() { - p - } else { - vfs_join(cwd, &p) - }; + let abs = if p.has_root() { p } else { vfs_join(cwd, &p) }; let bytes = fs .read_file(&abs) .await diff --git a/crates/bashkit/src/builtins/test.rs b/crates/bashkit/src/builtins/test.rs index aff001f17..d9703b0cf 100644 --- a/crates/bashkit/src/builtins/test.rs +++ b/crates/bashkit/src/builtins/test.rs @@ -96,7 +96,7 @@ impl Builtin for Bracket { /// Resolve a file path against cwd (relative paths become absolute) fn resolve_file_path(cwd: &Path, arg: &str) -> PathBuf { let p = Path::new(arg); - if p.is_absolute() { + if p.has_root() { p.to_path_buf() } else { vfs_join(cwd, p) diff --git a/crates/bashkit/src/builtins/textrev.rs b/crates/bashkit/src/builtins/textrev.rs index 0571b2379..df29e1d00 100644 --- a/crates/bashkit/src/builtins/textrev.rs +++ b/crates/bashkit/src/builtins/textrev.rs @@ -38,7 +38,7 @@ async fn read_input(ctx: &Context<'_>) -> std::result::Result Option { match args.first()? { Value::String(s) => { let p = Path::new(s.as_ref()); - if p.is_absolute() { + if p.has_root() { Some(p.to_owned()) } else { Some(vfs_join(cwd, p)) diff --git a/crates/bashkit/src/command.rs b/crates/bashkit/src/command.rs index 904feb0be..09143bc7f 100644 --- a/crates/bashkit/src/command.rs +++ b/crates/bashkit/src/command.rs @@ -193,7 +193,9 @@ impl CommandOutput { .await??; } Destination::Discard => {} - Destination::Closed => return Err(std::io::Error::from_raw_os_error(9).into()), + // Fixed text, not `from_raw_os_error(9)`: errno 9 is EBADF only on + // unix (Windows renders a host message), and bash prints no errno. + Destination::Closed => return Err(std::io::Error::other("Bad file descriptor").into()), Destination::Pipe(pipe) => self.budget.run(pipe.write_bounded(bytes)).await??, Destination::Capture(capture) => { let mut capture = capture.lock().unwrap_or_else(|e| e.into_inner()); diff --git a/crates/bashkit/src/execution.rs b/crates/bashkit/src/execution.rs index e610aa192..c60d69570 100644 --- a/crates/bashkit/src/execution.rs +++ b/crates/bashkit/src/execution.rs @@ -257,7 +257,9 @@ impl<'a> Execution<'a> { let session_cancel = self.bash.cancellation_token(); let output_file = match self.output_file { Some((path, max_bytes)) => { - if !path.is_absolute() { + // `has_root`, not `is_absolute`: a VFS path like `/tmp/out.log` + // has no drive prefix, so `is_absolute` is false on Windows. + if !path.has_root() { return Err(crate::Error::Execution(format!( "output file must be an absolute path: {}", path.display() diff --git a/crates/bashkit/src/interpreter/mod.rs b/crates/bashkit/src/interpreter/mod.rs index 80b92b646..867098f76 100644 --- a/crates/bashkit/src/interpreter/mod.rs +++ b/crates/bashkit/src/interpreter/mod.rs @@ -6067,7 +6067,7 @@ impl Interpreter { // Unary operators let resolve = |p: &str| -> std::path::PathBuf { let path = std::path::Path::new(p); - let joined = if path.is_absolute() { + let joined = if path.has_root() { path.to_path_buf() } else { crate::fs::vfs_join(&self.cwd, path) @@ -12941,7 +12941,7 @@ impl Interpreter { /// Resolve a path relative to cwd, normalizing `.` and `..` components. fn resolve_path(&self, path: &str) -> PathBuf { let p = Path::new(path); - let joined = if p.is_absolute() { + let joined = if p.has_root() { p.to_path_buf() } else { crate::fs::vfs_join(&self.cwd, p) diff --git a/crates/bashkit/tests/integration/archive_bzip2_tests.rs b/crates/bashkit/tests/integration/archive_bzip2_tests.rs index 3d17db6ba..1a1804b50 100644 --- a/crates/bashkit/tests/integration/archive_bzip2_tests.rs +++ b/crates/bashkit/tests/integration/archive_bzip2_tests.rs @@ -36,6 +36,7 @@ fn tar_with_entry(name: &str, content: &[u8]) -> Vec { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn bashkit_tar_bzip2_output_is_readable_by_system_tar() { let mut bash = Bash::new(); let setup = bash diff --git a/crates/bashkit/tests/integration/arithmetic_resource_tests.rs b/crates/bashkit/tests/integration/arithmetic_resource_tests.rs index df6d81090..5a83d40a6 100644 --- a/crates/bashkit/tests/integration/arithmetic_resource_tests.rs +++ b/crates/bashkit/tests/integration/arithmetic_resource_tests.rs @@ -52,6 +52,7 @@ async fn arithmetic_dollar_siblings_share_expansion_fuel() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn arithmetic_dollar_subscripts_match_bash_within_limits() { let expr = nested_array_expansion(4, false); // NOTE: subscript stays portable on purpose: macOS ships bash 3.2 with no @@ -229,6 +230,7 @@ async fn arithmetic_array_key_size_boundary() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn arithmetic_array_keys_match_modern_bash() { let version = std::process::Command::new("bash") .args(["--noprofile", "--norc", "-c", "echo ${BASH_VERSINFO[0]}"]) diff --git a/crates/bashkit/tests/integration/backtick_quote_tests.rs b/crates/bashkit/tests/integration/backtick_quote_tests.rs index 0ed7c710c..56ac1de9c 100644 --- a/crates/bashkit/tests/integration/backtick_quote_tests.rs +++ b/crates/bashkit/tests/integration/backtick_quote_tests.rs @@ -5,6 +5,7 @@ use bashkit::{Bash, CommandPlacement, ExecutionLimits}; use std::sync::{Arc, Mutex}; #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn backticks_after_quotes_match_bash() { let cases = [ r#"printf '[%s]\n' 'x'`printf '1 2'`; echo tail"#, diff --git a/crates/bashkit/tests/integration/blackbox_security_tests.rs b/crates/bashkit/tests/integration/blackbox_security_tests.rs index f304d2cb4..bb8f890db 100644 --- a/crates/bashkit/tests/integration/blackbox_security_tests.rs +++ b/crates/bashkit/tests/integration/blackbox_security_tests.rs @@ -118,6 +118,7 @@ mod finding_nested_cmd_subst_stack_overflow { } #[tokio::test] + #[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn moderate_substitutions_match_real_bash() { for template in [ "echo $(BODY)", diff --git a/crates/bashkit/tests/integration/byte_stream_tests.rs b/crates/bashkit/tests/integration/byte_stream_tests.rs index 8c74cbddc..10d087468 100644 --- a/crates/bashkit/tests/integration/byte_stream_tests.rs +++ b/crates/bashkit/tests/integration/byte_stream_tests.rs @@ -118,6 +118,7 @@ async fn command_substitution_drops_nuls_at_text_boundary() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn binary_pipeline_matches_real_bash_byte_for_byte() { let script = "printf 'AAHDqf/+QgB/' | base64 -d | head -c 8 | cat"; let expected = Command::new("bash").args(["-c", script]).output().unwrap(); diff --git a/crates/bashkit/tests/integration/competitor_regression_tests.rs b/crates/bashkit/tests/integration/competitor_regression_tests.rs index c154443f7..f3406e6ed 100644 --- a/crates/bashkit/tests/integration/competitor_regression_tests.rs +++ b/crates/bashkit/tests/integration/competitor_regression_tests.rs @@ -291,6 +291,7 @@ async fn competitor_regressions_stay_green_without_network() { } #[test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] fn competitor_real_bash_oracles_match_locked_expectations() { let bash = host_program("bash"); let bash_major = bash_major(&bash); diff --git a/crates/bashkit/tests/integration/curl_data_compat_tests.rs b/crates/bashkit/tests/integration/curl_data_compat_tests.rs index eb1ebcb81..ed2cbef52 100644 --- a/crates/bashkit/tests/integration/curl_data_compat_tests.rs +++ b/crates/bashkit/tests/integration/curl_data_compat_tests.rs @@ -416,6 +416,7 @@ async fn differential_real_curl_matches_mixed_post_data() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn differential_real_curl_matches_get_query_aggregation() { let expected = run_real_curl(&[ "-G", diff --git a/crates/bashkit/tests/integration/custom_fs_tests.rs b/crates/bashkit/tests/integration/custom_fs_tests.rs index 42029aabd..2b7347160 100644 --- a/crates/bashkit/tests/integration/custom_fs_tests.rs +++ b/crates/bashkit/tests/integration/custom_fs_tests.rs @@ -31,21 +31,10 @@ impl MinimalFs { } fn normalize_path(path: &Path) -> PathBuf { - let mut result = PathBuf::new(); - for component in path.components() { - match component { - std::path::Component::RootDir => result.push("/"), - std::path::Component::Normal(name) => result.push(name), - std::path::Component::ParentDir => { - result.pop(); - } - _ => {} - } - } - if result.as_os_str().is_empty() { - result.push("/"); - } - result + // bashkit's normalizer joins with `/` on every host; a `PathBuf::push` + // rebuild keyed entries as `/data\nested` on Windows and broke the + // `/`-prefix scan in `read_dir`. + bashkit::normalize_path(path) } } @@ -82,7 +71,7 @@ impl FileSystem for MinimalFs { if recursive { let mut current = PathBuf::new(); for component in path.components() { - current.push(component); + current = bashkit::vfs_join(¤t, component); let mut files = self.files.write().unwrap(); files.entry(current.clone()).or_default(); } diff --git a/crates/bashkit/tests/integration/execution_budget_tests.rs b/crates/bashkit/tests/integration/execution_budget_tests.rs index 70c1cef47..37a8bcf29 100644 --- a/crates/bashkit/tests/integration/execution_budget_tests.rs +++ b/crates/bashkit/tests/integration/execution_budget_tests.rs @@ -611,6 +611,7 @@ async fn indexed_array_pending_storage_is_released_between_assignments() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn indexed_array_budget_preserves_expansion_order() { let script = "a=(old); a=([0]=1+2 [a[0]]=$a [0]+=x); printf '%s\\n' \"${a[0]}\" \"${a[3]}\"; a+=([0]=new [1]=$a); printf '%s\\n' \"${a[1]}\""; let expected = std::process::Command::new("bash") @@ -660,6 +661,7 @@ async fn tilde_expansion_retains_sibling_assignment_leases() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn tilde_expansion_preserves_bash_semantics() { let script = r#"HOME='/home/test dir'; PWD=/pwd; OLDPWD=/old x=~:~+/bin:~-/lib:~missing diff --git a/crates/bashkit/tests/integration/fmt_resource_tests.rs b/crates/bashkit/tests/integration/fmt_resource_tests.rs index 01b226553..52df1afd1 100644 --- a/crates/bashkit/tests/integration/fmt_resource_tests.rs +++ b/crates/bashkit/tests/integration/fmt_resource_tests.rs @@ -185,6 +185,7 @@ async fn fmt_missing_file_reports_error_and_formats_remaining_file() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn fmt_finite_shell_input_matches_real_bash() { use std::process::Command; // One short line per paragraph: GNU/BSD fmt and the vendored optimal-fit diff --git a/crates/bashkit/tests/integration/function_metadata_security_tests.rs b/crates/bashkit/tests/integration/function_metadata_security_tests.rs index b49cc8a59..8541b2373 100644 --- a/crates/bashkit/tests/integration/function_metadata_security_tests.rs +++ b/crates/bashkit/tests/integration/function_metadata_security_tests.rs @@ -136,6 +136,7 @@ async fn function_metadata_budget_boundary() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn source_filename_lifecycle_matches_real_bash() { let dir = tempfile::tempdir().unwrap(); // Bash versions label functions defined in `-c` differently. Source the diff --git a/crates/bashkit/tests/integration/grep_recursive_security_tests.rs b/crates/bashkit/tests/integration/grep_recursive_security_tests.rs index 7711912d9..153bbbac4 100644 --- a/crates/bashkit/tests/integration/grep_recursive_security_tests.rs +++ b/crates/bashkit/tests/integration/grep_recursive_security_tests.rs @@ -153,13 +153,14 @@ async fn grep_recursive_files_share_aggregate_input_budget() { #[tokio::test] async fn grep_recursive_cycle_diagnostic_is_bounded_utf8() { let mut bash = Bash::new(); + // `/`-joined on every host: the path is also spliced into the script. let mut dir = std::path::PathBuf::from("/d"); for _ in 0..6 { - dir.push("é".repeat(100)); + dir = bashkit::vfs_join(&dir, "é".repeat(100)); } bash.fs().mkdir(&dir, true).await.unwrap(); bash.fs() - .symlink(Path::new("."), &dir.join("loop")) + .symlink(Path::new("."), &bashkit::vfs_join(&dir, "loop")) .await .unwrap(); let result = bash diff --git a/crates/bashkit/tests/integration/indirect_reference_tests.rs b/crates/bashkit/tests/integration/indirect_reference_tests.rs index 368243919..7caaa7935 100644 --- a/crates/bashkit/tests/integration/indirect_reference_tests.rs +++ b/crates/bashkit/tests/integration/indirect_reference_tests.rs @@ -4,6 +4,7 @@ use bashkit::Bash; use std::process::Command; #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn indirect_reference_nested_index_matches_bash() { let script = r#"a=(zero one); b=(1); r='a[b[0]]'; printf '%s/%s\n' "${!r}" "${a[b[0]]}""#; let result = Bash::new().exec(script).await.unwrap(); @@ -36,6 +37,7 @@ printf '%s/%s/%s\n' "${!quoted}" "${!escaped}" "${items['left]right']}" } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn indirect_reference_explicit_default_and_slice_remain_valid() { let script = r#"a=(zero one); r='a[1]'; printf '%s/%s\n' "${!r:-fallback}" "${!r:1}""#; let result = Bash::new().exec(script).await.unwrap(); diff --git a/crates/bashkit/tests/integration/main.rs b/crates/bashkit/tests/integration/main.rs index 8f001254d..038ac8ca2 100644 --- a/crates/bashkit/tests/integration/main.rs +++ b/crates/bashkit/tests/integration/main.rs @@ -73,7 +73,8 @@ pub mod cpython_capability_tests; pub mod cpython_http_tests; pub mod cpython_integration_tests; pub mod cpython_security_tests; -#[cfg(feature = "tzdata")] +// Oracle suite: compares against host GNU `date`/zoneinfo, Unix only. +#[cfg(all(unix, feature = "tzdata"))] pub mod date_timezone_differential_tests; #[cfg(not(feature = "tzdata"))] pub mod date_timezone_no_tzdata_tests; @@ -141,6 +142,8 @@ pub mod pipeline_tests; pub mod pr_resource_tests; pub mod process_substitution_fd_tests; pub mod prompt_resource_tests; +// Oracle suite: compares against host bash, Unix only. +#[cfg(unix)] pub mod proptest_differential; pub mod python_integration_tests; pub mod python_security_tests; diff --git a/crates/bashkit/tests/integration/partial_parse_tests.rs b/crates/bashkit/tests/integration/partial_parse_tests.rs index 16e1f10b0..408016eb8 100644 --- a/crates/bashkit/tests/integration/partial_parse_tests.rs +++ b/crates/bashkit/tests/integration/partial_parse_tests.rs @@ -111,6 +111,7 @@ async fn child_syntax_report_is_bounded() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn small_child_syntax_reports_match_bash() { // Host /bin/bash varies by platform (macOS bash 3.2 reports `-c` input as // `line 0`, modern GNU bash reports `line 1`, matching our parser), so diff --git a/crates/bashkit/tests/integration/pipeline_admission_tests.rs b/crates/bashkit/tests/integration/pipeline_admission_tests.rs index 31456fa5e..0960251f3 100644 --- a/crates/bashkit/tests/integration/pipeline_admission_tests.rs +++ b/crates/bashkit/tests/integration/pipeline_admission_tests.rs @@ -2,6 +2,7 @@ use bashkit::{Bash, ExecOptions, ExecutionLimits}; #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn two_stage_pipeline_preserves_exports_status_and_isolation() { let script = "export DEMO=parent; { export DEMO=child; printf '%s\\n' \"$DEMO\"; } | cat; printf '%s %s\\n' \"$DEMO\" \"${PIPESTATUS[*]}\""; let mut bash = Bash::builder() diff --git a/crates/bashkit/tests/integration/pr_resource_tests.rs b/crates/bashkit/tests/integration/pr_resource_tests.rs index 164833e98..0b8e6a401 100644 --- a/crates/bashkit/tests/integration/pr_resource_tests.rs +++ b/crates/bashkit/tests/integration/pr_resource_tests.rs @@ -103,6 +103,7 @@ async fn pr_line_metadata_and_work_are_budgeted() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn pr_finite_pagination_matches_real_bash_and_gnu_pr() { use std::process::Command; let program = ["gpr", "pr"].into_iter().find(|program| { diff --git a/crates/bashkit/tests/integration/spec_runner.rs b/crates/bashkit/tests/integration/spec_runner.rs index 9758fc086..fcd1889a1 100644 --- a/crates/bashkit/tests/integration/spec_runner.rs +++ b/crates/bashkit/tests/integration/spec_runner.rs @@ -92,6 +92,14 @@ pub fn parse_spec_file(content: &str) -> Vec { test.skip = true; test.skip_reason = Some(reason.trim().to_string()); } + } else if let Some(reason) = directive.strip_prefix("skip_windows:") { + // Host-specific VFS semantics (see L-FS-005): skip only there. + if cfg!(windows) + && let Some(ref mut test) = current_test + { + test.skip = true; + test.skip_reason = Some(reason.trim().to_string()); + } } else if directive == "skip" { if let Some(ref mut test) = current_test { test.skip = true; @@ -429,6 +437,7 @@ hello } #[test] + #[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] fn test_real_bash_comparison_uses_isolated_current_dir() { let probe_name = format!("bashkit_real_bash_isolation_probe_{}", std::process::id()); let probe = std::env::current_dir().unwrap().join(&probe_name); diff --git a/crates/bashkit/tests/integration/spec_tests.rs b/crates/bashkit/tests/integration/spec_tests.rs index cd074505b..2c0296abc 100644 --- a/crates/bashkit/tests/integration/spec_tests.rs +++ b/crates/bashkit/tests/integration/spec_tests.rs @@ -7,6 +7,7 @@ //! ## Test Directives //! - `### skip: reason` - Skip test entirely (not run in any test) //! - `### bash_diff: reason` - Known difference from real bash (runs in spec tests, excluded from comparison) +//! - `### skip_windows: reason` - Skip only on Windows hosts (host-specific VFS semantics, L-FS-005) //! //! ## Skipped Tests (32 total) //! diff --git a/crates/bashkit/tests/integration/streaming_audit_tests.rs b/crates/bashkit/tests/integration/streaming_audit_tests.rs index ac9b46ed9..f1693fa8b 100644 --- a/crates/bashkit/tests/integration/streaming_audit_tests.rs +++ b/crates/bashkit/tests/integration/streaming_audit_tests.rs @@ -121,6 +121,7 @@ async fn saved_output_descriptors_reach_sinks_and_capture() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn process_substitution_preserves_bytes_in_buffered_and_live_execution() { for script in [ "cat <(printf '\\377\\000A')", @@ -248,6 +249,7 @@ async fn descriptor_redirects_keep_final_filters_live() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn redirected_streaming_utilities_match_bash() { for script in [ "printf 'a\\nb\\n' | cat 2>&1", diff --git a/crates/bashkit/tests/integration/tar_files_from_budget_tests.rs b/crates/bashkit/tests/integration/tar_files_from_budget_tests.rs index 72f24067c..998552d57 100644 --- a/crates/bashkit/tests/integration/tar_files_from_budget_tests.rs +++ b/crates/bashkit/tests/integration/tar_files_from_budget_tests.rs @@ -149,6 +149,7 @@ async fn tar_files_from_preserves_order_duplicates_crlf_and_lossy_names() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn tar_files_from_matches_real_bash_tar() { let script = "printf a > a; printf b > b; printf 'a\\n\\nb\\na' > list; cp list list2; tar -cf out.tar -T list --files-from=list2; tar -tf out.tar; printf 'b\\n' | tar -cf stdin.tar -T -; tar -tf stdin.tar"; let mut bash = Bash::new(); diff --git a/crates/bashkit/tests/integration/threat_model_tests.rs b/crates/bashkit/tests/integration/threat_model_tests.rs index 9b47064eb..96fa10c75 100644 --- a/crates/bashkit/tests/integration/threat_model_tests.rs +++ b/crates/bashkit/tests/integration/threat_model_tests.rs @@ -958,6 +958,10 @@ pub(crate) mod resource_exhaustion { /// back what its own process received. This pins the actual value, which /// the static scan in `bounded_child_launcher_scan_tests` cannot. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn bounded_cli_children_get_a_profile_path_outside_the_merge_set() { fn profile_of(cmd: &Command) -> std::ffi::OsString { cmd.get_envs() @@ -1289,6 +1293,10 @@ pub(crate) mod resource_exhaustion { /// shape and flat <=1 KiB stderr, proving the report no longer grows /// with the product. Never runs in the test process. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn syntax_diagnostic_multiline_times_arg0_is_bounded_in_child() { for token_lines in [200usize, 2000usize] { let mut script = String::from("for x \""); @@ -1384,6 +1392,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_reader_exact_cap_eof_is_clean() { // Two 4096-byte reads land exactly on the 8192 cap, then EOF: // full retention, no excess flag. @@ -1399,6 +1411,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_reader_real_excess_flags_oversized() { let mut over: &[u8] = &vec![b'x'; BOUNDED_SAMPLE_CAP + 1]; let (buf, oversized, read_error) = drain_capped(&mut over); @@ -1412,6 +1428,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_reader_retries_interrupted_and_reports_errors() { let mut ok = ScriptedRead { ops: vec![ReadOp::Interrupted, ReadOp::Data(b"hi"), ReadOp::Eof], @@ -1431,6 +1451,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_signal_reports_presence_trichotomy() { // Direct deterministic proof of the ESRCH/EPERM/Unknown split // through the actual helper: self is Present, an impossible PID @@ -1515,6 +1539,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_drain_ends_without_eof_at_cap() { let start = Instant::now(); let mut src = EndlessWriter; @@ -1534,6 +1562,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_helper_timeout_kills_and_reaps_bounded() { // Deterministic timeout path through the shared helper: a 30s // sleeper against a 200ms end always trips the deadline first. @@ -1560,6 +1592,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_helper_retained_writer_times_out_bounded() { // Controlled retained-writer negative proof THROUGH the shared // helper entry (not a manual copy of its poll/drain/channel): a @@ -1653,6 +1689,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_handshake_failure_has_owned_unknown_verdict() { // Two identity channels for the SAME controlled victim: pidA is // written by the fixture and establishes independent ownership @@ -1736,6 +1776,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_ownership_channel_failure_has_owned_unknown_verdict() { // Fixture with NO pid echo anywhere: no per-process identity // channel exists, so the parent verdict stays honestly unknown. @@ -1825,6 +1869,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_drop_preserves_unfinished_reader_for_owner() { let (release, wait) = std::sync::mpsc::channel(); let handle = std::thread::spawn(move || { @@ -1865,6 +1913,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_marker_drop_cleans_up_on_unwind() { // Caught failure through a MARKER-owned fixture (no pid identity // anywhere): the guard is built before any assert, the panic @@ -1946,6 +1998,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_owned_guard_survives_unwind_then_completes() { // The guard survives a borrow-only panic (never consumed by it), // then runs its explicit finite cleanup AFTER catch_unwind: same @@ -2022,6 +2078,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_handshake_fixture_cleans_up_on_unwind() { // Caught setup/assertion failure through the owned handshake // fixture: panic BEFORE normal complete, then prove the guard's @@ -2095,6 +2155,10 @@ pub(crate) mod resource_exhaustion { std::fs::remove_file(&pid_a).ok(); } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_cleanup_guard_fires_on_unwind() { // A live sleeper owned by a guard that never reaches complete(): // the panic below simulates an assertion failure, and Drop must @@ -2170,6 +2234,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_reap_seam_covers_poll_verdicts() { // A pre-reaped status to replay through the seam. let mut done = Command::new("bash"); @@ -2216,6 +2284,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_join_gate_proves_paused_sender_unfinished() { // A sender paused after send, driven through the ACTUAL // `join_finished` gate the runner uses. The sender blocks on @@ -2256,6 +2328,10 @@ pub(crate) mod resource_exhaustion { ); } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_parent_verdict_covers_injected_faults() { // Poll failure against a TRULY LIVE child through the REAL parent // lifecycle: no panic, real termination in common cleanup, and a @@ -2365,6 +2441,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_timeout_kills_and_reaps_within_grace() { // Pure-builtin busy loop: no grandchildren can inherit the pipes, // so killing the shell closes them and the readers finish. @@ -2404,6 +2484,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn harness_overflow_child_is_flagged_with_clean_read() { // 9000 bytes: just over the 8192 cap, small enough to exit on its // own through the pipe buffer, so the verdict is overflow alone. @@ -2436,6 +2520,10 @@ pub(crate) mod resource_exhaustion { /// refused with `invalid variable name`, like modern bash (5.x); the /// real producer exit status is asserted, never relabeled. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn indirect_hostile_cycles_rejected_in_bounded_child() { for script in [ "unset a\nr='a[0]:-${!r}]'\necho \"${!r}\"", @@ -2478,6 +2566,10 @@ pub(crate) mod resource_exhaustion { /// it; and absence must stay an error, never a path that fails later as /// a spawn error or an exit 127. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn cli_lookup_resolves_known_cargo_layouts() { let root = std::env::temp_dir().join(format!("bashkit-cli-layout-{}", std::process::id())); let _ = std::fs::remove_dir_all(&root); @@ -2540,6 +2632,10 @@ pub(crate) mod resource_exhaustion { /// repeatedly: the timeout verdict must be deterministic, never a /// scheduling coin flip. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn bounded_helper_kills_hung_child() { let run = run_cli_bounded("sleep 30", Duration::from_secs(3)); assert!( @@ -2564,6 +2660,10 @@ pub(crate) mod resource_exhaustion { /// starts (exit 99) instead of running unbounded. A shadowed failing /// `ulimit` exercises the refusal with a harmless instant child. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn bounded_launcher_failure_is_fail_closed() { let probe = [ "ulimit() { return 1; }; ", @@ -2596,6 +2696,10 @@ pub(crate) mod resource_exhaustion { /// may end the run. The previous loop broke on complete buffers and /// then waited without a deadline; this case hung it forever. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn bounded_helper_covers_early_pipe_close() { let run = run_cli_bounded("echo hi; exec 1>&- 2>&-; sleep 30", Duration::from_secs(5)); assert!(run.timed_out, "live producer with closed pipes not killed"); @@ -2620,6 +2724,10 @@ pub(crate) mod resource_exhaustion { /// portably). The elapsed assertion proves the run returns without /// waiting for it. #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn bounded_helper_flags_retained_pipes() { // The sleeper's PID is retained through a second receipt file so // the test itself terminates and finitely observes the exact @@ -2714,6 +2822,10 @@ pub(crate) mod resource_exhaustion { } #[test] + #[cfg_attr( + not(unix), + ignore = "Unix child-process harness (signals, pipes, CLI layout)" + )] fn bounded_helper_flags_oversize_output() { let script = "i=0; while ((i < 4000)); do echo \"padding line $i padding\"; i=$((i + 1)); done"; diff --git a/crates/bashkit/tests/integration/time_command_tests.rs b/crates/bashkit/tests/integration/time_command_tests.rs index ac9731719..0ce729554 100644 --- a/crates/bashkit/tests/integration/time_command_tests.rs +++ b/crates/bashkit/tests/integration/time_command_tests.rs @@ -326,6 +326,7 @@ async fn failed_atomic_replace_cleans_temporary_report() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn reserved_word_matches_real_bash_stream_and_status_semantics() { let script = "set -o pipefail; f() { echo out; echo err >&2; return 6; }; time f | cat"; let host = Command::new("bash") diff --git a/crates/bashkit/tests/spec_cases/bash/ls.test.sh b/crates/bashkit/tests/spec_cases/bash/ls.test.sh index fc08ac671..89406ef22 100644 --- a/crates/bashkit/tests/spec_cases/bash/ls.test.sh +++ b/crates/bashkit/tests/spec_cases/bash/ls.test.sh @@ -188,6 +188,7 @@ ls X.Y.Z ### end ### ls_escape_nongraphic +### skip_windows: `\` is a path separator in the VFS on Windows (L-FS-005) # The VFS rejects control characters in names, so only spaces and # backslashes need escaping here; control-char escapes are unit-tested. mkdir -p /tmp/lse && cd /tmp/lse && touch 'a b' plain 'g\h' diff --git a/knowledge/operations/limitations.md b/knowledge/operations/limitations.md index 7a90c3377..4315fc33b 100644 --- a/knowledge/operations/limitations.md +++ b/knowledge/operations/limitations.md @@ -58,6 +58,7 @@ execution model. Evidence is a threat-model ID, a test, or `stance` | L-FS-002 | No file permission enforcement in the VFS | Single-tenant virtual FS; permissions would be theater | `l_fs_002_no_permission_enforcement` | | L-FS-003 | On Windows, `RealFs::symlink()` validates the target but creates an empty host file rather than a symlink/reparse point; pre-existing host symlinks and junctions remain readable subject to containment checks | Windows requires choosing file-vs-directory link semantics and may require link privileges; the portable VFS symlink contract does not carry that host metadata | TM-ESC-033 | | L-FS-004 | File names cannot contain control characters (newline, tab, ESC, ...) or bidi overrides: creating `$'a\nb'` fails with `unsafe character U+000A in path component`, so tools never print the quoted forms (`stat -c %N` as `'a'$'\n''b'`, `md5sum`'s `\` escape) for such names | Control characters in names let output forge extra lines or terminal escapes (TM-DOS-015) | `bashbox-checksum.test.sh`, `bashbox-stat.test.sh` (skipped) | +| L-FS-005 | On Windows hosts, `\` in a path is a separator, not a file-name character: `touch 'g\h'` names `g/h` | The VFS normalizer parses paths with `std::path`, which splits on both separators on Windows; host-path namespace stripping (TM-ESC-033) relies on that parse | `ls.test.sh` (`skip_windows`) | | L-NET-001 | No raw network sockets; HTTP only via `curl`/`wget`/`http` builtins | Allowlist-mediated egress is the only network surface | `l_net_001_no_raw_sockets` | | L-NET-002 | No DNS resolution; hosts must appear in the allowlist | Resolution would bypass allowlist intent | `l_net_002_default_deny_no_resolution` | | L-ARITH-001 | A variable's value read as an arithmetic expression or subscript never runs command substitution: `x='a[$(cmd)]'; echo $((x))` and `unset "a[$(cmd)]"` built from data are arithmetic syntax errors, and an indirect target holding `$(`, `` ` ``, `<(` or `>(` (`r='a[$(cmd)]'; ${!r}`) is `invalid variable name`, where bash runs `cmd` | Values are data; re-parsing them as code is the classic bash arithmetic injection, and a sandboxed agent shell must not execute text it only read | stance | From 68be1bc6182fae397063c41f8a69541e3aa0274c Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Wed, 18 Nov 2026 19:01:52 +0000 Subject: [PATCH 3/6] chore(knowledge): document the nightly Windows suite and is_absolute ban --- knowledge/foundations/vfs.md | 7 ++++++- knowledge/log.md | 2 ++ knowledge/operations/testing.md | 12 +++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/knowledge/foundations/vfs.md b/knowledge/foundations/vfs.md index 1d275f6a9..1315c2636 100644 --- a/knowledge/foundations/vfs.md +++ b/knowledge/foundations/vfs.md @@ -326,7 +326,8 @@ public `custom_backend` and `custom_filesystem_impl` examples taught the Fuzzing cannot find this class: the fuzz targets run on Linux, where the host separator already is `/`. These guards keep it out: - `crates/bashkit/clippy.toml` bans `Path::join`, `PathBuf::push`, - `PathBuf::set_file_name` and `Path::with_file_name` in the `bashkit` crate + `PathBuf::set_file_name`, `Path::with_file_name` and `Path::is_absolute` + (VFS code asks `has_root()`) in the `bashkit` crate (`clippy::disallowed_methods`, run by CI's `-D warnings` clippy on Linux). Host-path code opts out with a scoped `#[allow]` and a reason: `realfs.rs`, `HostMounts::host_path_for`, the non-UTF-8 fallback in `vfs_join`, @@ -348,6 +349,10 @@ host separator already is `/`. These guards keep it out: CI job runs (`cargo test -p bashkit --lib --features realfs windows_containment`). The `test-windows` job also runs the integration binary's `windows_containment`, `dev_fd_path_tests` and `dev_null_tests`. +- `.github/workflows/windows-nightly.yml` runs the whole lib, integration and + `proptest_security` suites on `windows-latest` daily, including a proptest of + random path scripts through `CheckedFs`. See + [Testing](../operations/testing.md#windows-ci). Host paths are the exception and keep using `Path::join`: `RealFs` joining under its host root, and `HostMounts` mapping a VFS path back to a host path. diff --git a/knowledge/log.md b/knowledge/log.md index 5df2d827b..189b2d433 100644 --- a/knowledge/log.md +++ b/knowledge/log.md @@ -2,6 +2,8 @@ ## 2026-11-18 +* **Nightly Windows run of the full bashkit suites**: `windows-nightly.yml` runs lib, integration and `proptest_security` tests on `windows-latest` daily, plus a proptest of random path scripts through `CheckedFs`. Its first trial found four more real Windows bugs: `Path::is_absolute()` (false for `/etc/x` on Windows) in the `output_file` check and a dozen builtins, now `has_root()` and banned in clippy; a closed fd reported the host's EBADF text (`os error 9` wording differs); and two test fixtures that built VFS paths with `PathBuf::push`. CRLF checkout broke skill and workflow fixtures, so `.gitattributes` forces LF. Host-tool oracles and the Unix process harness are ignored off unix; `ls` with a `\` file name is skipped there as L-FS-005. See [Testing](operations/testing.md#windows-ci). + * **Windows `/dev/stderr` redirects hit the VFS (#2933), and four more host-separator joins**: `dev_fd_alias` re-normalized the already-clean redirect target with `PathBuf::push`, which joins with `\` on Windows, so `/dev\stderr` missed the string match and `echo x > /dev/stderr` wrote a VFS file. It now uses the shared `normalize_path`. A clippy trial run with the join methods banned found the rest of the class: `PosixFs::mkdir -p` parent checks (backend saw `/a\b`), `cd x/..`, `readlink -f`/`realpath` prefix probes, and `OverlayFs` upper-dir counting, all now `vfs_join`. Second sweep after #2425, so the fix is a guard, not a sweep: `crates/bashkit/clippy.toml` bans `Path::join`/`PathBuf::push`/`set_file_name`/`with_file_name` with scoped allows for host-path code; `testing::CheckedFs` records paths a filesystem receives; the Windows CI job now runs the device-path and separator integration tests. Fuzzing could not have found it: Linux's separator is `/`. See [Virtual Filesystem](foundations/vfs.md). * **picomatch ReDoS suppressed: no patched release exists**: the nightly `Advisory Audit` went red on 2026-11-18 with GHSA-fc5q-39xc-vjpf (CVE-2026-112366, high) against `picomatch` in three of the five pnpm lockfiles (crates/bashkit-js, examples/browser, site). Nothing in the tree moved: picomatch 4.0.7 has been the resolution in all three since 2026-11-07 and every push scan was green, including main at 1bea26a eighteen hours earlier; the advisory was widened to cover `<= 4.0.7` on 2026-11-17. `<= 4.0.7` is picomatch's entire release history and the advisory lists no patched version, so the usual npm answer -- bump to the fix -- does not exist, and `pnpm audit` keys on the resolved version, so a `pnpm patch` would not clear it either. Suppressed by id in `IGNORED_NPM_ADVISORIES` with a rationale and a removal condition, the first npm entry since the `braces` exception was retired on 2026-10-23. The exposure is build tooling only: `ava` and `@napi-rs/cli` in crates/bashkit-js, `vite`/`tinyglobby` in examples/browser, `astro` and `vite` in site, plus `micromatch`/`anymatch` on picomatch 2.3.2. Every glob those compile comes from repo config or a build tool's own defaults, no tenant input reaches them, and no published crate, wheel or npm package resolves picomatch -- the published `@everruns/bashkit` ships only its JS wrappers and native binaries, with `@napi-rs/wasm-runtime` as its single optional dependency. A suppressed finding is still printed by the wrapper, so the entry stays visible until picomatch ships a release above 4.0.7. See [Threat Model](security/threat-model.md#suppressed-advisories). diff --git a/knowledge/operations/testing.md b/knowledge/operations/testing.md index beaec0942..16bf5ea0e 100644 --- a/knowledge/operations/testing.md +++ b/knowledge/operations/testing.md @@ -292,7 +292,17 @@ and command-resolver suites on `windows-latest` and gates `Check`. It is deliberately scoped rather than a full workspace port: the adoption shape exists to work on Windows without a real `bash`, and that claim needs a Windows -runner to stay true. Everything else stays ubuntu-only. +runner to stay true. Everything else stays ubuntu-only on PRs. + +`windows-nightly.yml` (daily 05:00 UTC, manual dispatch, and PRs that edit it) +runs `bashkit`'s lib, integration and `proptest_security` suites on +`windows-latest`, because host-separator bugs (#2425, #2933) cannot show up +on Linux. It is not a `Check` gate. Two kinds of tests are ignored off unix, +with `#[cfg_attr(not(unix), ignore = ...)]` or a module `#[cfg(unix)]`: +oracles that run host bash/GNU tools (Windows `bash` is the WSL launcher), and +the Unix child-process harness in `threat_model_tests`. Spec cases that cannot +hold on Windows use `### skip_windows: reason`. `.gitattributes` forces LF +checkout, since CRLF fixtures broke skill and workflow parsers. ## Third-Party API Steps in CI From a0ccf4cc71519f08695ec9c2062adac7f608f9f1 Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Wed, 18 Nov 2026 19:10:01 +0000 Subject: [PATCH 4/6] test: ignore the indirect-index bash oracle off unix --- crates/bashkit/tests/integration/threat_model_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bashkit/tests/integration/threat_model_tests.rs b/crates/bashkit/tests/integration/threat_model_tests.rs index 96fa10c75..198e9c755 100644 --- a/crates/bashkit/tests/integration/threat_model_tests.rs +++ b/crates/bashkit/tests/integration/threat_model_tests.rs @@ -2913,6 +2913,7 @@ pub(crate) mod resource_exhaustion { /// byte-for-byte. Indexed arrays work on bash 3.2+, so this runs on /// macOS and Linux CI alike. #[tokio::test] + #[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn indirect_nested_indexed_matches_real_bash() { for script in [ "a=(zero one two three); b=(2); r='a[b[0]]'; printf 'indirect=[%s]\n' \"${!r}\"; printf 'direct=[%s]\n' \"${a[b[0]]}\"", From d175715c5057308696ec2ac0865f4aff9634884c Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Wed, 18 Nov 2026 19:46:21 +0000 Subject: [PATCH 5/6] test: ignore the iconv oracle off unix --- crates/bashkit/tests/integration/byte_stream_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bashkit/tests/integration/byte_stream_tests.rs b/crates/bashkit/tests/integration/byte_stream_tests.rs index c26eb35a9..3e8c6720b 100644 --- a/crates/bashkit/tests/integration/byte_stream_tests.rs +++ b/crates/bashkit/tests/integration/byte_stream_tests.rs @@ -190,6 +190,7 @@ async fn iconv_repairs_cp_export_and_writes_real_bytes() { } #[tokio::test] +#[cfg_attr(not(unix), ignore = "compares against host Unix bash/tools")] async fn iconv_matches_real_iconv_byte_for_byte() { // Skip where the host has no iconv; CI runners ship glibc's. if Command::new("iconv").arg("-l").output().is_err() { From f3099b0f1e94f50e51882b3f24ccada9db9feedd Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Wed, 18 Nov 2026 19:46:30 +0000 Subject: [PATCH 6/6] chore(knowledge): new host-tool oracle tests need the off-unix ignore --- knowledge/operations/testing.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/knowledge/operations/testing.md b/knowledge/operations/testing.md index 16bf5ea0e..a5b6a04de 100644 --- a/knowledge/operations/testing.md +++ b/knowledge/operations/testing.md @@ -300,7 +300,8 @@ runs `bashkit`'s lib, integration and `proptest_security` suites on on Linux. It is not a `Check` gate. Two kinds of tests are ignored off unix, with `#[cfg_attr(not(unix), ignore = ...)]` or a module `#[cfg(unix)]`: oracles that run host bash/GNU tools (Windows `bash` is the WSL launcher), and -the Unix child-process harness in `threat_model_tests`. Spec cases that cannot +the Unix child-process harness in `threat_model_tests`. A new oracle test needs +the same attribute, or the nightly goes red. Spec cases that cannot hold on Windows use `### skip_windows: reason`. `.gitattributes` forces LF checkout, since CRLF fixtures broke skill and workflow parsers.