| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 697a851 commit bcdb42d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -143,10 +143,12 @@ void FSPermission::Apply(Environment* env, | |||
| 143 | 143 | ||
| 144 | 144 | void FSPermission::GrantAccess(PermissionScope perm, const std::string& res) { | |
| 145 | 145 | const std::string path = WildcardIfDir(res); | |
| 146 | - if (perm == PermissionScope::kFileSystemRead) { | ||
| 146 | + if (perm == PermissionScope::kFileSystemRead && | ||
| 147 | + !granted_in_fs_.Lookup(path)) { | ||
| 147 | 148 | granted_in_fs_.Insert(path); | |
| 148 | 149 | deny_all_in_ = false; | |
| 149 | - } else if (perm == PermissionScope::kFileSystemWrite) { | ||
| 150 | + } else if (perm == PermissionScope::kFileSystemWrite && | ||
| 151 | + !granted_out_fs_.Lookup(path)) { | ||
| 150 | 152 | granted_out_fs_.Insert(path); | |
| 151 | 153 | deny_all_out_ = false; | |
| 152 | 154 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + // Flags: --permission --allow-fs-read=* --allow-child-process | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + const common = require('../common'); | ||
| 5 | + const path = require('path'); | ||
| 6 | + common.skipIfWorker(); | ||
| 7 | + | ||
| 8 | + const assert = require('assert'); | ||
| 9 | + const { spawnSync } = require('child_process'); | ||
| 10 | + | ||
| 11 | + { | ||
| 12 | + // Relative path as CLI args are supported | ||
| 13 | + const { status, stdout } = spawnSync( | ||
| 14 | + process.execPath, | ||
| 15 | + [ | ||
| 16 | + '--permission', | ||
| 17 | + '--allow-fs-write', path.resolve('../fixtures/permission/deny/regular-file.md'), | ||
| 18 | + '--allow-fs-write', path.resolve('../fixtures/permission/deny/regular-file.md'), | ||
| 19 | + '--allow-fs-read', path.resolve('../fixtures/permission/deny/regular-file.md'), | ||
| 20 | + '--allow-fs-read', path.resolve('../fixtures/permission/deny/regular-file.md'), | ||
| 21 | + '-e', | ||
| 22 | + ` | ||
| 23 | + const path = require("path"); | ||
| 24 | + const absolutePath = path.resolve("../fixtures/permission/deny/regular-file.md"); | ||
| 25 | + const blockedPath = path.resolve("../fixtures/permission/deny/protected-file.md"); | ||
| 26 | + console.log(process.permission.has("fs.write", absolutePath)); | ||
| 27 | + console.log(process.permission.has("fs.read", absolutePath)); | ||
| 28 | + console.log(process.permission.has("fs.read", blockedPath)); | ||
| 29 | + console.log(process.permission.has("fs.write", blockedPath)); | ||
| 30 | + `, | ||
| 31 | + ] | ||
| 32 | + ); | ||
| 33 | + | ||
| 34 | + const [fsWrite, fsRead, fsBlockedRead, fsBlockedWrite] = stdout.toString().split('\n'); | ||
| 35 | + assert.strictEqual(status, 0); | ||
| 36 | + assert.strictEqual(fsWrite, 'true'); | ||
| 37 | + assert.strictEqual(fsRead, 'true'); | ||
| 38 | + assert.strictEqual(fsBlockedRead, 'false'); | ||
| 39 | + assert.strictEqual(fsBlockedWrite, 'false'); | ||
| 40 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments