From 629751503165118d5fec5f70e64fe2d6592f7b53 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 14 Nov 2026 13:49:42 -0500 Subject: [PATCH 1/4] chore: cut over remaining resvg and roxmltree usages to craft-svg and craft-xml (#14320) * chore: cut over remaining resvg and roxmltree usages to craft-svg and craft-xml * Cut over remaining photocraft-io TIFF tests, rawinfo example, and move exr to dev-dependencies * chore: remove unused zune-jpeg workspace dependency * style: cargo fmt --- Cargo.lock | 8 ++-- Cargo.toml | 3 +- apps/photocraft/Cargo.toml | 6 +-- apps/photocraft/src/icon_theme.rs | 5 +-- apps/photocraft/src/vector_conversion.rs | 10 ++--- crates/engine/Cargo.toml | 2 +- crates/io/Cargo.toml | 3 -- crates/io/src/pdf/tests.rs | 27 +++++++---- crates/io/tests/it/tiff_layers.rs | 57 +++++++++--------------- crates/io/tests/it/tiff_save_options.rs | 8 +++- crates/raw/Cargo.toml | 2 +- crates/raw/examples/rawinfo.rs | 14 +++--- 12 files changed, 68 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4428cb4306..c0e3142ebd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5414,7 +5414,9 @@ dependencies = [ "craft-cms", "craft-flags", "craft-image-codecs", + "craft-svg", "craft-update", + "craft-xml", "dispatch2", "eframe", "egui", @@ -5438,10 +5440,8 @@ dependencies = [ "photocraft-tablet", "photocraft-ui-egui", "plist", - "resvg 0.45.1", "rfd", "ron", - "roxmltree 0.21.2", "rustix 1.1.5", "serde", "serde_json", @@ -5704,10 +5704,8 @@ dependencies = [ "photocraft-text", "photocraft-vector", "proptest", - "roxmltree 0.21.2", "serde_json", "thiserror 2.0.21", - "tiff", "ttf-parser", "zune-core", "zune-jpegxl", @@ -5774,11 +5772,11 @@ dependencies = [ name = "photocraft-raw" version = "0.23.1" dependencies = [ + "craft-image-codecs", "craft-raw", "flate2", "image", "photocraft-raw", - "png 0.18.1", "rayon", "zune-core", "zune-jpegxl", diff --git a/Cargo.toml b/Cargo.toml index bf7ca911a7..1ec3fe6b37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,9 +82,8 @@ bytemuck = { version = "1", features = ["derive"] } flate2 = { version = "1.1.10", default-features = false, features = ["zlib-rs", "runtime_detection"] } encoding_rs = { version = "0.8", default-features = false, features = ["alloc"] } image = { version = "0.25", default-features = false } -# Baseline-JPEG decode of lossy DNG tiles (compression 34892), shared with zune-jpeg. +# Baseline-JPEG decode of lossy DNG tiles (compression 34892). zune-core = "0.5" -zune-jpeg = "0.5" proptest = "1" eframe = { version = "0.37", default-features = false } # Without `default_fonts`, which embeds egui's fonts uncompressed: ui-egui ships them deflated diff --git a/apps/photocraft/Cargo.toml b/apps/photocraft/Cargo.toml index a864529767..0ed338bb97 100644 --- a/apps/photocraft/Cargo.toml +++ b/apps/photocraft/Cargo.toml @@ -42,7 +42,7 @@ thiserror = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tempfile = "=3.27.0" -roxmltree = "0.21" +craft-xml = { workspace = true } craft-update = { workspace = true } rfd = { workspace = true } arboard = { version = "3.7", features = ["wayland-data-control"] } @@ -94,8 +94,8 @@ wl-clipboard-rs = { version = "=0.9.4", default-features = false } # Wayland desktop color selection through the existing XDG portal transport. zbus = "=5.19.0" # Caption button glyphs from the desktop's icon theme (`caption_style.rs`): SVG paths only, no -# text or images. Already in Cargo.lock (photocraft-io); pinned exactly. -resvg = { version = "=0.45.1", default-features = false } +# text or images. Already in Cargo.lock (photocraft-io). +craft-svg = { workspace = true } # Already used by the portal stack; bounded waits let cancelling close the OS request. futures-lite = "=2.6.1" async-io = "=2.6.0" diff --git a/apps/photocraft/src/icon_theme.rs b/apps/photocraft/src/icon_theme.rs index 66647cd1db..16cd47c7cb 100644 --- a/apps/photocraft/src/icon_theme.rs +++ b/apps/photocraft/src/icon_theme.rs @@ -200,7 +200,7 @@ impl IconTheme { /// An SVG's coverage (alpha) as a `px` × `px` mask, the drawing fitted and centred. `None` for an /// unreadable SVG or an absurd size. pub fn rasterize_mask(svg: &[u8], px: u32) -> Option> { - use resvg::{tiny_skia, usvg}; + use craft_svg::tree::{draw, draw::tiny_skia, usvg}; // usvg inflates gzip (`.svgz`) input without a decoded-size limit, and icons are plain `.svg`. if !(1..=256).contains(&px) || svg.starts_with(&[0x1f, 0x8b]) { return None; @@ -221,8 +221,7 @@ pub fn rasterize_mask(svg: &[u8], px: u32) -> Option> { } let s = px as f32 / side; let (dx, dy) = ((px as f32 - size.width() * s) / 2.0, (px as f32 - size.height() * s) / 2.0); - let mut pixmap = tiny_skia::Pixmap::new(px, px)?; - resvg::render(&tree, tiny_skia::Transform::from_scale(s, s).post_translate(dx, dy), &mut pixmap.as_mut()); + let pixmap = draw::render(&tree, tiny_skia::Transform::from_scale(s, s).post_translate(dx, dy), px, px, 0, 64 * 1024 * 1024).ok()?; Some(pixmap.data().as_chunks::<4>().0.iter().map(|[_, _, _, a]| *a).collect()) })) .ok() diff --git a/apps/photocraft/src/vector_conversion.rs b/apps/photocraft/src/vector_conversion.rs index ce473a1b95..f2787511a1 100644 --- a/apps/photocraft/src/vector_conversion.rs +++ b/apps/photocraft/src/vector_conversion.rs @@ -147,9 +147,9 @@ fn export_commands(input: &Path, output: &Path, format: &str) -> Result<[(u8, &' fn source_svg(bytes: &[u8], size: Option<(f64, f64)>) -> Result, String> { let text = std::str::from_utf8(bytes).map_err(|_| "Converted SVG is not UTF-8")?; photocraft_io::svg::import_svg_bounded_with_work("Artwork.svg", bytes, 96_000_000).map_err(|e| format!("Converted SVG is unsupported: {e}"))?; - let doc = roxmltree::Document::parse(text).map_err(|e| format!("Invalid converted SVG: {e}"))?; - let root = doc.root_element(); - if root.tag_name().name() != "svg" { + let root = craft_xml::parse(text.as_bytes()).map_err(|e| format!("Invalid converted SVG: {e}"))?; + let local_name = root.name.rsplit_once(':').map_or(root.name.as_str(), |(_, l)| l); + if local_name != "svg" { return Err("VectorCraft did not return SVG".into()); } let Some((w, h)) = size else { @@ -161,12 +161,12 @@ fn source_svg(bytes: &[u8], size: Option<(f64, f64)>) -> Result, String> // The nested root keeps its own width/height, so the outer viewBox must use the same CSS // pixels: `612pt` is 816 user units at SVG's 96 dpi. Other units are rejected below. let dimension = |key| { - let value = root.attribute(key)?; + let value = root.attr(key)?; let (number, scale) = value.strip_suffix("pt").map_or((value, 1.0), |number| (number, 4.0 / 3.0)); number.parse::().ok().map(|v| v * scale).filter(|v| v.is_finite() && *v > 0.0) }; let (iw, ih) = dimension("width").zip(dimension("height")).ok_or("Converted SVG has no finite dimensions")?; - let inner = text.get(root.range()).ok_or("Invalid SVG root range")?; + let inner = root.to_xml(); let result = format!(r#"{inner}"#) .into_bytes(); diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index 8cc159e9c9..99bf586b28 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -68,7 +68,7 @@ photocraft-io = { workspace = true, features = ["testgen"] } # Synthetic camera raw files for the open tests. photocraft-raw = { workspace = true, features = ["testgen"] } photocraft-testkit = { workspace = true } +exr = { version = "1.73", default-features = false } # WebAssembly text -> binary for plug-in test modules (Apache-2.0 WITH LLVM-exception). wat = "1.228" # Synthetic multi-part EXR fixtures for the parts-commands tests. -exr = { version = "1.73", default-features = false } diff --git a/crates/io/Cargo.toml b/crates/io/Cargo.toml index b3de2eeaf5..7280fa576e 100644 --- a/crates/io/Cargo.toml +++ b/crates/io/Cargo.toml @@ -64,8 +64,6 @@ kurbo = { version = "0.13", optional = true } [dev-dependencies] lopdf = { version = "0.38", default-features = false } -# PDF XMP serialization assertions parse output XML in tests. -roxmltree = "0.21" miniz_oxide = "0.9" crc32fast = "1.5" craft-affinity = { workspace = true, features = ["synth"] } @@ -77,4 +75,3 @@ proptest = { workspace = true } # Lossless JPEG XL encoder for the JPEG XL DNG preview test (tests only), as in photocraft-raw. zune-jpegxl = { version = "=0.5.2", default-features = false, features = ["std"] } zune-core = { workspace = true } -tiff = { version = "0.11", default-features = false, features = ["deflate", "lzw"] } diff --git a/crates/io/src/pdf/tests.rs b/crates/io/src/pdf/tests.rs index 37575545e8..3dd6322c88 100644 --- a/crates/io/src/pdf/tests.rs +++ b/crates/io/src/pdf/tests.rs @@ -442,15 +442,24 @@ fn the_plate_description_joins_the_rdf_element_however_the_packet_spells_it() { d.channels.push(spot("Varnish", photocraft_color::Color::rgb(0.9, 0.9, 0.6), &[1.0; 8])); // The packet must parse as namespaced XML with the plates a description inside its RDF element. let plates_in_rdf = |xmp: &str| { - let tree = roxmltree::Document::parse(xmp.trim_start_matches('\u{feff}')).unwrap_or_else(|e| panic!("{e}: {xmp}")); - let plates = tree - .descendants() - .find(|n| n.tag_name().namespace() == Some(crate::pdf::SPOT_PLATES_NS) && n.tag_name().name() == "plates") - .unwrap_or_else(|| panic!("no pcsp:plates: {xmp}")); - let description = plates.parent_element().unwrap(); - assert_eq!((description.tag_name().namespace(), description.tag_name().name()), (Some(RDF), "Description"), "{xmp}"); - let rdf = description.parent_element().unwrap(); - assert_eq!((rdf.tag_name().namespace(), rdf.tag_name().name()), (Some(RDF), "RDF"), "{xmp}"); + let canon = craft_xml::Canonical::new(&[("rdf", RDF), ("pcsp", crate::pdf::SPOT_PLATES_NS)]); + let tree = craft_xml::Options::canonical(&canon).parse(xmp.trim_start_matches('\u{feff}').as_bytes()).unwrap_or_else(|e| panic!("{e}: {xmp}")); + fn child_els(el: &craft_xml::El) -> impl Iterator { + el.children.iter().filter_map(|n| match n { + craft_xml::Node::El(e) => Some(e), + _ => None, + }) + } + let mut stack = vec![&tree]; + let mut found = false; + while let Some(el) = stack.pop() { + if el.name == "rdf:RDF" && child_els(el).any(|d| d.name == "rdf:Description" && child_els(d).any(|p| p.name == "pcsp:plates")) { + found = true; + break; + } + stack.extend(child_els(el)); + } + assert!(found, "no rdf:RDF/rdf:Description/pcsp:plates: {xmp}"); assert_eq!(xmp.matches("\n\n"; diff --git a/crates/io/tests/it/tiff_layers.rs b/crates/io/tests/it/tiff_layers.rs index 5eb2020e42..e2e3a5b67a 100644 --- a/crates/io/tests/it/tiff_layers.rs +++ b/crates/io/tests/it/tiff_layers.rs @@ -412,44 +412,27 @@ fn damaged_layer_data_opens_flattened_part(part: u64) { /// the file is retagged MinIsBlack first. The result is then a multiband image of every sample, /// which is what libtiff's `TIFFReadScanline` returns and what a RIP walks. fn independent_samples(bytes: &[u8]) -> (u16, Vec, Vec, u32, Vec) { - let mut tags = tiff::decoder::Decoder::new(std::io::Cursor::new(bytes)).expect("tiff tags"); - let spp: u16 = tags.get_tag_unsigned(tiff::tags::Tag::SamplesPerPixel).expect("spp"); - let bps = tags.get_tag_u16_vec(tiff::tags::Tag::BitsPerSample).expect("bps"); - let extra = tags.get_tag_u16_vec(tiff::tags::Tag::ExtraSamples).unwrap_or_default(); - let rows = tags.find_tag_unsigned::(tiff::tags::Tag::RowsPerStrip).ok().flatten().unwrap_or(0); - let patched = photometric_min_is_black(bytes); - let mut dec = tiff::decoder::Decoder::new(std::io::Cursor::new(patched.as_slice())).expect("tiff decode"); - let tiff::decoder::DecodingResult::U8(samples) = dec.read_image().expect("read image") else { - panic!("expected 8-bit samples"); - }; - (spp, bps, extra, rows, samples) -} - -/// Classic-TIFF photometric tag 262 → 1 (MinIsBlack), value stored inline in the IFD entry. -fn photometric_min_is_black(src: &[u8]) -> Vec { - let mut bytes = src.to_vec(); - let le = bytes.first().copied() == Some(b'I'); - let ru16 = |b: &[u8], i: usize| -> Option { - let s = b.get(i..i + 2)?; - Some(if le { u16::from_le_bytes([s[0], s[1]]) } else { u16::from_be_bytes([s[0], s[1]]) }) - }; - let ru32 = |b: &[u8], i: usize| -> Option { - let s = b.get(i..i + 4)?; - Some(if le { u32::from_le_bytes(s.try_into().ok()?) } else { u32::from_be_bytes(s.try_into().ok()?) }) - }; - let Some(ifd) = ru32(&bytes, 4) else { return bytes }; - let Some(n) = ru16(&bytes, ifd as usize) else { return bytes }; - for e in 0..n as usize { - let at = ifd as usize + 2 + e * 12; - if ru16(&bytes, at) == Some(262) { - let value = if le { 1u16.to_le_bytes() } else { 1u16.to_be_bytes() }; - if let Some(slot) = bytes.get_mut(at + 8..at + 10) { - slot.copy_from_slice(&value); + use std::io::Read; + let tiff = craft_tiff::Tiff::parse(bytes).expect("tiff tags"); + let ifd = tiff.ifds.first().expect("ifd0"); + let spp = ifd.u16(craft_tiff::tags::SAMPLES_PER_PIXEL).expect("spp"); + let bps: Vec = ifd.value(craft_tiff::tags::BITS_PER_SAMPLE).expect("bps").to_u64_vec().into_iter().map(|v| v as u16).collect(); + let extra: Vec = ifd.value(craft_tiff::tags::EXTRA_SAMPLES).map(|v| v.to_u64_vec().into_iter().map(|x| x as u16).collect()).unwrap_or_default(); + let rows = ifd.u32(craft_tiff::tags::ROWS_PER_STRIP).unwrap_or(0); + let info = craft_tiff::image::ImageInfo::from_ifd(ifd).expect("tiff info"); + let comp = ifd.u16(craft_tiff::tags::COMPRESSION).unwrap_or(1); + let mut samples = Vec::new(); + for chunk in info.chunks(bytes.len() as u64) { + let raw = craft_tiff::image::chunk_bytes(bytes, &chunk).expect("chunk bytes"); + match comp { + 1 => samples.extend_from_slice(raw), + 8 | 32946 => { + flate2::read::ZlibDecoder::new(raw).read_to_end(&mut samples).expect("deflate"); } - break; + other => panic!("unexpected compression {other} in tiff_layers test"), } } - bytes + (spp, bps, extra, rows, samples) } fn assert_plane(samples: &[u8], spp: usize, plane: usize, expected: &[u8]) { @@ -616,8 +599,8 @@ fn transparent_tiff_without_channels_keeps_image_alpha() { let img = photocraft_codecs::decode(&r.bytes).unwrap(); assert!(img.layout().has_alpha(), "{layers}"); assert!(img.meta.extra_samples.is_empty(), "{layers}"); - let mut dec = tiff::decoder::Decoder::new(std::io::Cursor::new(r.bytes.as_slice())).unwrap(); - let extra = dec.get_tag_u16_vec(tiff::tags::Tag::ExtraSamples).unwrap(); + let parsed = craft_tiff::Tiff::parse(&r.bytes).unwrap(); + let extra: Vec = parsed.ifds[0].value(craft_tiff::tags::EXTRA_SAMPLES).unwrap().to_u64_vec().into_iter().map(|x| x as u16).collect(); assert_eq!(extra, vec![2], "{layers}"); assert!(!r.warnings.iter().any(|w| w.contains("Save Transparency")), "{layers}: {:?}", r.warnings); if layers { diff --git a/crates/io/tests/it/tiff_save_options.rs b/crates/io/tests/it/tiff_save_options.rs index 3bdedc71a3..d3329bf1aa 100644 --- a/crates/io/tests/it/tiff_save_options.rs +++ b/crates/io/tests/it/tiff_save_options.rs @@ -33,8 +33,12 @@ fn save(doc: &Document, layers: bool, transparency: Option) -> ExportResul } fn extra_samples_tag(bytes: &[u8]) -> Vec { - let mut dec = tiff::decoder::Decoder::new(std::io::Cursor::new(bytes)).unwrap(); - dec.get_tag_u16_vec(tiff::tags::Tag::ExtraSamples).unwrap_or_default() + let tiff = craft_tiff::Tiff::parse(bytes).unwrap(); + tiff.ifds + .first() + .and_then(|ifd| ifd.value(craft_tiff::tags::EXTRA_SAMPLES)) + .map(|v| v.to_u64_vec().into_iter().map(|x| x as u16).collect()) + .unwrap_or_default() } /// A TIFF's channel resources: the names in 1006, and the byte lengths of DisplayInfo (1077) diff --git a/crates/raw/Cargo.toml b/crates/raw/Cargo.toml index 462847468b..76410f1340 100644 --- a/crates/raw/Cargo.toml +++ b/crates/raw/Cargo.toml @@ -27,7 +27,7 @@ rayon = { workspace = true } [dev-dependencies] photocraft-raw = { path = ".", features = ["testgen"] } # Writes sRGB PNG previews in the `rawinfo` example. -png = "0.18" +photocraft-codecs = { workspace = true } # JPEG XL encoder used by legacy test fixtures only. zune-jpegxl = { version = "=0.5.2", default-features = false, features = ["std"] } zune-core = "0.5" diff --git a/crates/raw/examples/rawinfo.rs b/crates/raw/examples/rawinfo.rs index dd32a7f8cf..26f4f501c7 100644 --- a/crates/raw/examples/rawinfo.rs +++ b/crates/raw/examples/rawinfo.rs @@ -236,11 +236,13 @@ fn write_png(path: &str, dev: &photocraft_raw::Developed) { } } } - let Ok(f) = std::fs::File::create(path) else { return eprintln!("{path}: cannot create") }; - let mut enc = png::Encoder::new(std::io::BufWriter::new(f), ow as u32, oh as u32); - enc.set_color(png::ColorType::Rgb); - enc.set_depth(png::BitDepth::Eight); - if let Err(e) = enc.write_header().and_then(|mut w| w.write_image_data(&out)) { - eprintln!("{path}: {e}"); + let img = photocraft_codecs::Image::from_u8(ow as u32, oh as u32, photocraft_codecs::ChannelLayout::Rgb, out).unwrap(); + match photocraft_codecs::encode(&img, photocraft_codecs::Format::Png, &Default::default()) { + Ok(png) => { + if let Err(e) = std::fs::write(path, png) { + eprintln!("{path}: {e}"); + } + } + Err(e) => eprintln!("{path}: {e}"), } } From d6557b9a8b40f0542a99e7382ec2b5250548e27b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 14 Nov 2026 14:33:10 -0500 Subject: [PATCH 2/4] docs: reflect the screenshot admission budgets in the security notes (#14780) --- book/src/automation/security-model.md | 6 ++++-- book/src/security/automation-security.md | 6 ++++-- book/src/security/overview.md | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/book/src/automation/security-model.md b/book/src/automation/security-model.md index 405b847d42..351ff4c514 100644 --- a/book/src/automation/security-model.md +++ b/book/src/automation/security-model.md @@ -40,8 +40,10 @@ MCP or control client The current token proves possession of a secret but does not provide general method authorization. Filesystem handles and a defensive command-path policy are implemented; explicit non-filesystem capabilities, session-memory/command-duration budgets, and audit events remain. Preview and -reply ceilings do not bound all document operations or desktop screenshot capture. Private token handling, process -isolation, and least-privileged execution are still practical containment measures. +reply ceilings do not bound all document operations; desktop screenshots are admission-bounded +per image and in aggregate, though that admission is far above the reply ceiling. Private token +handling, process isolation, and least-privileged execution are still practical containment +measures. ## Windows UNC write roots diff --git a/book/src/security/automation-security.md b/book/src/security/automation-security.md index cc65c7dc81..9ba26e561a 100644 --- a/book/src/security/automation-security.md +++ b/book/src/security/automation-security.md @@ -67,8 +67,10 @@ Automation is a privilege boundary because requests can cause filesystem access, or command-duration/cancellation budget; - one thread per accepted TCP connection; - no structured security audit event stream; -- desktop screenshot capture/encoding and document import/export have no automation-specific - operation budgets; the desktop transport limits replies after their creation; +- desktop screenshots are admission-bounded (4 outstanding requests, 128 MiB per image, 256 MiB + aggregate, 8 s deadline), which is far above the 8 MiB JSON reply cap; document import/export + have no automation-specific operation budgets, and the desktop transport limits replies after + their creation; - expensive engine commands are not charged to a session budget. Reply rejection can happen after a command has changed state. Such errors report that the diff --git a/book/src/security/overview.md b/book/src/security/overview.md index 21ce8e85fa..e5449b9342 100644 --- a/book/src/security/overview.md +++ b/book/src/security/overview.md @@ -11,7 +11,7 @@ PhotoCraft processes complex attacker-controlled files and exposes automation th | `.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 | | 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; transport reply caps do not bound desktop screenshot capture | +| 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 | | Releases | Checksums and platform signing/notarization paths when secrets are configured | Signing can be absent; no SBOM generation confirmed in current tree | @@ -22,7 +22,8 @@ The table is a snapshot of the current repository, not a guarantee about deploye 1. Add capability-scoped automation sessions on top of the authenticated transport. 2. Maintain the implemented workspace-handle boundary as file-bearing commands evolve. 3. Extend the preview/reply budgets to JSON complexity, aggregate document/session memory, - desktop capture/import/export, and command duration/cancellation. + desktop import/export, command duration/cancellation, and the gap between screenshot + admission and the reply ceiling. 4. Expand PSD/PSB, codec, and `.pcraft` fuzzing with regression corpora. 5. Add dependency advisories/license policy checks and release SBOMs. From 0fd3210c2058de528b741d192f39315f8331a84c Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:39:15 +0100 Subject: [PATCH 3/4] i18n: move the craft-i18n pin to e56d262 (#14689) Brings in the translations merged to craft-i18n since the last pin. The flatpak manifests name the same commit. Co-authored-by: FredApps --- craft-i18n.rev | 2 +- packaging/linux/flatpak/ai.storyteller.photocraft.bundle.yml | 2 +- packaging/linux/flatpak/ai.storyteller.photocraft.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/craft-i18n.rev b/craft-i18n.rev index d8e79fe337..b91ff589cd 100644 --- a/craft-i18n.rev +++ b/craft-i18n.rev @@ -1 +1 @@ -e02939ef009218e81c44e8ec001fbb7603461de4 +e56d26244bbac099bfd42e23fb12f78a4be418a7 diff --git a/packaging/linux/flatpak/ai.storyteller.photocraft.bundle.yml b/packaging/linux/flatpak/ai.storyteller.photocraft.bundle.yml index c2ee9d5473..1aa4a49861 100644 --- a/packaging/linux/flatpak/ai.storyteller.photocraft.bundle.yml +++ b/packaging/linux/flatpak/ai.storyteller.photocraft.bundle.yml @@ -118,5 +118,5 @@ modules: path: stage - type: git url: https://github.com/storytold/craft-i18n - commit: e02939ef009218e81c44e8ec001fbb7603461de4 + commit: e56d26244bbac099bfd42e23fb12f78a4be418a7 dest: craft-i18n diff --git a/packaging/linux/flatpak/ai.storyteller.photocraft.yml b/packaging/linux/flatpak/ai.storyteller.photocraft.yml index f1958d7709..06efed5f0c 100644 --- a/packaging/linux/flatpak/ai.storyteller.photocraft.yml +++ b/packaging/linux/flatpak/ai.storyteller.photocraft.yml @@ -132,5 +132,5 @@ modules: # The interface translations at the commit in craft-i18n.rev (a test keeps the two equal). - type: git url: https://github.com/storytold/craft-i18n - commit: e02939ef009218e81c44e8ec001fbb7603461de4 + commit: e56d26244bbac099bfd42e23fb12f78a4be418a7 dest: craft-i18n From fd105cccc4ea723b38c010d40cd09980c7b59ab0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 14 Nov 2026 17:31:37 -0500 Subject: [PATCH 4/4] 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. --- book/src/security/overview.md | 1 + crates/automation/src/workspace/tests.rs | 16 ++++++++++++++++ crates/io/src/svg/tests.rs | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/book/src/security/overview.md b/book/src/security/overview.md index e5449b9342..ffa4104804 100644 --- a/book/src/security/overview.md +++ b/book/src/security/overview.md @@ -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 | diff --git a/crates/automation/src/workspace/tests.rs b/crates/automation/src/workspace/tests.rs index d7ff20a3ed..a19a35e7ea 100644 --- a/crates/automation/src/workspace/tests.rs +++ b/crates/automation/src/workspace/tests.rs @@ -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"); diff --git a/crates/io/src/svg/tests.rs b/crates/io/src/svg/tests.rs index d8a60194b3..2fe64fbd87 100644 --- a/crates/io/src/svg/tests.rs +++ b/crates/io/src/svg/tests.rs @@ -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"),