File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 25
25
#include " memory_tracker-inl.h"
26
26
#include " node_external_reference.h"
27
27
#include " node_file-inl.h"
28
+ #include " permission/permission.h"
28
29
#include " util-inl.h"
29
30
30
31
#include < cstring>
@@ -111,6 +112,10 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
111
112
112
113
node::Utf8Value path (args.GetIsolate (), args[0 ]);
113
114
CHECK_NOT_NULL (*path);
115
+ THROW_IF_INSUFFICIENT_PERMISSIONS (
116
+ wrap->env (),
117
+ permission::PermissionScope::kFileSystemRead ,
118
+ path.ToStringView ());
114
119
115
120
CHECK (args[1 ]->IsUint32 ());
116
121
const uint32_t interval = args[1 ].As <Uint32>()->Value ();
Original file line number Diff line number Diff line change @@ -228,6 +228,17 @@ const regularFile = __filename;
228
228
} ) ;
229
229
}
230
230
231
+ // fs.watchFile
232
+ {
233
+ assert . throws ( ( ) => {
234
+ fs . watchFile ( blockedFile , common . mustNotCall ( ) ) ;
235
+ } , common . expectsError ( {
236
+ code : 'ERR_ACCESS_DENIED' ,
237
+ permission : 'FileSystemRead' ,
238
+ resource : path . toNamespacedPath ( blockedFile ) ,
239
+ } ) ) ;
240
+ }
241
+
231
242
// fs.rename
232
243
{
233
244
assert . throws ( ( ) => {
You can’t perform that action at this time.
0 commit comments