Skip to content

feat(plugins): contract 1.6 with hardened plugin-declared SVG icons - #251

Merged
Hona merged 1 commit into
devfrom
ws6/contract-1.6-plugin-icons
Nov 20, 2026
Merged

Hona merged 1 commit into
devfrom
ws6/contract-1.6-plugin-icons

Conversation

@Hona

@Hona Hona commented Nov 20, 2026

Copy link
Copy Markdown
Member

Ports #64577 (UP-068: GUI plugins declare their own SVG icons) and bumps the Luau plugin contract from 1.5 to 1.6 (including Tone::Accent for #60001).

Summary

  • Contract 1.6 (crates/opencode-plugin-spec/contract.json): bumped to 1.6, added Tone::Accent, updated IconName / ComposerPillView.title / ComposerPillSpec.renderMenu docs, and regenerated all 15 bindings (cargo run -q -p opencode-plugin-spec -- --check green). Plugins built for 1.0–1.5 load unchanged.
  • Hostile-SVG Sanitizer (crates/opencode-plugin-runtime/src/svg/{mod,validate}.rs, #![forbid(unsafe_code)]): iterative XML/SVG parser and canonical re-serializer enforcing hard caps (32 KiB, depth 16, 128 elements, 64 shapes, 16 SMIL animations, 16 KiB / 1,024 path commands, 64 icons per plugin), strict tag/attribute allow-lists (rejecting <script>, <foreignObject>, <image>, <use>, <filter>, DTD/CDATA, on* handlers, and external URLs), and non-zero/non-square viewBox + root presentation-attribute normalization onto an outer <g>. Malformed or oversized icons log a warning and fall back cleanly.
  • Lifecycle & Cross-Surface Resolution: atomic icons::replace_plugin on load/reload, icons::clear_plugin on lifecycle::stop, <plugin>:<name> qualified lookup, and plugin-ID icon resolution wired through settings rail, composer pills, titlebar items, code block actions, panel launchers, single/instance panel tabs, dormant panel launchers, narrow/mobile views, ui.segmented, and persisted closed tabs (PanelsHost::resolve_closed_icon, without waking dormant plugin VMs).
  • Built-in Migration: migrated plugins/pairing/icons/pair.svg and plugins/goal/icons/steer.svg.

Proof (proof/ws6/pr2-icons/)

  • Hostile SVG stress suite: huge-paths-20k (1 MB, 20k paths) 352 ms -> 45 ms; <use> billion-laughs bomb 243 ms -> 41 ms; <feGaussianBlur>/<feTurbulence> filter DoS 115 ms -> 40 ms; 2,000 nested <g> tags rejected; <script>/<foreignObject>/http:/file: rejected with 0 canary hits and fallback icon drawn.
  • Valid contract = "1.0", "1.5", and "1.6" (including unmodified upstream viewBox="1 1 14 14" + <animate> goal SVG) all load and draw centered in dark/light at 1x/1.5x.
  • scripts/guardrails.ps1 (5/5), cargo check --workspace, and scripts/web.ps1 -Check green.

- Bump plugin contract from 1.5 to 1.6 (UP-068 #64577 + Tone::Accent for #60001), regenerating all 15 contract artifacts (opencode.d.luau, plugin.schema.json, api.md, generated Rust bindings). Plugins targeting 1.0-1.5 continue to load unchanged.
- Add #![forbid(unsafe_code)] iterative hostile-SVG sanitizer (crates/opencode-plugin-runtime/src/svg.rs) enforcing hard caps (32 KiB, depth 16, 128 elements, 64 shapes, 16 SMIL animations, 16 KiB / 1024 path commands, 64 icons per plugin), strict tag/attribute allow-lists (rejecting <script>, <foreignObject>, <image>, <use>, <filter>, DTD/CDATA, event handlers, and external URLs), and canonical re-emission normalizing non-zero/non-square viewBox origins and root presentation attributes onto an outer <g>.
- Add atomic per-plugin icon replacement (icons::replace_plugin), unload/disable icon withdrawal (icons::clear_plugin in lifecycle::stop), and <plugin>:<name> qualified cross-surface icon lookup (icons::resolve).
- Route plugin IDs through every host-drawn icon field: settings rail, composer pills, titlebar items, code block actions, panel launchers, single/instance panel tabs, dormant panel launchers, narrow/mobile views, ui.segmented, and persisted closed tabs (PanelsHost::resolve_closed_icon, resolving dormant plugin icons without waking their VMs).
- Migrate built-in plugins/pairing/icons/pair.svg and plugins/goal/icons/steer.svg to plugin-declared icons.
@Hona
Hona merged commit 51986c6 into dev Nov 20, 2026
@Hona
Hona deleted the ws6/contract-1.6-plugin-icons branch November 20, 2026 07:55
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

Hona added a commit that referenced this pull request Nov 20, 2026
…ons in dev builds (#261)

- Allow Figma and common plain-geometry SVG attributes with strict value validation in crates/opencode-plugin-runtime/src/svg/{mod,validate}.rs: clip-rule and fill-rule (nonzero|evenodd only), stroke-dasharray (<= 32 finite entries, sum >= 0.5 to block tiny-dash DoS), stroke-dashoffset, paint-order, shape-rendering, vector-effect (none|non-scaling-stroke), visibility, display (none emitted; block/inline/initial dropped), color, rgb()/rgba()/inherit paints, root overflow/version/xml:space/preserveAspectRatio/percentage dims (when viewBox is present), and validated style declarations (refusing arbitrary CSS properties).
- Keep all security boundaries intact: refuse <script>, <foreignObject>, <style>, <image>, <use>, <filter>, <defs>, <mask>, <clipPath>, on* handlers, href/xlink:href/src/filter/clip-path/mask/marker-*, external URLs/data URIs/url(...), arbitrary CSS, and size/depth/element/shape/path/dash limits.
- Return structured error strings naming the offending element, attribute, or CSS property, and emit a dev-build stderr diagnostic (`plugin <id>: icons/<name>.svg rejected: <reason>`) in icons::replace_plugin and icons::intern_svg so rejected icons are never silent during development.
- Fixes the dialog-wsl warning icon regression introduced by #251 (plugins/wsl/icons/warning.svg uses clip-rule="evenodd").
Hona added a commit that referenced this pull request Nov 20, 2026
…ing (#266)

- Fold verified fleet PRs #247, #251, #252, #253, #254, #255, #256, #257,
  #258, #260, #261, #262, #263, #264, and #265 (Rune #1290 PRE-11 / #1296)
  into docs/upstream-sync/ledger.{json,md}
- Audit upstream anomalyco/opencode through 92d35f8e18 (+9 commits past
  bf683129fa), adding UP-107..UP-113 and assigning UP-106/UP-108/UP-111 to
  BROWSER-UI
- Update scripts/upstream-sync-check.ts to skip pure *.fixture.* test files
  and route browser UI/history vs extensions commits to BROWSER-UI and WS-9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant