Repository navigation
Conversation
|
Friendly ping for review — the package is already live, so this PR is the last step:
If you'd rather host it in this repo (name |
yetone
left a comment
There was a problem hiding this comment.
Thanks for this, @cty1735. I read every file of magpie-select-translate@0.1.1 from npm and the helper's Go source, rebuilt helper.exe from it (it matches apart from the build id and vcs stamps), and ran the helper on a Windows box. I can't merge it yet. The first item is a security problem.
Must fix
-
Any web page can change the helper's settings. The helper's local API (
internal/api/server.go,guardHost) checks only thatHostis a loopback name. It doesn't checkOrigin, and it acceptstext/plainPOSTs, which a browser sends cross-site without a preflight. So a page open in any browser can rewrite/api/settings. In a test on Windows that let a page:- point
gatewayat its own server. The next Alt+D then sent the selected text, with the magpie gateway key as the Bearer token, to that server. - point
glossaryFileat any local file. Its contents then went out in the prompt.
/api/clipboardis open the same way. Please refuse every request that carries a browserOrigin(or require a per-install token that only the page gets), requireContent-Type: application/jsonon writes, and limitglossaryFileto a file the user picked in the page. - point
-
The package doesn't load. The published
package.jsonstarts with a UTF-8 BOM. Bun'sJSON.parseand magpie'sinternal/plugin/page.go(json.Unmarshal) both reject it, so the page never opens. -
"community": truein registry.json. That flag shows the "magpie community" shield, which means the package lives in this repo. A third-party package leaves it out, as the other 11 do. -
The summary says it "reads nothing". The helper reads magpie's
caller-keys.jsonfor the gateway key. Please say so.
Checked and fine
- Port 3477 is used by nothing in magpie.
- The only outbound calls go to the configured gateway.
- The key is kept in memory only, and logs record timings and character counts, never text.
- The clipboard is saved and put back, and terminals, Explorer, Remote Desktop and password managers are skipped. One note: formats other than text are lost when the clipboard is put back.
bun scripts/check.mjsat ffdd22f passes.
Since 0.1.1 is already on npm, please fix item 1 in a new version soon, even before this is listed. Once it's out, I'll run the same checks again.
|
All four fixed in 0.2.1 (repo commit 1. Cross-site writes (the security one) —
Tests added: I chose "refuse all Origins" over a per-install token because the helper is a standalone exe that also has to work with the page absent; a token would need a handshake the sandboxed page can't do ( 2. BOM — 3. 4. Summary wording — no longer says "reads nothing". It now says the helper reads On your note about non-text clipboard formats: correct, and it's in the README's known trade-offs (
|
b0f279d to
f24cf17
Compare
|
0.2.1 is on npm now ( Checked against the published tarball (fetched back from the registry, not the local build):
Local run of the built helper on 3499: Also fixed while here: an upgraded plugin reused whatever helper was already installed, so users who upgraded kept running the old exe — the bundled one now wins. The registry entry on this branch has On the clipboard note: yes, only text is put back; other formats are dropped. I'd rather fix that properly than paper over it, so it stays as is for now. |
f24cf17 to
b82e7b1
Compare
|
0.2.2 is on npm ( |
|
Re-reviewed at head b82e7b1 against the npm 0.2.2 tarball (shasum The 11-12 points
One left, smaller Merge status |
Adds Select Translate to the market: a page plugin plus a local helper.
Alt+D, and a popover next to the cursor streams the translation from the user's own magpie gateway.magpie-select-translate(npm), version 0.1.1. Not a@magpie-community/*package; maintained at https://github.com/cty1735/magpie-select-translate.index.mjsexports{id, server};server()pings127.0.0.1:3477/api/pingand starts the bundled helper if it isn't running. No imports, no build step.bin/helper.exe(Go, windows/amd64, ~6.3 MB, CGO off, no runtime needed). It only listens on127.0.0.1, validatesHost, never logs the source text, and restores the clipboard after reading the selection. Source: the repository above.connect-src 'none'); reads nothing from magpie, onlymagpie.options.get/set. Nopermissionsdeclared on purpose.Tested on Windows 11:
magpie plugin add npm:magpie-select-translateinstalls, the page shows, and the helper registers the hotkey within a second.