GeezerVison is showing github.com — permission: mark const functions as such · nodejs/node@43160dc
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/permission/child_process_permission.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ void ChildProcessPermission::Apply(const std::vector<std::string>& allow, | 15 | 15 | } | 16 | 16 |
| 17 | 17 | bool ChildProcessPermission::is_granted(PermissionScope perm, | 18 | | - const std::string_view& param) { | | 18 | + const std::string_view& param) const { | 19 | 19 | return deny_all_ == false; | 20 | 20 | } | 21 | 21 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/permission/child_process_permission.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ class ChildProcessPermission final : public PermissionBase { | 15 | 15 | void Apply(const std::vector<std::string>& allow, | 16 | 16 | PermissionScope scope) override; | 17 | 17 | bool is_granted(PermissionScope perm, | 18 | | - const std::string_view& param = "") override; | | 18 | + const std::string_view& param = "") const override; | 19 | 19 |
| 20 | 20 | private: | 21 | 21 | bool deny_all_; | |
Collapse file Copy file name to clipboardExpand all lines: src/permission/fs_permission.cc +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,8 +50,9 @@ void FreeRecursivelyNode( | 50 | 50 | delete node; | 51 | 51 | } | 52 | 52 |
| 53 | | -bool is_tree_granted(node::permission::FSPermission::RadixTree* granted_tree, | 54 | | - const std::string_view& param) { | | 53 | +bool is_tree_granted( | | 54 | + const node::permission::FSPermission::RadixTree* granted_tree, | | 55 | + const std::string_view& param) { | 55 | 56 | #ifdef _WIN32 | 56 | 57 | // is UNC file path | 57 | 58 | if (param.rfind("\\\\", 0) == 0) { | @@ -147,7 +148,7 @@ void FSPermission::GrantAccess(PermissionScope perm, const std::string& res) { | 147 | 148 | } | 148 | 149 |
| 149 | 150 | bool FSPermission::is_granted(PermissionScope perm, | 150 | | - const std::string_view& param = "") { | | 151 | + const std::string_view& param = "") const { | 151 | 152 | switch (perm) { | 152 | 153 | case PermissionScope::kFileSystem: | 153 | 154 | return allow_all_in_ && allow_all_out_; | @@ -171,7 +172,7 @@ FSPermission::RadixTree::~RadixTree() { | 171 | 172 | } | 172 | 173 |
| 173 | 174 | bool FSPermission::RadixTree::Lookup(const std::string_view& s, | 174 | | - bool when_empty_return = false) { | | 175 | + bool when_empty_return = false) const { | 175 | 176 | FSPermission::RadixTree::Node* current_node = root_node_; | 176 | 177 | if (current_node->children.size() == 0) { | 177 | 178 | return when_empty_return; | |
Collapse file Copy file name to clipboardExpand all lines: src/permission/fs_permission.h +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,8 @@ class FSPermission final : public PermissionBase { | 17 | 17 | public: | 18 | 18 | void Apply(const std::vector<std::string>& allow, | 19 | 19 | PermissionScope scope) override; | 20 | | - bool is_granted(PermissionScope perm, const std::string_view& param) override; | | 20 | + bool is_granted(PermissionScope perm, | | 21 | + const std::string_view& param) const override; | 21 | 22 |
| 22 | 23 | struct RadixTree { | 23 | 24 | struct Node { | @@ -72,7 +73,7 @@ class FSPermission final : public PermissionBase { | 72 | 73 | return wildcard_child; | 73 | 74 | } | 74 | 75 |
| 75 | | - Node* NextNode(const std::string& path, size_t idx) { | | 76 | + Node* NextNode(const std::string& path, size_t idx) const { | 76 | 77 | if (idx >= path.length()) { | 77 | 78 | return nullptr; | 78 | 79 | } | @@ -115,7 +116,7 @@ class FSPermission final : public PermissionBase { | 115 | 116 | // ---> '\000' ASCII (0) || \0 | 116 | 117 | // ---> er | 117 | 118 | // ---> n | 118 | | - bool IsEndNode() { | | 119 | + bool IsEndNode() const { | 119 | 120 | if (children.size() == 0) { | 120 | 121 | return true; | 121 | 122 | } | @@ -126,8 +127,8 @@ class FSPermission final : public PermissionBase { | 126 | 127 | RadixTree(); | 127 | 128 | ~RadixTree(); | 128 | 129 | void Insert(const std::string& s); | 129 | | - bool Lookup(const std::string_view& s) { return Lookup(s, false); } | 130 | | - bool Lookup(const std::string_view& s, bool when_empty_return); | | 130 | + bool Lookup(const std::string_view& s) const { return Lookup(s, false); } | | 131 | + bool Lookup(const std::string_view& s, bool when_empty_return) const; | 131 | 132 |
| 132 | 133 | private: | 133 | 134 | Node* root_node_; | |
Collapse file Copy file name to clipboardExpand all lines: src/permission/inspector_permission.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ void InspectorPermission::Apply(const std::vector<std::string>& allow, | 14 | 14 | } | 15 | 15 |
| 16 | 16 | bool InspectorPermission::is_granted(PermissionScope perm, | 17 | | - const std::string_view& param) { | | 17 | + const std::string_view& param) const { | 18 | 18 | return deny_all_ == false; | 19 | 19 | } | 20 | 20 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/permission/inspector_permission.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ class InspectorPermission final : public PermissionBase { | 15 | 15 | void Apply(const std::vector<std::string>& allow, | 16 | 16 | PermissionScope scope) override; | 17 | 17 | bool is_granted(PermissionScope perm, | 18 | | - const std::string_view& param = "") override; | | 18 | + const std::string_view& param = "") const override; | 19 | 19 |
| 20 | 20 | private: | 21 | 21 | bool deny_all_; | |
Collapse file Copy file name to clipboardExpand all lines: src/permission/permission_base.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,7 +42,7 @@ class PermissionBase { | 42 | 42 | virtual void Apply(const std::vector<std::string>& allow, | 43 | 43 | PermissionScope scope) = 0; | 44 | 44 | virtual bool is_granted(PermissionScope perm, | 45 | | - const std::string_view& param = "") = 0; | | 45 | + const std::string_view& param = "") const = 0; | 46 | 46 | }; | 47 | 47 |
| 48 | 48 | } // namespace permission | |
Collapse file Copy file name to clipboardExpand all lines: src/permission/worker_permission.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ void WorkerPermission::Apply(const std::vector<std::string>& allow, | 15 | 15 | } | 16 | 16 |
| 17 | 17 | bool WorkerPermission::is_granted(PermissionScope perm, | 18 | | - const std::string_view& param) { | | 18 | + const std::string_view& param) const { | 19 | 19 | return deny_all_ == false; | 20 | 20 | } | 21 | 21 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/permission/worker_permission.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ class WorkerPermission final : public PermissionBase { | 15 | 15 | void Apply(const std::vector<std::string>& allow, | 16 | 16 | PermissionScope scope) override; | 17 | 17 | bool is_granted(PermissionScope perm, | 18 | | - const std::string_view& param = "") override; | | 18 | + const std::string_view& param = "") const override; | 19 | 19 |
| 20 | 20 | private: | 21 | 21 | bool deny_all_; | |
|