@@ -126,39 +126,25 @@ const regularFile = __filename;
126126 } ) ;
127127}
128128
129-
130- // TODO
131129// fs.access
132130{
133- // assert.throws(() => {
134- // fs.access(blockedFile, fs.constants.R_OK, () => {});
135- // }, common.expectsError({
136- // code: 'ERR_ACCESS_DENIED',
137- // permission: 'FileSystemIn',
138- // }));
139-
140- // assert.throws(() => {
141- // fs.access(blockedFolder + 'anyfile', fs.constants.R_OK, () => {});
142- // }, common.expectsError({
143- // code: 'ERR_ACCESS_DENIED',
144- // permission: 'FileSystemIn',
145- // }));
146-
147- assert . doesNotThrow ( ( ) => {
148- fs . access ( regularFile , fs . constants . R_OK , ( ) => { } ) ;
149- } ) ;
150- }
131+ assert . throws ( ( ) => {
132+ fs . access ( blockedFile , fs . constants . R_OK , ( ) => { } ) ;
133+ } , common . expectsError ( {
134+ code : 'ERR_ACCESS_DENIED' ,
135+ permission : 'FileSystemIn' ,
136+ } ) ) ;
151137
152- // fs.chmodSync (should not bypass)
153- {
154138 assert . throws ( ( ) => {
155- // this operation will work fine
156- fs . chmodSync ( blockedFile , 0o400 ) ;
157- fs . readFileSync ( blockedFile )
139+ fs . access ( blockedFolder + 'anyfile' , fs . constants . R_OK , ( ) => { } ) ;
158140 } , common . expectsError ( {
159141 code : 'ERR_ACCESS_DENIED' ,
160142 permission : 'FileSystemIn' ,
161143 } ) ) ;
144+
145+ assert . doesNotThrow ( ( ) => {
146+ fs . access ( regularFile , fs . constants . R_OK , ( ) => { } ) ;
147+ } ) ;
162148}
163149
164150// fs.chownSync (should not bypass)
@@ -173,9 +159,9 @@ const regularFile = __filename;
173159 } ) ) ;
174160}
175161
176- // TODO(rafaelgss): mention possible workarounds (spawn('cp blockedFile regularFile'))
177- // copyFile (handle security concerns)
178- // cp (handle security concerns)
162+ // // TODO(rafaelgss): mention possible workarounds (spawn('cp blockedFile regularFile'))
163+ // // copyFile (handle security concerns)
164+ // // cp (handle security concerns)
179165
180166// fs.openSync
181167{
@@ -220,45 +206,45 @@ const regularFile = __filename;
220206}
221207
222208// fs.opendir (TODO)
223- {
224- // assert.throws(() => {
225- // fs.opendir(blockedFolder, (err) => {
226- // if (err) throw err;
227- // });
228- // }, common.expectsError({
229- // code: 'ERR_ACCESS_DENIED',
230- // permission: 'FileSystemIn',
231- // }));
232-
233- assert . doesNotThrow ( ( ) => {
234- fs . opendir ( __dirname , ( ) => { } ) ;
235- } ) ;
236- }
237-
238- // fs.readdir
239- {
240- // assert.throws(() => {
241- // fs.readdir(blockedFolder, () => {});
242- // }, common.expectsError({
243- // code: 'ERR_ACCESS_DENIED',
244- // permission: 'FileSystemIn',
245- // }));
246-
247- assert . doesNotThrow ( ( ) => {
248- fs . readdir ( __dirname , ( ) => { } ) ;
249- } ) ;
250- }
251-
252- // fs.watch (TODO)
253209{
254210 assert . throws ( ( ) => {
255- fs . watch ( blockedFile , ( ) => { } ) ;
211+ fs . opendir ( blockedFolder , ( err ) => {
212+ if ( err ) throw err ;
213+ } ) ;
256214 } , common . expectsError ( {
257215 code : 'ERR_ACCESS_DENIED' ,
258216 permission : 'FileSystemIn' ,
259217 } ) ) ;
260218
261219 assert . doesNotThrow ( ( ) => {
262- fs . readdir ( __dirname , ( ) => { } ) ;
220+ fs . opendir ( __dirname , ( ) => { } ) ;
263221 } ) ;
264222}
223+
224+ // // fs.readdir
225+ // {
226+ // // assert.throws(() => {
227+ // // fs.readdir(blockedFolder, () => {});
228+ // // }, common.expectsError({
229+ // // code: 'ERR_ACCESS_DENIED',
230+ // // permission: 'FileSystemIn',
231+ // // }));
232+
233+ // assert.doesNotThrow(() => {
234+ // fs.readdir(__dirname, () => {});
235+ // });
236+ // }
237+
238+ // // fs.watch (TODO)
239+ // {
240+ // assert.throws(() => {
241+ // fs.watch(blockedFile, () => {});
242+ // }, common.expectsError({
243+ // code: 'ERR_ACCESS_DENIED',
244+ // permission: 'FileSystemIn',
245+ // }));
246+
247+ // assert.doesNotThrow(() => {
248+ // fs.readdir(__dirname, () => {});
249+ // });
250+ // }
0 commit comments