benandez's re-review reproduced three escapes the first confinement fix still
left open. A dangling symlink: canonicalize reported it as missing, so the
old confine_to_root walked up to root and accepted it, and write created the
symlink's target for real, outside root. A check-then-use race: confine_to_root
checked one path string and a later fs::read or fs::write resolved that same
string again, a second lookup a concurrently swapped link could land in
between. A hard link: write truncated the shared inode in place, with nothing
in a canonicalized path to show that another name pointed at the same file
outside root.
list, read, write and create now resolve every already segment-checked
relative path through a cap_std::fs::Dir capability opened on root, instead
of joining an absolute OS path and handing it to plain std::fs. cap_std
resolves one path component at a time against real, already-open directory
handles, so a symlink or a Windows junction cannot walk resolution above
root, dangling or not, and there is no separate check with a window for the
directory tree to change underneath it: the one resolution is the open. This
is the same family of guarantee craft-font-store already depends on through
cap-primitives, which cap_std is built on.
write no longer truncates its target in place either way: it writes a new
sibling file and renames it over the target, so a hard link's directory
entry is replaced rather than its shared content being overwritten.
Per that review's non-blocking notes: a name that already exists on disk
with an ordinary ':' or '\' byte (macOS stores a typed '/' as ':') stays
reachable by list and read, since neither character is a path separator on
any platform's filesystem; the stricter refusal now applies only to a name
being chosen by Create. Create also goes back to bringing a fresh root into
existence, matching its behaviour before the first confinement fix. A
Windows reserved device name (CON, COM1, CONIN$, with or without an
extension) is refused in a chosen name on every platform.
Regression tests reproduce all three escapes (dangling symlink, swapped-link
race, hard link), plus the previously missing coverage: a link in the folder
a Create targets, and a write test that actually reaches disk instead of
being refused for an unrelated reason before confinement ever ran. Verified
by hand that each of the three new write-path tests fails against the
pre-fix pattern (an absolute OS path joined by string concatenation) before
trusting them.
FredApps' re-review found that resolve only split on slash and rejected a
segment equal to parent-dir, with no constraint on a Windows backslash, a
drive letter or UNC prefix, or a filesystem link, and that create joined
the Job::Create name onto the resolved folder with no validation of the
name at all.
Every path segment, and a Create name on its own, now goes through one
shared confine_segment check: accepted only when it parses as exactly one
Component::Normal equal to the original text, with a backslash or colon
refused outright first so a Windows-shaped escape cannot slip past a
Linux build's narrower native parser. A second shared check, confine_to_root,
canonicalises the nearest existing ancestor of a resolved path and
confirms it still sits under the canonicalised root, refusing a symlink or
a Windows junction that would otherwise redirect outside it. List, read,
write and create all run both checks before touching disk.
Regression tests cover the review's own examples (a parent segment, an
absolute path, the three Windows-shaped forms) for Create, the same
Windows-shaped escape for a List folder path, and a symlink (Unix) or
junction (Windows) placed inside the root for list, read and write, each
against a sibling sentinel file and directory that must stay untouched.
clippy::unreachable is denied at the crate root with no in-tests
carve-out, unlike unwrap, expect and panic. The three let-else
fallbacks in conflict_tests.rs now panic with a message instead,
matching the pattern used everywhere else in this crate's tests.
Read now stats the file it just read. The returned entry reflects
that read. It no longer echoes the etag of the entry passed in. A
reload after a conflict used to carry the version that was just
refused into the next save, conflicting it again.
Create opens the file with exclusive creation. An exists check no
longer precedes a separate write. Two creates of the same name can no
longer both observe an empty slot and both report success. Regression
tests drive both fixes through craft_ui::cloud's public functions
against a real folder on disk.
Reload from the conflict modal now acts on the conflicted document's
uid. Save as a copy acts on that same uid too. Neither acts on the
active tab anymore. A window with more than one document open keeps
them separate.
Sign-out bumps an account generation. Sign-in bumps it too. Each
clears busy. A job's reply carries the generation it was issued
under. A reply from an older generation gets dropped. A stale session
cannot restore its account or its files over a newer one. A job that
never answers cannot refuse every save afterward. Regression tests
for both pairs of findings run through a held backend that answers
jobs on the test's own schedule.
The current egui pin denies the deprecated egui::WidgetType alias and egui::Id::new. The slice's pages (account, cloud, share, presence, the menu helper) move to egui::Role::Button and egui::Id::unique, the same spellings main's craft-ui already uses.
* xtask: delegate Unix group restoration in report test filesystem
* craft-xlsx: xlsb tests unwrap the zip fixture's Result
#1386 made the test zip writer return Result<Vec<u8>, Error>. The xlsb
tests from #1263, #1323, #1330 and #1337 merged alongside it and still
used the return value as bytes, so `cargo check --workspace --tests`
failed on main with seven E0308 errors in crates/xlsx/tests/xlsb.rs.
These call sites now unwrap the result, as #1386 did for the others.
---------
Co-authored-by: dotCooCoo <RobertLeeLW@gmail.com>