File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -604,7 +604,8 @@ function openAsBlob(path, options = kEmptyObject) {
604604 // The underlying implementation here returns the Blob synchronously for now.
605605 // To give ourselves flexibility to maybe return the Blob asynchronously,
606606 // this API returns a Promise.
607- return PromiseResolve ( createBlobFromFilePath ( getValidatedPath ( path ) , { type } ) ) ;
607+ path = getValidatedPath ( path ) ;
608+ return PromiseResolve ( createBlobFromFilePath ( pathModule . toNamespacedPath ( path ) , { type } ) ) ;
608609}
609610
610611/**
Original file line number Diff line number Diff line change 88#include " node_errors.h"
99#include " node_external_reference.h"
1010#include " node_file.h"
11+ #include " permission/permission.h"
1112#include " util.h"
1213#include " v8.h"
1314
@@ -85,6 +86,10 @@ void Concat(const FunctionCallbackInfo<Value>& args) {
8586
8687void BlobFromFilePath (const FunctionCallbackInfo<Value>& args) {
8788 Environment* env = Environment::GetCurrent (args);
89+ BufferValue path (env->isolate (), args[0 ]);
90+ CHECK_NOT_NULL (*path);
91+ THROW_IF_INSUFFICIENT_PERMISSIONS (
92+ env, permission::PermissionScope::kFileSystemRead , path.ToStringView ());
8893 auto entry = DataQueue::CreateFdEntry (env, args[0 ]);
8994 if (entry == nullptr ) {
9095 return THROW_ERR_INVALID_ARG_VALUE (env, " Unabled to open file as blob" );
Original file line number Diff line number Diff line change @@ -249,3 +249,14 @@ const regularFile = __filename;
249249 resource : path . toNamespacedPath ( blockedFile ) ,
250250 } ) ) ;
251251}
252+
253+ // fs.openAsBlob
254+ {
255+ assert . throws ( ( ) => {
256+ fs . openAsBlob ( blockedFile ) ;
257+ } , common . expectsError ( {
258+ code : 'ERR_ACCESS_DENIED' ,
259+ permission : 'FileSystemRead' ,
260+ resource : path . toNamespacedPath ( blockedFile ) ,
261+ } ) ) ;
262+ }
You can’t perform that action at this time.
0 commit comments