Repository navigation
MCP: confined exports refuse native files that name a linked JavaScript file outside the read roots - #7600
MCP: confined exports refuse native files that name a linked JavaScript file outside the read roots#7600dotCooCoo wants to merge 8 commits into
Conversation
…pt file outside the read roots Under --automation-read-root, a document that links a JavaScript file outside the read roots could still be written by a confined caller to any output that carries the native document, and that document holds the stored path. SVG and SVGZ output was already refused. This change applies the same control to every output that carries the native document, and they now return the same error, "a linked JavaScript file is outside the read roots", without the path: - document.serialize, document.export, document.exportSelection and document.exportEps for vectorcraft, template, EPS, .ai and .ait files (not a legacy version 7 .ai file, a .ai file of some of the artboards, or one of the art's bounds) - PDF with Preserve Editing on, as its preset, standard and options leave it, when it holds every artboard, including document.exportPdf - document.save, file.saveAs and file.saveAsTemplate - document.exportForScreens and assets.export, checked with the artboards each file is written with - file.exportAs in the app - file.package, before the folder is made, including when a linked native document, or the native document a linked PDF, .ai or EPS file carries, links such a file Outputs that do not carry the native document, unconfined callers and linked files inside the read roots are written as before.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Follows #7264.
What and why
#7264 refuses an SVG or SVGZ export by a caller confined with
--automation-read-rootwhen the document links a JavaScript file outside the read roots. The native document stores the same linked file paths, so every other output that carries the native document now gets the same control, with the sameBadParamserror, "a linked JavaScript file is outside the read roots", which names no file or folder. A JavaScript Files entry can be a file picked from the computer or a typed URL (the help page). The read roots and this refusal are VectorCraft's own rules.check_linked_scripts(crates/engine/src/cmd/fileio/access.rs) now takes the effective options and asksnames_linked_scriptswhether the output carries the native document: native files and templates and EPS files always do; a.aior.aitfile does unless it is a legacy version 7.aifile, has only some of the artboards, or is a.aifile of the art's bounds (useArtboards: false); a PDF does when Preserve Editing is on, as its preset, standard and options leave it, and it holds every artboard. A PDF saved with Preserve Editing holds the full editable document (the help page).document.serialize,document.export,document.exportSelectionanddocument.exportEpscheck after presets are expanded.document.exportPdfgains the check.document.save,file.saveAs,file.saveCopyandfile.saveAsTemplatecheck with the save's final options; a.aisave always has every artboard, souseArtboardsdoes not exempt it.document.exportForScreensandassets.exportcheck each file with the artboards and options it is written with, before the folder is made: a PDF per artboard leaves the editing data out and is written, while one PDF of every artboard or Full Document's PDF with Preserve Editing is refused.file.exportAsin the app (crates/ui-egui/src/io/export.rs) checks with a saved PDF preset expanded.file.package(crates/engine/src/cmd/package.rs) checks the document before anything is collected or written, and checks each linked native document, and the native document a linked PDF,.aior EPS file carries, before copying it. A package gathers the document with its linked graphics and the fonts it uses, and adds a report (the help page).document.serialize,document.export,document.exportSelection,document.exportForScreens,document.exportPdf,document.save(which also coversfile.saveAsandfile.saveCopy),file.saveAsTemplate,file.packageandfile.exportAs,docs/mcp.md(Confining file access, Preserve Editing, Package) and one line indocs/target-app-parity.mddescribe the refusal. No user-visible string changed.This changes existing behavior for confined callers only: these outputs were written before and are now refused. Outputs without the native document (images, a PDF without Preserve Editing, a PDF or
.aifile of some artboards or of the art's bounds, a legacy.aifile), linked files inside the read roots, URLs and the person at the keyboard are written as before.How it was tested
New tests, each failing without the change:
confined_native_output_refuses_a_linked_javascript_file_outside_the_read_roots(crates/engine/src/tests/interactivity.rs): native, template, PDF,.aiand EPS output fromdocument.serialize,export(alsoselectedOnly),exportSelection,exportPdf,exportEps, the saves,exportForScreens,assets.exportandfile.packageare refused withBadParamsand the exact message, which names neither folder nor the file; no file is written and the document keeps the link.confined_output_without_the_document_or_with_scripts_the_caller_may_read_is_written(same file): a PDF without Preserve Editing, a PDF or.aifile of the art's bounds or of one artboard, a legacy.aifile, a PNG and per-artboard Export for Screens PDFs are written; one PDF of both artboards and Full Document's PDF are refused; a JavaScript file inside the roots, a relative path and a URL stay in the native document and the PDF editing data, and the package is written.a_confined_package_refuses_a_linked_javascript_file_outside_the_read_root(crates/engine/src/tests/package.rs): a package of the document, or of a document that links such a native file or PDF with Preserve Editing, is refused for a folder and a ZIP, and nothing is written; the unconfined package copies it, and a JavaScript file inside the roots is packaged.control_native_export_refuses_a_linked_javascript_file_outside_the_read_root(crates/ui-egui/src/tests/automation.rs):app.exportto PDF,.aiand EPS andfile.exportAsto a native file over the control connection are refused and write nothing; a PDF without Preserve Editing is written, and the person'sfile.exportAskeeps the link.Focused checks on the final tree, one commit on
mainata47d7eec912, which was still the head ofmainwhen this was posted:cargo fmt --all -- --checkcargo check --workspace --testscargo clippy -p vectorcraft-engine -p vectorcraft-ui-egui -p vectorcraft-mcp --all-targets -- -D warningscargo test -p vectorcraft-engine --lib, filtered totests::interactivity,tests::packageand the Export for Screens tests: 98 passedcargo test -p vectorcraft-ui-egui --lib, filtered tocontrol_native_export_refuses,scriptandexport_selection: 95 passedcargo xtask brands,cargo xtask layers(30 crates),cargo xtask assets(337 files) andcargo xtask ui-commands --checkcargo xtask ciruns in this pull request's CI.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.Summary by CodeRabbit