GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: fix the fs permission tree node on wildcard nodes · nodejs/node@5e497ae

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/permission
    • fs_permission.h
  • test/parallel
    • test-permission-fs-wildcard.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/permission/fs_permission.h‎

Copy file name to clipboardExpand all lines: src/permission/fs_permission.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class FSPermission final : public PermissionBase {
100100
auto child = it->second;
101101
// match prefix
102102
size_t prefix_len = child->prefix.length();
103-
for (size_t i = 0; i < path.length(); ++i) {
104-
if (i >= prefix_len || child->prefix[i] == '*') {
103+
for (size_t i = 0; i < prefix_len; ++i) {
104+
if (child->prefix[i] == '*') {
105105
return child;
106106
}
107107

Collapse file

‎test/parallel/test-permission-fs-wildcard.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-permission-fs-wildcard.js
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,34 @@ if (common.isWindows) {
126126
assert.strictEqual(status, 0, stderr.toString());
127127
}
128128
}
129+
130+
{
131+
// Each scope holds a single grant, so its wildcard node sits directly under
132+
// the radix tree root. Removing the `*` and the character before it must not
133+
// produce a granted path.
134+
if (!common.isWindows) {
135+
const { status, stderr } = spawnSync(
136+
process.execPath,
137+
[
138+
'--permission',
139+
'--allow-fs-read=/tmp/test*',
140+
'--allow-fs-write=/tmp/test/*',
141+
'-e',
142+
`
143+
const assert = require('assert');
144+
assert.ok(process.permission.has('fs.read', '/tmp/test'));
145+
assert.ok(process.permission.has('fs.read', '/tmp/test2'));
146+
assert.ok(process.permission.has('fs.read', '/tmp/test/file'));
147+
assert.ok(!process.permission.has('fs.read', '/tmp/tes'));
148+
assert.ok(!process.permission.has('fs.read', '/tmp/te'));
149+
assert.ok(process.permission.has('fs.write', '/tmp/test'));
150+
assert.ok(process.permission.has('fs.write', '/tmp/test/'));
151+
assert.ok(process.permission.has('fs.write', '/tmp/test/file'));
152+
assert.ok(!process.permission.has('fs.write', '/tmp/tes'));
153+
assert.ok(!process.permission.has('fs.write', '/tmp/test2'));
154+
`,
155+
]
156+
);
157+
assert.strictEqual(status, 0, stderr.toString());
158+
}
159+
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.