@@ -15,6 +15,8 @@ const { checkRaspExecutedAndNotThreat, checkRaspExecutedAndHasThreat } = require
1515
1616function noop ( ) { }
1717
18+ const UNRESOLVABLE_HOST = 'not-a-threat.invalid'
19+
1820describe ( 'RASP - ssrf' , ( ) => {
1921 withVersions ( 'express' , 'express' , expressVersion => {
2022 let app , server , axios
@@ -84,12 +86,12 @@ describe('RASP - ssrf', () => {
8486 res . end ( 'end' )
8587 } )
8688
87- clientRequest . on ( 'error' , noop )
89+ clientRequest . on ( 'error' , ( ) => res . end ( 'end' ) )
8890 }
8991
9092 await Promise . all ( [
9193 checkRaspExecutedAndNotThreat ( agent ) ,
92- axios . get ( ' /?host=www.datadoghq.com' ) ,
94+ axios . get ( ` /?host=${ UNRESOLVABLE_HOST } ` ) ,
9395 ] )
9496 } )
9597
@@ -146,13 +148,13 @@ describe('RASP - ssrf', () => {
146148
147149 it ( 'Should not detect threat' , async ( ) => {
148150 app = ( req , res ) => {
149- axiosToTest . get ( `https://${ req . query . host } ` )
151+ axiosToTest . get ( `https://${ req . query . host } ` , { proxy : false } )
150152 . catch ( noop ) // swallow network error
151153 . then ( ( ) => res . end ( 'end' ) )
152154 }
153155
154156 await Promise . all ( [
155- axios . get ( ' /?host=www.datadoghq.com' ) ,
157+ axios . get ( ` /?host=${ UNRESOLVABLE_HOST } ` ) ,
156158 checkRaspExecutedAndNotThreat ( agent ) ,
157159 ] )
158160 } )
@@ -200,13 +202,13 @@ describe('RASP - ssrf', () => {
200202
201203 it ( 'Should not detect threat' , async ( ) => {
202204 app = ( req , res ) => {
203- requestToTest . get ( `https://${ req . query . host } ` ) . on ( 'response' , ( ) => {
204- res . end ( 'end' )
205- } )
205+ requestToTest . get ( `https://${ req . query . host } ` , { proxy : false } )
206+ . on ( 'response' , ( ) => res . end ( 'end' ) )
207+ . on ( 'error' , ( ) => res . end ( 'end' ) )
206208 }
207209
208210 await Promise . all ( [
209- axios . get ( ' /?host=www.datadoghq.com' ) ,
211+ axios . get ( ` /?host=${ UNRESOLVABLE_HOST } ` ) ,
210212 checkRaspExecutedAndNotThreat ( agent ) ,
211213 ] )
212214 } )
0 commit comments