-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
src,permission: disable WASI when pm is enabled #53124
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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,25 @@ | ||
| #include "permission/wasi_permission.h" | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace node { | ||
|
|
||
| namespace permission { | ||
|
|
||
| // Currently, WASIPermission manage a single state | ||
| // Once denied, it's always denied | ||
| void WASIPermission::Apply(Environment* env, | ||
| const std::vector<std::string>& allow, | ||
| PermissionScope scope) { | ||
| deny_all_ = true; | ||
| } | ||
|
|
||
| bool WASIPermission::is_granted(Environment* env, | ||
| PermissionScope perm, | ||
| const std::string_view& param) const { | ||
| return deny_all_ == false; | ||
| } | ||
|
|
||
| } // namespace permission | ||
| } // namespace node |
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,31 @@ | ||
| #ifndef SRC_PERMISSION_WASI_PERMISSION_H_ | ||
| #define SRC_PERMISSION_WASI_PERMISSION_H_ | ||
|
|
||
| #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
|
|
||
| #include <vector> | ||
| #include "permission/permission_base.h" | ||
|
|
||
| namespace node { | ||
|
|
||
| namespace permission { | ||
|
|
||
| class WASIPermission final : public PermissionBase { | ||
| public: | ||
| void Apply(Environment* env, | ||
| const std::vector<std::string>& allow, | ||
| PermissionScope scope) override; | ||
| bool is_granted(Environment* env, | ||
| PermissionScope perm, | ||
| const std::string_view& param = "") const override; | ||
|
|
||
| private: | ||
| bool deny_all_; | ||
| }; | ||
|
|
||
| } // namespace permission | ||
|
|
||
| } // namespace node | ||
|
|
||
| #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | ||
| #endif // SRC_PERMISSION_WASI_PERMISSION_H_ |
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,22 @@ | ||
| // Flags: --experimental-permission --allow-wasi --allow-fs-read=* | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| common.skipIfWorker(); | ||
|
|
||
| const assert = require('assert'); | ||
| const { WASI } = require('wasi'); | ||
|
|
||
| // Guarantee the initial state | ||
| { | ||
| assert.ok(process.permission.has('wasi')); | ||
| } | ||
|
|
||
| // When a permission is set by cli, the process shouldn't be able | ||
| // to create WASI instance unless --allow-wasi is sent | ||
| { | ||
| // doesNotThrow | ||
| new WASI({ | ||
| version: 'preview1', | ||
| }); | ||
| } |
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,19 @@ | ||
| // Flags: --experimental-permission --allow-fs-read=* | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| const assert = require('node:assert'); | ||
|
|
||
| const { WASI } = require('wasi'); | ||
|
|
||
| { | ||
| assert.throws(() => { | ||
| new WASI({ | ||
| version: 'preview1', | ||
| preopens: { '/': '/' }, | ||
| }); | ||
| }, common.expectsError({ | ||
| code: 'ERR_ACCESS_DENIED', | ||
| permission: 'WASI', | ||
| })); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.