| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0b328b2 commit 1726da9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -423,7 +423,7 @@ function readPackageScope(checkPath) { | |||
| 423 | 423 | checkPath = StringPrototypeSlice(checkPath, 0, separatorIndex); | |
| 424 | 424 | // Stop the search when the process doesn't have permissions | |
| 425 | 425 | // to walk upwards | |
| 426 | - if (enabledPermission && !permission.has('fs.read', checkPath)) { | ||
| 426 | + if (enabledPermission && !permission.has('fs.read', checkPath + sep)) { | ||
| 427 | 427 | return false; | |
| 428 | 428 | } | |
| 429 | 429 | if (StringPrototypeEndsWith(checkPath, sep + 'node_modules')) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + const fs = require('node:fs'); | ||
| 2 | + | ||
| 3 | + fs.readFile('/etc/passwd', () => {}); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - require('../common'); | ||
| 3 | + const common = require('../common'); | ||
| 4 | + | ||
| 5 | + const fixtures = require('../common/fixtures'); | ||
| 4 | 6 | const { spawnSync } = require('child_process'); | |
| 5 | 7 | const assert = require('assert'); | |
| 6 | 8 | const fs = require('fs'); | |
| 9 | + const path = require('path'); | ||
| 7 | 10 | ||
| 8 | 11 | { | |
| 9 | 12 | const { status, stdout } = spawnSync( | |
@@ -126,3 +129,23 @@ const fs = require('fs'); | |||
| 126 | 129 | assert.strictEqual(status, 1); | |
| 127 | 130 | assert.ok(!fs.existsSync('permission-deny-example.md')); | |
| 128 | 131 | } | |
| 132 | + | ||
| 133 | + { | ||
| 134 | + const { root } = path.parse(process.cwd()); | ||
| 135 | + const abs = (p) => path.join(root, p); | ||
| 136 | + const firstPath = abs(path.sep + process.cwd().split(path.sep, 2)[1]); | ||
| 137 | + if (firstPath.startsWith('/etc')) { | ||
| 138 | + common.skip('/etc as firstPath'); | ||
| 139 | + } | ||
| 140 | + const file = fixtures.path('permission', 'loader', 'index.js'); | ||
| 141 | + const { status, stderr } = spawnSync( | ||
| 142 | + process.execPath, | ||
| 143 | + [ | ||
| 144 | + '--experimental-permission', | ||
| 145 | + `--allow-fs-read=${firstPath}`, | ||
| 146 | + file, | ||
| 147 | + ] | ||
| 148 | + ); | ||
| 149 | + assert.match(stderr.toString(), /resource: '.*?[\\/](?:etc|passwd)'/); | ||
| 150 | + assert.strictEqual(status, 1); | ||
| 151 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments