Repository navigation
Conversation
file.importFigma brings Figma frames and layers in as native, editable layers (comps/precomps, group nulls, shape layers with editable paths, fills, gradients, strokes, text with style runs, track mattes, layer styles, Gaussian Blur), from a Figma link via the REST API (system curl, token from FIGMA_TOKEN / figma.setToken, never journaled) or from node JSON passed in. Image fills and unsupported nodes come in as 2x PNG renders. One undo step per import. effectcraft-cli figma-bridge is the local HTTP endpoint for the Figma plug-in in integrations/figma. Co-Authored-By: Claude <noreply@anthropic.com> (cherry picked from commit 8836faa) (cherry picked from commit ae6f1da39093854a2539696fbfe025cd20843c01) (cherry picked from commit 5989be7) (cherry picked from commit 56f4d2aaccfd6985486f2da5fa00440864786b56)
…d bridge pairing From the review of storytold#858: - Requests that carry X-Figma-Token never pass -L (curl forwards custom headers to redirect targets; Figma's API doesn't redirect). Only the token-less pre-signed image download follows redirects (at most 5). Every request is HTTPS-only (--proto/--proto-redir =https); plain HTTP only for a loopback apiBase (tests). The options come from curl_args, unit-tested. - figma.setToken and the bridge's pairing-code file are created with mode 0600 (figma::write_private: OpenOptions + mode; an existing wider file is narrowed first) instead of write-then-chmod. - figma-bridge: pairing code from the OS CSPRNG (getrandom, rejection-sampled, 12 of 32 letters); after 5 wrong codes in a row codes are refused for 60 s (429), a right code resets the count; bodies capped at 64 MB (413); --code needs 8+ characters; the Host header must be the loopback address (no DNS rebinding). Tests: engine figma (12), cli figma_bridge (6). (cherry picked from commit 589a910, adapted to the bridge in apps/effectcraft-cli) (cherry picked from commit 6ebb351b9a8a680cfd19aa9cfcd2089b629c1a3f)
…told#858); reply 858 has PR numbers
|
Thank you for this, @eliasx45! We've held this one, because it's a large bundle (~4.8k lines) with some security problems to fix first:
Separately, the maintainers still need to decide whether a local HTTP bridge and curl-based Figma fetching belong in core. If you are not on our Discord yet, please join us: https://discord.gg/artcraft |
…ckout, private payloads, confinement Review on storytold#1103: - apiBase is parsed strictly: only http:// to a loopback IP literal with a numeric port, so http://127.0.0.1:80@evil.com (and host names) never get X-Figma-Token. - Payload images must be inline base64 / data URLs: a forwarded payload can't make the app read a local file. - No lockout after wrong pairing codes (any sandboxed page could lock the plug-in out); the 60-bit code is the protection, and --code now needs 12 characters. - Payloads go to a per-user 0700 folder under random names, created exclusively, 0600. - Confinement: file.importFigma's payloadPath is read-checked and its image folder (beside the project) write-checked; figma.setToken is refused while confined. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014d65YdNxQmjRkbXRtP2NwH
|
@echelon Thanks. Fixed all four: the token only goes to a loopback IP literal, payload images must be inline, there's no pairing lockout (and a 12-character code), payloads are private (0700/0600), and confinement covers the import and figma.setToken. |
Add a bounded native-only clipboard receiver and normal Paste routing, with actionable unsupported-visual warnings and one-step undo. Preserve destination timing, standalone rendered bounds, affine linear gradient direction, and redo focus when no composition remains active. Validation: scoped engine/UI cargo check and clippy --all-targets with warnings denied, native app build, and actual cross-app UI clipboard/edit/undo/redo/render/save-reopen checks passed. Regression tests compiled but were not executed under the fork daytime rule; no full CI. Text metrics remain visibly different and warned; parity scores are unchanged. (cherry picked from commit f01f2e0)
Recognize the bounded FigCraft metadata carrier before generic SVG paste, preserve explicit JSON and text-editing routes, and reject damaged or ambiguous metadata without fallback. Permit SVG path strings only in native geometry entries. Validation: scoped engine/UI check and clippy --all-targets with warnings denied and native app build passed. Actual right-click Copy and Cmd+C through the OS clipboard pasted ten native editable layers, with no images; undo/redo, independent copies, malformed-carrier rejection, save/reopen and stroke/shadow bounds passed native QA. Regression tests compiled but were not executed under daytime rules; no full CI. Text-metric differences remain warned. (cherry picked from commit 3a3a1a9)
(cherry picked from commit 796f37e)
A writable project path does not prove sibling asset directories stay inside the write roots: a symlink can escape. Reject native FigCraft paste in confined automation until assets can be checked at their actual destination. Desktop paste remains available. Adds a symlink regression, compiled by strict all-target automation Clippy; tests not executed under daytime policy.
|
@echelon The follow-up hardening is pushed: REST downloads use bounded stdout pipes, dry-run plans expose the exact asset destinations for confinement checks, and unresolved symlinks are rejected. Latest native clipboard contributions are preserved; clipboard paste is refused while confined. Formatting and strict workspace/all-target Clippy pass. Focused downloader and confinement regressions pass, including both post-integration confinement tests. Full runtime CI and visual clipboard QA were not rerun. The HTTP bridge/curl-in-core policy question remains for maintainers. |
|
Hi @eliasx45, thanks for this PR! Most of the conflict comes from the shared module layout (#2491), which moved or split files this PR touches:
When you rebase, please also make sure it fits the other recent changes:
CI ( |
What
Transfer designs into native, editable EffectCraft layers from Figma or FigCraft. This extends the existing Figma transfer contribution (the Figma part of #858) with one-time FigCraft Copy/Paste and shared rendering fixes.
file.importFigmaaccepts node JSON from the transfer plug-in/MCP, or a Figma link through the REST API. The plug-in inintegrations/figma/pluginuses the localeffectcraft-cli figma-bridgeHTTP endpoint to forward into the app's control channel. Supported shapes/text become editable layers; unsupported Figma nodes use PNG renders.edit.pasteFigCraft; explicit JSON is accepted too. Each paste is independent and one undo step, with no live link. Text editing and ordinary SVG paste retain their own routes. Frames create compositions; other selections use the active composition and its timing.Companion FigCraft Copy/export support: storytold/figcraft#535.
Validation and security
edit.pasteFigCraft, because checking the project path alone does not prevent sibling asset-directory symlinks from escaping the write root. Ordinary desktop paste is unaffected.How tested
The original Figma contribution recorded 12 focused engine tests and 6 bridge tests. For this extension, the already-integrated fork was verified through the native apps: 529/529 frames pasted and passed Undo, with no blank targets or size-limit failures; 953 stored bitmap files matched their original bytes, and four saved/reopened projects rendered identically. Synthetic sampled gradient interiors differed by at most 1/255 per channel and both text lines occupied matching ink bands. These are scoped observations, not universal pixel-parity claims.
This upstream branch was adapted to #1103's older PNG-only Figma mapper while preserving its security fixes. Fresh branch checks passed:
rustfmt --check,git diff --check, and strict all-target Clippy (which compiles test targets) foreffectcraft-project,effectcraft-render,effectcraft-engine,effectcraft-ui-eguiandeffectcraft-automation. Added regression coverage includes malformed carriers/assets, bitmap placement, overflow, multiple shadows, gradients, text metrics, text-edit paste routing and automation confinement including a sibling-directory symlink regression.Not run for this update: full CI, Rust regression execution (the fork's daytime policy requires compilation only), a new native build/UI pass on this upstream branch, or the Figma plug-in end to end. Pattern/tiled fills, image colour filters/strokes and some advanced text/effects remain warned unsupported; minor rasterization differences remain.
Review hardening update
Integrated current upstream main and retained the latest native clipboard/bitmap contributions. REST downloads now use bounded stdout pipes instead of predictable shared temporary files. Import dry runs report exact output paths, and confinement checks those paths (including dangling symlinks); clipboard paste remains refused under confinement.
Final-tree formatting and strict workspace/all-target release Clippy passed. Focused downloader and confinement regressions passed, including both confinement tests after the latest clipboard integration. Full runtime CI and visual clipboard QA were not rerun for this update. The local HTTP bridge/curl architecture remains a maintainer decision.