config: detect Windows cache/data directory case overlap #61

Closed
LouisRiverstone wants to merge 0 commits from upstream-pr/61 into main
LouisRiverstone commented 2026-11-25 21:22:21 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by LouisRiverstone on 2026-11-25T21:22:21Z.


Fixes #55.

Summary

  • compare resolved path components case-insensitively on Windows
  • preserve exact component comparison on other platforms
  • keep sibling paths such as cache/cache-old accepted

Tests

  • cargo test -p victory-core
  • cargo check -p victory-core --target x86_64-pc-windows-msvc

Added Windows-specific config regressions for equal, nested, accented, and sibling paths.

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:5499394512 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VitoriaBr2.0/pull/61). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-25T21:22:21Z. --- Fixes #55. ## Summary - compare resolved path components case-insensitively on Windows - preserve exact component comparison on other platforms - keep sibling paths such as cache/cache-old accepted ## Tests - cargo test -p victory-core - cargo check -p victory-core --target x86_64-pc-windows-msvc Added Windows-specific config regressions for equal, nested, accented, and sibling paths.
lmouz823-lang commented 2026-11-28 04:40:17 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lmouz823-lang on 2026-11-28T04:40:17Z.


I can take a native Windows semantic review at exact head 43077e483f2f606c7a0795823077ac4f49af6825. I will check the uncreated-tail Unicode comparisons against actual filesystem aliases and Windows ordinal comparison, and check case-sensitive parent-directory behavior in a private temporary directory if the system permits it. Existing regressions, concrete counterexamples, unsupported controls and any minimal test-only patch will be reported separately. I will also compare the corresponding cases with #103, which addresses the same #55 requirement, to give an actionable reuse path. AI-assisted with Codex.

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7234185658 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/61#issuecomment-7234185658). Originally posted by [lmouz823-lang](https://github.com/lmouz823-lang) on 2026-11-28T04:40:17Z. --- I can take a native Windows semantic review at exact head `43077e483f2f606c7a0795823077ac4f49af6825`. I will check the uncreated-tail Unicode comparisons against actual filesystem aliases and Windows ordinal comparison, and check case-sensitive parent-directory behavior in a private temporary directory if the system permits it. Existing regressions, concrete counterexamples, unsupported controls and any minimal test-only patch will be reported separately. I will also compare the corresponding cases with #103, which addresses the same #55 requirement, to give an actionable reuse path. AI-assisted with Codex.
lmouz823-lang commented 2026-11-28 04:52:23 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by lmouz823-lang on 2026-11-28T04:52:23Z.


Native Windows/NTFS audit of exact head 43077e483f2f606c7a0795823077ac4f49af6825 found incorrect overlap rejections that the existing tests miss. The unchanged victory-core --lib suite passes all 17 tests, but the new regression below fails.

The component-wise to_string_lossy().to_lowercase() comparison treats these distinct NTFS directory names as equal.

Cache component Data parent component Windows ordinal comparison Actual directory creation #61 with both tails missing
İ (U+0130) i + combining dot (U+0069 U+0307) Different Both directories can be created, canonical paths differ is_within returns true and Config::load rejects
K (U+004B) Kelvin sign K (U+212A) Different Both directories can be created, canonical paths differ is_within returns true and Config::load rejects

For each case, the public API and Config::load checks ran while the configured directories were absent. Validation left the temporary parent empty. A separate creation phase confirmed the names are distinct using successful second create_dir calls and canonicalization. The ASCII cache / CACHE and accented depósito / DEPÓSITO controls correctly collide and are rejected.

There is also a case-sensitive-directory issue. I successfully enabled and queried the case-sensitive flag on a new, private, empty temporary directory (fsutil returned 0 for both operations), then verified that probe and PROBE differ there. With missing cache and CACHE/saves paths beneath that parent, #61 still returns is_within = true and rejects the configuration. The parent remained empty after validation.

I ran the identical external probe source and dependency lock against #103 at 8c7eb1ea64a7955550e6cf24f77212b39622812b. That implementation returns false and accepts these independent paths for both Unicode cases and the case-sensitive-parent control. It still rejects the true ASCII/accented aliases. This comparison covers those controls and the one new exact regression.

