Repository navigation
[bugfix] desktop: grant the renderer permissions the shell controls use #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Zhangbo-cn
wants to merge
15
commits into
ThinkFlowLab:main
Choose a base branch
from
Zhangbo-cn:fix/desktop-renderer-permissions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−5
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
59c0117
[bugfix] desktop: grant the renderer permissions the shell controls use
ffbf3bb
[bugfix] desktop: report the clipboard value the smoke actually read
f7dcd6e
[bugfix] desktop: keep the clipboard permission the click actually as…
5db77fd
Merge remote-tracking branch 'origin/main' into fix/desktop-renderer-…
Zhangbo-cn a30281d
Merge remote-tracking branch 'origin/main' into fix/desktop-renderer-…
aa79bd3
[bugfix] desktop: grant only the renderer permissions the UI calls
a20a5b9
Merge remote-tracking branch 'origin/main' into fix/desktop-renderer-…
98f8239
[bugfix] desktop: scope permission requests by their own URL
26b115d
[bugfix] desktop: assert the clipboard read, not an unactivated write
05f6f09
[docs] desktop: correct what the clipboard probe established
6ae9fd3
Merge remote-tracking branch 'origin/main' into fix/desktop-renderer-…
843df69
[bugfix] desktop: poll the close assertion instead of observing once
d049f6b
[docs] desktop: describe the clipboard evidence accurately
7c97765
[ci] checks: rerun release checks after the assistant-lane flake
9ef7764
[bugfix] desktop: await the clipboard restore and guard the close poll
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { ownedURL } from './host.mjs'; | ||
|
|
||
| const granted = new Set(['clipboard-sanitized-write', 'fullscreen', 'automatic-fullscreen']); | ||
|
|
||
| export function permissionGranted(permission, requestingUrl) { | ||
| if (!granted.has(permission)) return false; | ||
| try { | ||
| return ownedURL(requestingUrl); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { permissionGranted } from '../src/permissions.mjs'; | ||
|
|
||
| const app = 'opendirector://app/'; | ||
| const allowed = ['clipboard-sanitized-write', 'fullscreen', 'automatic-fullscreen']; | ||
|
|
||
| test('The application page receives the permissions its controls use', () => { | ||
| for (const permission of allowed) { | ||
| assert.equal(permissionGranted(permission, app), true, permission); | ||
| assert.equal(permissionGranted(permission, 'opendirector://app/canvas?x=1'), true, permission); | ||
| assert.equal(permissionGranted(permission, 'opendirector://app'), true, permission); | ||
| } | ||
| }); | ||
|
|
||
| test('Clipboard reads stay denied while sanitized writes are granted', () => { | ||
| assert.equal(permissionGranted('clipboard-read', app), false); | ||
| assert.equal(permissionGranted('clipboard-read', 'opendirector://app/canvas'), false); | ||
| assert.equal(permissionGranted('clipboard-sanitized-write', app), true); | ||
| }); | ||
|
|
||
| test('Other renderer permissions stay denied', () => { | ||
| for (const permission of ['media', 'display-capture', 'geolocation', 'notifications', | ||
| 'midi', 'pointerLock', 'openExternal', 'fileSystem', 'serial', 'usb', 'unknown', '']) { | ||
| assert.equal(permissionGranted(permission, app), false, permission); | ||
| } | ||
| }); | ||
|
|
||
| test('The granted permissions do not extend to other origins', () => { | ||
| for (const origin of ['https://example.com/', 'file:///C:/tmp/a.html', 'opendirector://other/', | ||
| 'opendirector://app:8080/', 'opendirector://app@evil.com/', 'opendirector://x.app/', | ||
| '', undefined, null, 'null', 'not a url']) { | ||
| for (const permission of allowed) { | ||
| assert.equal(permissionGranted(permission, origin), false, `${permission} on ${String(origin)}`); | ||
| } | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:这里实际覆盖的是「点击写入成功、读取被拒」,没有断言所有无激活写入被拒。开发文档也明确说这不是当前保证。建议把 PR 摘要改成与这里一致;如果「只允许真实用户手势写入」是产品要求,就单独明确这个边界,再为它补安装包回归。