mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 11:56:20 +00:00
- Add host-rendered native IDE primitives (PluginCodeEditor/Monaco, PluginDataGrid/@tanstack/react-virtual, PluginSplitPane, PluginErCanvas) with Shadow DOM slot projection (zero iframes, zero plugin JS in renderer) - Expand Remote DOM budgets, expose full 22 Netcatty semantic CSS tokens, add dblclick/contextmenu/scroll/selection events, cursor-anchored PluginPopover, database theme icon, and full-bleed chrome flag - Add dynamic user-approved TCP/TLS byte streams (incl. localhost opt-in blocking internal control ports), in-band STARTTLS upgrade with cert fingerprint confirmation, durable revocable Vault SSH host bindings, plugin-owned encrypted secrets, native ui.openFile/saveFile streaming handles, 4 MiB clipboard, and prefix-filtered storage.keys - Optimize plugin view image pipeline with pooled sandboxed rasterizer window (auto-destroyed on idle/error/dispose), LRU version+hash cache in PluginViewResources, transient failure eviction in HostDrawnViewHost, renderer-side session deduplication, and RemoteImageElement cache + retry - Temporarily enable plugin host by default in hostBootstrap.cjs (marked TODO(revert), opt-out via NETCATTY_PLUGIN_DEV=0)
31 lines
2.2 KiB
JavaScript
31 lines
2.2 KiB
JavaScript
"use strict";
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const { validatePluginStylesheet } = require("./pluginViewStylePolicy.cjs");
|
|
|
|
test("plugin styling supports ordinary layouts, animation and scoped theme tokens", () => {
|
|
const css = `.layout { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; --plugin-accent: #fa0; color: hsl(var(--foreground)); background: hsl(var(--card)); border-radius: var(--radius); font-family: var(--font-mono); }
|
|
.badge { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); border: 1px solid hsl(var(--input)); outline-color: hsl(var(--ring)); }
|
|
.danger { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
|
|
.menu { background: hsl(var(--popover)); color: hsl(var(--popover-foreground)); font-family: var(--font-sans); }
|
|
.active { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
|
|
@media (max-width: 400px) { .layout { display:flex; flex-direction:column; } }
|
|
@keyframes spin { from { transform:rotate(0deg) } to { transform:rotate(360deg) } }
|
|
.action:hover { animation:spin 1s; color:var(--plugin-accent); }`;
|
|
assert.doesNotThrow(() => validatePluginStylesheet(css));
|
|
});
|
|
|
|
test("plugin CSS rejects network loads, escapes and access outside the surface", () => {
|
|
const attacks = [
|
|
'@import "https://bad.example/a.css";', '@\\69mport "https://bad.example/a.css";',
|
|
'.x{background:url(https://bad.example/x)}', '.x{--plugin-a:url(https://bad.example)}',
|
|
'.x{background:u\\72l(https://bad.example)}', '.x{background:i\\6d age-set("https://bad.example" 1x)}',
|
|
'@font-face{font-family:x;src:url(https://bad.example/font)}', ':host{position:absolute}',
|
|
':host-context(.secret) .x {color:red}', '.x::part(secret){color:red}',
|
|
'.x{position:fixed}', '.x{position:fi\\78 ed}', '.x{--plugin-pos:fixed;position:var(--plugin-pos)}', '.x{background:image("https://bad.example/x")}', '.x{-webkit-app-region:drag}', '.x{background:var(--host-secret)}',
|
|
'.x{--foreground:red}', '.x{content:attr(data-secret)}', '.x{color:red;}\0',
|
|
];
|
|
for (const attack of attacks) assert.throws(() => validatePluginStylesheet(attack), undefined, attack);
|
|
assert.throws(() => validatePluginStylesheet('x'.repeat(131073)));
|
|
});
|