The attached 34-line test-only regression derives the expected identity from actual directory creation, cross-checks canonicalization, removes its own probe directories, asserts the configured tails are absent, and calls is_within. It fails on #61 at the dotted-I pair with left: true, right: false (exit 101), and the same test passes when temporarily added to the #103 head. #103 was then restored to its clean source. The proposed #61 diff contains only this regression. Changed-file rustfmt, package Clippy with -D warnings, and git diff --check pass.

Please consider reusing or coordinating with #103's existing Windows ordinal comparison and ancestor case-sensitivity handling for #55. These observations were made on Windows 11/NTFS with Rust 1.98.1. No proposed filesystem controls were skipped, including the case-sensitive-directory setup, and both exact regression runs have zero ignored tests. Other filesystems and non-Windows behavior remain outside this focused audit.

Microsoft documents that CompareStringOrdinal with ignore-case uses the OS uppercase table, and Windows supports per-directory case-sensitivity flags. CompareStringOrdinal, case sensitivity.

Run the added regression with the command below.

cargo test --locked -p victory-core --lib policy::tests::missing_components_follow_filesystem_case_identity -- --exact --nocapture --test-threads=1

AI assistance from Codex covered the audit, synthetic probe, regression and report.

Minimal failing regression against this PR head
diff --git a/crates/victory-core/src/policy.rs b/crates/victory-core/src/policy.rs
index 514a777..b998556 100644
--- a/crates/victory-core/src/policy.rs
+++ b/crates/victory-core/src/policy.rs
@@ -212,4 +212,38 @@ mod tests {
             ));
         }
     }
+
+    #[cfg(windows)]
+    #[test]
+    fn missing_components_follow_filesystem_case_identity() {
+        for (cache_name, alias_name) in [("cache", "CACHE"), ("İ", "i\u{307}"), ("K", "K")] {
+            let tmp = tempfile::tempdir().unwrap();
+            let cache = tmp.path().join(cache_name);
+            let alias = tmp.path().join(alias_name);
+            std::fs::create_dir(&cache).unwrap();
+            let equivalent = match std::fs::create_dir(&alias) {
+                Ok(()) => false,
+                Err(error) => {
+                    assert_eq!(error.kind(), std::io::ErrorKind::AlreadyExists);
+                    true
+                }
+            };
+            assert_eq!(
+                std::fs::canonicalize(&cache).unwrap() == std::fs::canonicalize(&alias).unwrap(),
+                equivalent
+            );
+            std::fs::remove_dir(&cache).unwrap();
+            if !equivalent {
+                std::fs::remove_dir(&alias).unwrap();
+            }
+            assert_eq!(std::fs::read_dir(tmp.path()).unwrap().count(), 0);
+            let data = alias.join("saves");
+            assert!(!cache.exists() && !data.exists());
+            assert_eq!(
+                is_within(&data, &cache).unwrap(),
+                equivalent,
+                "cache {cache_name:?}, data parent {alias_name:?}"
+            );
+        }
+    }
 }
