@@ -468,34 +468,8 @@ describe('PackageURL', () => {
468468 } )
469469
470470 describe ( 'Input validation' , ( ) => {
471- it ( 'should reject JSON strings exceeding maximum size' , ( ) => {
472- const largeJson = JSON . stringify ( { name : 'x' . repeat ( 1024 * 1024 ) } )
473- expect ( ( ) => PackageURL . fromJSON ( largeJson ) ) . toThrow (
474- 'JSON string exceeds maximum size limit of 1048576 bytes' ,
475- )
476- } )
477-
478- it ( 'should reject non-object JSON' , ( ) => {
479- expect ( ( ) => PackageURL . fromJSON ( '[]' ) ) . toThrow (
480- 'JSON must parse to an object' ,
481- )
482- expect ( ( ) => PackageURL . fromJSON ( '"string"' ) ) . toThrow (
483- 'JSON must parse to an object' ,
484- )
485- expect ( ( ) => PackageURL . fromJSON ( 'null' ) ) . toThrow (
486- 'JSON must parse to an object' ,
487- )
488- } )
489-
490- it ( 'should prevent prototype pollution in fromJSON' , ( ) => {
491- const maliciousJson =
492- '{"__proto__":{"isAdmin":true},"type":"npm","name":"test"}'
493- const purl = PackageURL . fromJSON ( maliciousJson )
494- expect ( purl . type ) . toBe ( 'npm' )
495- expect ( purl . name ) . toBe ( 'test' )
496- // Verify prototype pollution didn't occur.
497- expect ( ( { } as any ) . isAdmin ) . toBeUndefined ( )
498- } )
471+ // JSON security tests moved to package-url-json-security.test.mts
472+ // for better organization and to avoid duplication
499473
500474 it ( 'should reject package URLs exceeding maximum length' , ( ) => {
501475 const longUrl = 'pkg:npm/' + 'x' . repeat ( 4090 )
0 commit comments