mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-20 17:06:42 +00:00
Pin hardlink write-over behavior in the workspace (#14833)
* io: assert the embedded-SVG depth boundary is blank The deepest-chain test treated any Ok raster as an accepted chain. At MAX_EMBEDDED_SVG_DEPTH + 1 the bounded non-strict path intentionally omits the image and returns a transparent canvas, so the test asserted the opposite of the documented behavior. Check that the over-limit image is blank instead. * automation: pin hardlink write-over behavior A hardlink inside a granted root shares the inode of its other name, so reads can see that content. Document that a write-over atomically replaces the directory entry inside the root and leaves the other name untouched, with a Unix regression test.
This commit is contained in:
1 parent
0fd3210c20
commit
fd105cccc4
3 files changed
+25
-1
No files matched your search
@@ -10,6 +10,7 @@ PhotoCraft processes complex attacker-controlled files and exposes automation th
|
||||
| Raster codecs | Default dimension/pixel/allocation limits; decoder-specific budgets; malformed/property tests; fuzz targets | Continuous fuzzing and more format-specific semantic cases |
|
||||
| `.pcraft` | Manifest/blob/total-byte limits; bounded decompression; CRC/hash and version checks; fuzz target | Tighter complexity/entry limits and directory-bundle path-race analysis |
|
||||
| Engine commands | Error-return contract, focused bad-parameter tests, adversarial `panic_hunt` test | Continue eliminating input-derived panic and exhaustion paths |
|
||||
| Automation filesystem | Separate read roots and one write root held as directory capabilities; traversal and symlink escapes refused; writes are atomic replacements | A hardlink inside a root still reads the inode it names outside the root; writing over it replaces only the link, leaving the outside name unchanged |
|
||||
| Control TCP | Loopback binding; bearer-token authentication; rooted read/write authority; 1 MiB request lines; 8 MiB replies; 16 active connections; I/O timeouts | No general method capabilities, encryption, client identity, explicit JSON-depth policy, aggregate session-memory/command-duration budgets, or audit trail |
|
||||
| MCP | Stdio; typed tools; authenticated and bounded bridge; rooted read/write authority; 256-step batches with aggregate reply budgets; headless preview/output ceilings | No general tool authorization scopes, aggregate session-memory accounting, or command cancellation; desktop screenshot capture is admission-bounded (4 outstanding requests, 128 MiB per image, 256 MiB aggregate, 8 s deadline) but that admission is far above the 8 MiB reply cap |
|
||||
| Dependencies | Cargo lockfile and normal CI build/test/clippy | No `cargo-audit` or `cargo-deny` job/configuration confirmed in current tree |
|
||||
|
||||
@@ -1499,6 +1499,22 @@ fn same_root_leaf_link_save_replaces_the_link_without_writing_its_target() {
|
||||
assert!(!std::fs::symlink_metadata(inside.join("link.png")).unwrap().file_type().is_symlink());
|
||||
}
|
||||
|
||||
/// A hardlink inside a root names the outside inode, so it reads that content. Writing over it is
|
||||
/// an atomic replace of the directory entry: the other name and its inode keep their bytes.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn hardlink_inside_a_root_reads_the_target_but_write_over_replaces_the_link() {
|
||||
let (inside, outside, workspace) = roots("hardlink");
|
||||
let target = outside.join("target.png");
|
||||
std::fs::write(&target, b"outside").unwrap();
|
||||
std::fs::hard_link(&target, inside.join("linked.png")).unwrap();
|
||||
|
||||
assert_eq!(workspace.read("linked.png").unwrap(), b"outside");
|
||||
workspace.write("linked.png", b"replacement").unwrap();
|
||||
assert_eq!(std::fs::read(&target).unwrap(), b"outside", "the outside inode is not modified");
|
||||
assert_eq!(std::fs::read(inside.join("linked.png")).unwrap(), b"replacement");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn directory_pcraft_uses_ordered_roots_without_falling_back_after_selection() {
|
||||
let (library, work, _) = roots("pcraft-ordered");
|
||||
|
||||
@@ -1045,7 +1045,14 @@ fn the_deepest_chain_of_embedded_svg_images_fits_a_small_stack() {
|
||||
for levels in 1..=MAX_EMBEDDED_SVG_DEPTH + 1 {
|
||||
match rasterize_bounded(chain(levels).as_bytes(), 1.0, MAX_RASTER_PIXELS) {
|
||||
Ok(buf) => {
|
||||
assert!(buf.px[4 * 8 + 4][3] > 0.99, "{levels} levels: the innermost rect draws through every level");
|
||||
let drawn = buf.px[4 * 8 + 4][3] > 0.99;
|
||||
if levels > MAX_EMBEDDED_SVG_DEPTH {
|
||||
// A chain past the limit is left out rather than rejected; it must not
|
||||
// still draw its innermost image through the exhausted depth budget.
|
||||
assert!(!drawn, "{levels} levels: the too-deep image is left out");
|
||||
break;
|
||||
}
|
||||
assert!(drawn, "{levels} levels: the innermost rect draws through every level");
|
||||
accepted = levels;
|
||||
}
|
||||
Err(_) => assert!(accepted > 0, "a one-level chain renders"),
|
||||
|
||||
Reference in new issue
Block a user