| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac920e0 commit 521aaf1
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -954,6 +954,7 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 954 | 954 | ||
| 955 | 955 | if (options_->permission || options_->permission_audit) { | |
| 956 | 956 | permission()->EnablePermissions(); | |
| 957 | + static const std::array args = {std::string("*")}; | ||
| 957 | 958 | if (options_->permission_audit) { | |
| 958 | 959 | permission()->EnableWarningOnly(); | |
| 959 | 960 | } | |
@@ -962,29 +963,29 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 962 | 963 | // unless explicitly allowed by the user | |
| 963 | 964 | if (!options_->allow_addons) { | |
| 964 | 965 | options_->allow_native_addons = false; | |
| 965 | - permission()->Apply(this, {"*"}, permission::PermissionScope::kAddon); | ||
| 966 | + permission()->Apply(this, args, permission::PermissionScope::kAddon); | ||
| 966 | 967 | } | |
| 967 | 968 | if (!options_->allow_inspector) { | |
| 968 | 969 | flags_ = flags_ | EnvironmentFlags::kNoCreateInspector; | |
| 969 | - permission()->Apply(this, {"*"}, permission::PermissionScope::kInspector); | ||
| 970 | + permission()->Apply(this, args, permission::PermissionScope::kInspector); | ||
| 970 | 971 | } | |
| 971 | 972 | if (!options_->allow_child_process) { | |
| 972 | 973 | permission()->Apply( | |
| 973 | - this, {"*"}, permission::PermissionScope::kChildProcess); | ||
| 974 | + this, args, permission::PermissionScope::kChildProcess); | ||
| 974 | 975 | } | |
| 975 | 976 | if (!options_->allow_ffi) { | |
| 976 | - permission()->Apply(this, {"*"}, permission::PermissionScope::kFFI); | ||
| 977 | + permission()->Apply(this, args, permission::PermissionScope::kFFI); | ||
| 977 | 978 | } | |
| 978 | 979 | if (!options_->allow_openssl_store) { | |
| 979 | 980 | permission()->Apply( | |
| 980 | - this, {"*"}, permission::PermissionScope::kOpenSSLStore); | ||
| 981 | + this, args, permission::PermissionScope::kOpenSSLStore); | ||
| 981 | 982 | } | |
| 982 | 983 | if (!options_->allow_worker_threads) { | |
| 983 | 984 | permission()->Apply( | |
| 984 | - this, {"*"}, permission::PermissionScope::kWorkerThreads); | ||
| 985 | + this, args, permission::PermissionScope::kWorkerThreads); | ||
| 985 | 986 | } | |
| 986 | 987 | if (!options_->allow_wasi) { | |
| 987 | - permission()->Apply(this, {"*"}, permission::PermissionScope::kWASI); | ||
| 988 | + permission()->Apply(this, args, permission::PermissionScope::kWASI); | ||
| 988 | 989 | } | |
| 989 | 990 | ||
| 990 | 991 | // Implicit allow entrypoint to kFileSystemRead | |
@@ -1019,7 +1020,7 @@ Environment::Environment(IsolateData* isolate_data, | |||
| 1019 | 1020 | } | |
| 1020 | 1021 | ||
| 1021 | 1022 | if (options_->allow_net) { | |
| 1022 | - permission()->Apply(this, {"*"}, permission::PermissionScope::kNet); | ||
| 1023 | + permission()->Apply(this, args, permission::PermissionScope::kNet); | ||
| 1023 | 1024 | } | |
| 1024 | 1025 | } | |
| 1025 | 1026 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -223,8 +223,8 @@ BaseObjectPtr<Channel> Channel::Get(Environment* env, std::string_view name) { | |||
| 223 | 223 | HandleScope handle_scope(isolate); | |
| 224 | 224 | Local<Context> context = env->context(); | |
| 225 | 225 | Local<Value> argv[] = { | |
| 226 | - ToV8Value(context, name).ToLocalChecked(), | ||
| 227 | - Integer::NewFromUnsigned(isolate, index), | ||
| 226 | + ToV8Value(context, name).ToLocalChecked(), | ||
| 227 | + Integer::NewFromUnsigned(isolate, index), | ||
| 228 | 228 | }; | |
| 229 | 229 | Local<Value> result; | |
| 230 | 230 | if (binding->link_callback_.Get(isolate) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,20 +9,20 @@ namespace permission { | |||
| 9 | 9 | // Currently, Addon manage a single state | |
| 10 | 10 | // Once denied, it's always denied | |
| 11 | 11 | void AddonPermission::Apply(Environment* env, | |
| 12 | - const std::vector<std::string>& allow, | ||
| 12 | + std::span<const std::string> allow, | ||
| 13 | 13 | PermissionScope scope) { | |
| 14 | 14 | deny_all_ = true; | |
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | 17 | void AddonPermission::Drop(Environment* env, | |
| 18 | 18 | PermissionScope scope, | |
| 19 | - const std::string_view& param) { | ||
| 19 | + std::string_view param) { | ||
| 20 | 20 | deny_all_ = true; | |
| 21 | 21 | } | |
| 22 | 22 | ||
| 23 | 23 | bool AddonPermission::is_granted(Environment* env, | |
| 24 | 24 | PermissionScope perm, | |
| 25 | - const std::string_view& param) const { | ||
| 25 | + std::string_view param) const { | ||
| 26 | 26 | return deny_all_ == false; | |
| 27 | 27 | } | |
| 28 | 28 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,14 +13,14 @@ namespace permission { | |||
| 13 | 13 | class AddonPermission final : public PermissionBase { | |
| 14 | 14 | public: | |
| 15 | 15 | void Apply(Environment* env, | |
| 16 | - const std::vector<std::string>& allow, | ||
| 16 | + std::span<const std::string> allow, | ||
| 17 | 17 | PermissionScope scope) override; | |
| 18 | 18 | void Drop(Environment* env, | |
| 19 | 19 | PermissionScope scope, | |
| 20 | - const std::string_view& param = "") override; | ||
| 20 | + std::string_view param) override; | ||
| 21 | 21 | bool is_granted(Environment* env, | |
| 22 | 22 | PermissionScope perm, | |
| 23 | - const std::string_view& param = "") const override; | ||
| 23 | + std::string_view param) const override; | ||
| 24 | 24 | ||
| 25 | 25 | private: | |
| 26 | 26 | bool deny_all_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,20 +10,20 @@ namespace permission { | |||
| 10 | 10 | // Currently, ChildProcess manage a single state | |
| 11 | 11 | // Once denied, it's always denied | |
| 12 | 12 | void ChildProcessPermission::Apply(Environment* env, | |
| 13 | - const std::vector<std::string>& allow, | ||
| 13 | + std::span<const std::string> allow, | ||
| 14 | 14 | PermissionScope scope) { | |
| 15 | 15 | deny_all_ = true; | |
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | void ChildProcessPermission::Drop(Environment* env, | |
| 19 | 19 | PermissionScope scope, | |
| 20 | - const std::string_view& param) { | ||
| 20 | + std::string_view param) { | ||
| 21 | 21 | deny_all_ = true; | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | 24 | bool ChildProcessPermission::is_granted(Environment* env, | |
| 25 | 25 | PermissionScope perm, | |
| 26 | - const std::string_view& param) const { | ||
| 26 | + std::string_view param) const { | ||
| 27 | 27 | return deny_all_ == false; | |
| 28 | 28 | } | |
| 29 | 29 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,14 +13,14 @@ namespace permission { | |||
| 13 | 13 | class ChildProcessPermission final : public PermissionBase { | |
| 14 | 14 | public: | |
| 15 | 15 | void Apply(Environment* env, | |
| 16 | - const std::vector<std::string>& allow, | ||
| 16 | + std::span<const std::string> allow, | ||
| 17 | 17 | PermissionScope scope) override; | |
| 18 | 18 | void Drop(Environment* env, | |
| 19 | 19 | PermissionScope scope, | |
| 20 | - const std::string_view& param = "") override; | ||
| 20 | + std::string_view param) override; | ||
| 21 | 21 | bool is_granted(Environment* env, | |
| 22 | 22 | PermissionScope perm, | |
| 23 | - const std::string_view& param = "") const override; | ||
| 23 | + std::string_view param) const override; | ||
| 24 | 24 | ||
| 25 | 25 | private: | |
| 26 | 26 | bool deny_all_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,20 +9,20 @@ namespace permission { | |||
| 9 | 9 | ||
| 10 | 10 | // Currently, FFIPermission manages a single global deny state for FFI. | |
| 11 | 11 | void FFIPermission::Apply(Environment* env, | |
| 12 | - const std::vector<std::string>& allow, | ||
| 12 | + std::span<const std::string> allow, | ||
| 13 | 13 | PermissionScope scope) { | |
| 14 | 14 | deny_all_ = true; | |
| 15 | 15 | } | |
| 16 | 16 | ||
| 17 | 17 | void FFIPermission::Drop(Environment* env, | |
| 18 | 18 | PermissionScope scope, | |
| 19 | - const std::string_view& param) { | ||
| 19 | + std::string_view param) { | ||
| 20 | 20 | deny_all_ = true; | |
| 21 | 21 | } | |
| 22 | 22 | ||
| 23 | 23 | bool FFIPermission::is_granted(Environment* env, | |
| 24 | 24 | PermissionScope perm, | |
| 25 | - const std::string_view& param) const { | ||
| 25 | + std::string_view param) const { | ||
| 26 | 26 | return perm != PermissionScope::kFFI || !deny_all_; | |
| 27 | 27 | } | |
| 28 | 28 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,14 +13,14 @@ namespace permission { | |||
| 13 | 13 | class FFIPermission final : public PermissionBase { | |
| 14 | 14 | public: | |
| 15 | 15 | void Apply(Environment* env, | |
| 16 | - const std::vector<std::string>& allow, | ||
| 16 | + std::span<const std::string> allow, | ||
| 17 | 17 | PermissionScope scope) override; | |
| 18 | 18 | void Drop(Environment* env, | |
| 19 | 19 | PermissionScope scope, | |
| 20 | - const std::string_view& param = "") override; | ||
| 20 | + std::string_view param) override; | ||
| 21 | 21 | bool is_granted(Environment* env, | |
| 22 | 22 | PermissionScope perm, | |
| 23 | - const std::string_view& param = "") const override; | ||
| 23 | + std::string_view param) const override; | ||
| 24 | 24 | ||
| 25 | 25 | private: | |
| 26 | 26 | bool deny_all_ = false; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,7 +52,7 @@ void FreeRecursivelyNode( | |||
| 52 | 52 | bool is_tree_granted( | |
| 53 | 53 | node::Environment* env, | |
| 54 | 54 | const node::permission::FSPermission::RadixTree* granted_tree, | |
| 55 | - const std::string_view& param) { | ||
| 55 | + std::string_view param) { | ||
| 56 | 56 | std::string resolved_param = node::PathResolve(env, {param}); | |
| 57 | 57 | #ifdef _WIN32 | |
| 58 | 58 | // Remove leading "\\?\" from UNC path | |
@@ -137,7 +137,7 @@ namespace permission { | |||
| 137 | 137 | // allow = '*' | |
| 138 | 138 | // allow = '/tmp/,/home/example.js' | |
| 139 | 139 | void FSPermission::Apply(Environment* env, | |
| 140 | - const std::vector<std::string>& allow, | ||
| 140 | + std::span<const std::string> allow, | ||
| 141 | 141 | PermissionScope scope) { | |
| 142 | 142 | for (const std::string& res : allow) { | |
| 143 | 143 | if (res == "*") { | |
@@ -156,7 +156,7 @@ void FSPermission::Apply(Environment* env, | |||
| 156 | 156 | ||
| 157 | 157 | void FSPermission::Drop(Environment* env, | |
| 158 | 158 | PermissionScope scope, | |
| 159 | - const std::string_view& param) { | ||
| 159 | + std::string_view param) { | ||
| 160 | 160 | if (param.empty()) { | |
| 161 | 161 | // Drop all access for this scope | |
| 162 | 162 | if (scope == PermissionScope::kFileSystemRead || | |
@@ -250,7 +250,7 @@ void FSPermission::GrantAccess(PermissionScope perm, const std::string& res) { | |||
| 250 | 250 | ||
| 251 | 251 | bool FSPermission::is_granted(Environment* env, | |
| 252 | 252 | PermissionScope perm, | |
| 253 | - const std::string_view& param = "") const { | ||
| 253 | + std::string_view param = "") const { | ||
| 254 | 254 | switch (perm) { | |
| 255 | 255 | case PermissionScope::kFileSystem: | |
| 256 | 256 | return allow_all_in_ && allow_all_out_; | |
@@ -287,7 +287,7 @@ void FSPermission::RadixTree::Clear() { | |||
| 287 | 287 | root_node_->is_leaf = false; | |
| 288 | 288 | } | |
| 289 | 289 | ||
| 290 | - bool FSPermission::RadixTree::Lookup(const std::string_view& s, | ||
| 290 | + bool FSPermission::RadixTree::Lookup(std::string_view s, | ||
| 291 | 291 | bool when_empty_return) const { | |
| 292 | 292 | FSPermission::RadixTree::Node* current_node = root_node_; | |
| 293 | 293 | if (current_node->children.empty()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,14 +16,14 @@ namespace permission { | |||
| 16 | 16 | class FSPermission final : public PermissionBase { | |
| 17 | 17 | public: | |
| 18 | 18 | void Apply(Environment* env, | |
| 19 | - const std::vector<std::string>& allow, | ||
| 19 | + std::span<const std::string> allow, | ||
| 20 | 20 | PermissionScope scope) override; | |
| 21 | 21 | void Drop(Environment* env, | |
| 22 | 22 | PermissionScope scope, | |
| 23 | - const std::string_view& param = "") override; | ||
| 23 | + std::string_view param) override; | ||
| 24 | 24 | bool is_granted(Environment* env, | |
| 25 | 25 | PermissionScope perm, | |
| 26 | - const std::string_view& param) const override; | ||
| 26 | + std::string_view param) const override; | ||
| 27 | 27 | ||
| 28 | 28 | struct RadixTree { | |
| 29 | 29 | struct Node { | |
@@ -146,8 +146,8 @@ class FSPermission final : public PermissionBase { | |||
| 146 | 146 | ~RadixTree(); | |
| 147 | 147 | void Insert(const std::string& s); | |
| 148 | 148 | void Clear(); | |
| 149 | - bool Lookup(const std::string_view& s) const { return Lookup(s, false); } | ||
| 150 | - bool Lookup(const std::string_view& s, bool when_empty_return) const; | ||
| 149 | + bool Lookup(std::string_view s) const { return Lookup(s, false); } | ||
| 150 | + bool Lookup(std::string_view s, bool when_empty_return) const; | ||
| 151 | 151 | ||
| 152 | 152 | private: | |
| 153 | 153 | Node* root_node_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments