@@ -279,6 +279,44 @@ describe('Vulnerabilities', () => {
279
279
expect ( text . code ) . toBe ( Parse . Error . INVALID_KEY_NAME ) ;
280
280
expect ( text . error ) . toBe ( 'Prohibited keyword in request data: {"value":"aValue[123]*"}.' ) ;
281
281
} ) ;
282
+
283
+ it ( 'denies BSON type code data in file metadata' , async ( ) => {
284
+ const str = 'Hello World!' ;
285
+ const data = [ ] ;
286
+ for ( let i = 0 ; i < str . length ; i ++ ) {
287
+ data . push ( str . charCodeAt ( i ) ) ;
288
+ }
289
+ const file = new Parse . File ( 'hello.txt' , data , 'text/plain' ) ;
290
+ file . addMetadata ( 'obj' , {
291
+ _bsontype : 'Code' ,
292
+ code : 'delete Object.prototype.evalFunctions' ,
293
+ } ) ;
294
+ await expectAsync ( file . save ( ) ) . toBeRejectedWith (
295
+ new Parse . Error (
296
+ Parse . Error . INVALID_KEY_NAME ,
297
+ `Prohibited keyword in request data: {"key":"_bsontype","value":"Code"}.`
298
+ )
299
+ ) ;
300
+ } ) ;
301
+
302
+ it ( 'denies BSON type code data in file tags' , async ( ) => {
303
+ const str = 'Hello World!' ;
304
+ const data = [ ] ;
305
+ for ( let i = 0 ; i < str . length ; i ++ ) {
306
+ data . push ( str . charCodeAt ( i ) ) ;
307
+ }
308
+ const file = new Parse . File ( 'hello.txt' , data , 'text/plain' ) ;
309
+ file . addTag ( 'obj' , {
310
+ _bsontype : 'Code' ,
311
+ code : 'delete Object.prototype.evalFunctions' ,
312
+ } ) ;
313
+ await expectAsync ( file . save ( ) ) . toBeRejectedWith (
314
+ new Parse . Error (
315
+ Parse . Error . INVALID_KEY_NAME ,
316
+ `Prohibited keyword in request data: {"key":"_bsontype","value":"Code"}.`
317
+ )
318
+ ) ;
319
+ } ) ;
282
320
} ) ;
283
321
284
322
describe ( 'Ignore non-matches' , ( ) => {
0 commit comments