File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,22 @@ describe('Request', function() {
127127 request . custom2 . should . eql ( originalRequest . custom2 ) ;
128128 } ) ;
129129
130+ it ( 'should not allow overwriting methods on the Request prototype via custom properties' , ( ) => {
131+ const request = new Request ( {
132+ query : { } ,
133+ method : 'GET' ,
134+ headers : {
135+ 'content-type' : 'application/json'
136+ } ,
137+ get ( ) {
138+ // malicious attempt to override the 'get' method
139+ return 'text/html' ;
140+ }
141+ } ) ;
142+
143+ request . get ( 'content-type' ) . should . equal ( 'application/json' ) ;
144+ } ) ;
145+
130146 it ( 'should allow getting of headers using `request.get`' , function ( ) {
131147 const originalRequest = generateBaseRequest ( ) ;
132148
Original file line number Diff line number Diff line change @@ -83,6 +83,20 @@ describe('Request', function() {
8383 response . custom2 . should . eql ( originalResponse . custom2 ) ;
8484 } ) ;
8585
86+ it ( 'should not allow overwriting methods on the Response prototype via custom properties' , ( ) => {
87+ const response = new Response ( {
88+ headers : {
89+ 'content-type' : 'application/json'
90+ } ,
91+ get ( ) {
92+ // malicious attempt to override the 'get' method
93+ return 'text/html' ;
94+ }
95+ } ) ;
96+
97+ response . get ( 'content-type' ) . should . equal ( 'application/json' ) ;
98+ } ) ;
99+
86100 it ( 'should allow getting of headers using `response.get`' , function ( ) {
87101 const originalResponse = generateBaseResponse ( ) ;
88102
You can’t perform that action at this time.
0 commit comments