<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7234311672 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/61#issuecomment-7234311672). Originally posted by [lmouz823-lang](https://github.com/lmouz823-lang) on 2026-11-28T04:52:23Z. --- Native Windows/NTFS audit of exact head `43077e483f2f606c7a0795823077ac4f49af6825` found incorrect overlap rejections that the existing tests miss. The unchanged `victory-core --lib` suite passes all 17 tests, but the new regression below fails. The component-wise `to_string_lossy().to_lowercase()` comparison treats these distinct NTFS directory names as equal. | Cache component | Data parent component | Windows ordinal comparison | Actual directory creation | #61 with both tails missing | | --- | --- | --- | --- | --- | | `İ` (`U+0130`) | `i` + combining dot (`U+0069 U+0307`) | Different | Both directories can be created, canonical paths differ | `is_within` returns true and `Config::load` rejects | | `K` (`U+004B`) | Kelvin sign `K` (`U+212A`) | Different | Both directories can be created, canonical paths differ | `is_within` returns true and `Config::load` rejects | For each case, the public API and `Config::load` checks ran while the configured directories were absent. Validation left the temporary parent empty. A separate creation phase confirmed the names are distinct using successful second `create_dir` calls and canonicalization. The ASCII `cache` / `CACHE` and accented `depósito` / `DEPÓSITO` controls correctly collide and are rejected. There is also a case-sensitive-directory issue. I successfully enabled and queried the case-sensitive flag on a new, private, empty temporary directory (`fsutil` returned 0 for both operations), then verified that `probe` and `PROBE` differ there. With missing `cache` and `CACHE/saves` paths beneath that parent, #61 still returns `is_within = true` and rejects the configuration. The parent remained empty after validation. I ran the identical external probe source and dependency lock against #103 at `8c7eb1ea64a7955550e6cf24f77212b39622812b`. That implementation returns false and accepts these independent paths for both Unicode cases and the case-sensitive-parent control. It still rejects the true ASCII/accented aliases. This comparison covers those controls and the one new exact regression. The attached 34-line test-only regression derives the expected identity from actual directory creation, cross-checks canonicalization, removes its own probe directories, asserts the configured tails are absent, and calls `is_within`. It fails on #61 at the dotted-I pair with `left: true, right: false` (exit 101), and the same test passes when temporarily added to the #103 head. #103 was then restored to its clean source. The proposed #61 diff contains only this regression. Changed-file rustfmt, package Clippy with `-D warnings`, and `git diff --check` pass. Please consider reusing or coordinating with #103's existing Windows ordinal comparison and ancestor case-sensitivity handling for #55. These observations were made on Windows 11/NTFS with Rust 1.98.1. No proposed filesystem controls were skipped, including the case-sensitive-directory setup, and both exact regression runs have zero ignored tests. Other filesystems and non-Windows behavior remain outside this focused audit. Microsoft documents that `CompareStringOrdinal` with ignore-case uses the OS uppercase table, and Windows supports per-directory case-sensitivity flags. [CompareStringOrdinal](https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-comparestringordinal), [case sensitivity](https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity). Run the added regression with the command below. ```powershell cargo test --locked -p victory-core --lib policy::tests::missing_components_follow_filesystem_case_identity -- --exact --nocapture --test-threads=1 ``` AI assistance from Codex covered the audit, synthetic probe, regression and report. <details> <summary>Minimal failing regression against this PR head</summary> ```diff diff --git a/crates/victory-core/src/policy.rs b/crates/victory-core/src/policy.rs index 514a777..b998556 100644 --- a/crates/victory-core/src/policy.rs +++ b/crates/victory-core/src/policy.rs @@ -212,4 +212,38 @@ mod tests { )); } } + + #[cfg(windows)] + #[test] + fn missing_components_follow_filesystem_case_identity() { + for (cache_name, alias_name) in [("cache", "CACHE"), ("İ", "i\u{307}"), ("K", "K")] { + let tmp = tempfile::tempdir().unwrap(); + let cache = tmp.path().join(cache_name); + let alias = tmp.path().join(alias_name); + std::fs::create_dir(&cache).unwrap(); + let equivalent = match std::fs::create_dir(&alias) { + Ok(()) => false, + Err(error) => { + assert_eq!(error.kind(), std::io::ErrorKind::AlreadyExists); + true + } + }; + assert_eq!( + std::fs::canonicalize(&cache).unwrap() == std::fs::canonicalize(&alias).unwrap(), + equivalent + ); + std::fs::remove_dir(&cache).unwrap(); + if !equivalent { + std::fs::remove_dir(&alias).unwrap(); + } + assert_eq!(std::fs::read_dir(tmp.path()).unwrap().count(), 0); + let data = alias.join("saves"); + assert!(!cache.exists() && !data.exists()); + assert_eq!( + is_within(&data, &cache).unwrap(), + equivalent, + "cache {cache_name:?}, data parent {alias_name:?}" + ); + } + } } ``` </details>

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
uiliannn/VItoriaBr!61
No description provided.