@@ -171,6 +171,37 @@ describe('test/ssrf.test.js', () => {
171
171
assert ( count === 3 ) ;
172
172
} ) ;
173
173
} ) ;
174
+
175
+ describe ( 'hostnameExceptionList' , ( ) => {
176
+ before ( ( ) => {
177
+ app = mm . app ( { baseDir : 'apps/ssrf-hostname-exception-list' } ) ;
178
+ return app . ready ( ) ;
179
+ } ) ;
180
+
181
+ it ( 'should safeCurl work' , async ( ) => {
182
+ const ctx = app . createAnonymousContext ( ) ;
183
+ const host = process . env . CI ? 'registry.npmjs.org' : 'registry.npmmirror.com' ;
184
+ const url = `https://${ host } ` ;
185
+ let count = 0 ;
186
+
187
+ mm ( app , 'curl' , async ( url , options ) => {
188
+ options . checkAddress ( '10.0.0.1' , 4 , host ) && count ++ ;
189
+ return 'response' ;
190
+ } ) ;
191
+ mm ( app . agent , 'curl' , async ( url , options ) => {
192
+ options . checkAddress ( '10.0.0.1' , 4 , host ) && count ++ ;
193
+ return 'response' ;
194
+ } ) ;
195
+ mm ( ctx , 'curl' , async ( url , options ) => {
196
+ options . checkAddress ( '10.0.0.1' , 4 , host ) && count ++ ;
197
+ return 'response' ;
198
+ } ) ;
199
+
200
+ await app . safeCurl ( url , { dataType : 'json' } ) ;
201
+ await app . agent . safeCurl ( url , { dataType : 'json' } ) ;
202
+ await ctx . safeCurl ( url , { dataType : 'json' } ) ;
203
+ } ) ;
204
+ } ) ;
174
205
} ) ;
175
206
176
207
async function checkIllegalAddressError ( instance , url ) {
0 commit comments