1414// Doc: https://docs.aws.amazon.com/code-samples/latest/catalog/javascriptv3-lambda-src-MyLambdaApp-index.ts.html
1515import { LambdaClient , InvokeCommand } from '@aws-sdk/client-lambda' ;
1616import { ServiceDiscoveryClient , ListInstancesCommand } from '@aws-sdk/client-servicediscovery' ;
17- import axios from 'axios ' ;
18- import HttpProxyAgent from 'http-proxy-agent ' ;
17+ import got from 'got ' ;
18+ import { HttpProxyAgent } from 'hpagent ' ;
1919import Bourne from '@hapi/bourne' ;
2020
2121// For complete sessionsProps
@@ -247,10 +247,22 @@ internals.s2ContainersReady = async ({ collectionOfS2ContainerHostNamesWithPorts
247247 // https://github.com/zaproxy/zaproxy/issues/3796#issuecomment-319376915
248248 // https://github.com/zaproxy/zaproxy/issues/3594
249249 {
250- cloud ( ) { return axios . get ( `${ protocol } ://zap:${ port } /UI` , { httpAgent : new HttpProxyAgent ( `${ protocol } ://${ mCV . appEmissaryHostName } :${ mCV . appEmissaryPort } ` ) } ) ; } ,
251- local ( ) { return axios . get ( `${ protocol } ://${ mCV . appEmissaryHostName } :${ mCV . appEmissaryPort } /UI` ) ; }
250+ cloud ( ) {
251+ const agent = {
252+ http : new HttpProxyAgent ( {
253+ keepAlive : true ,
254+ keepAliveMsecs : 1000 ,
255+ maxSockets : 256 ,
256+ maxFreeSockets : 256 ,
257+ scheduling : 'lifo' ,
258+ proxy : `${ protocol } ://${ mCV . appEmissaryHostName } :${ mCV . appEmissaryPort } `
259+ } )
260+ } ;
261+ return got . get ( `${ protocol } ://zap:${ port } /UI` , { agent } ) ;
262+ } ,
263+ local ( ) { return got . get ( `${ protocol } ://${ mCV . appEmissaryHostName } :${ mCV . appEmissaryPort } /UI` ) ; }
252264 } [ process . env . NODE_ENV ] ( ) ,
253- axios . get ( `http://${ mCV . seleniumHostName } :${ mCV . seleniumPort } /wd/hub/status` )
265+ got . get ( `http://${ mCV . seleniumHostName } :${ mCV . seleniumPort } /wd/hub/status` )
254266 ] ) ;
255267
256268 const results = await Promise . all ( containerReadyPromises )
@@ -262,7 +274,7 @@ internals.s2ContainersReady = async ({ collectionOfS2ContainerHostNamesWithPorts
262274 log . warning ( `${ error . response . status } ` , { tags : [ 'app.emissary' ] } ) ;
263275 log . warning ( `${ error . response . headers } ` , { tags : [ 'app.emissary' ] } ) ;
264276 } else if ( error . request && error . message ) {
265- log . warning ( `The request was made to check emissary health but no response was received.\nThe error.message was: ${ error . message } \nThe error.stack was: ${ error . stack } ` , { tags : [ 'app.emissary' ] } ) ;
277+ log . warning ( `The request was made to check emissary health but no response was received.\nThe error.message was: ${ error . message } ` , { tags : [ 'app.emissary' ] } ) ;
266278 } else {
267279 log . warning ( 'Something happened in setting up the request that triggered an Error' , { tags : [ 'app.emissary' ] } ) ;
268280 log . warning ( `${ error . message } ` , { tags : [ 'app.emissary' ] } ) ;
@@ -271,8 +283,8 @@ internals.s2ContainersReady = async ({ collectionOfS2ContainerHostNamesWithPorts
271283
272284 if ( results ) {
273285 const isReady = {
274- appEmissary : ( response ) => ( typeof response . data === 'string' ) && response . data . includes ( 'ZAP API UI' ) ,
275- seleniumContainer : ( response ) => response . data . value . ready === true
286+ appEmissary : ( response ) => ( typeof response . body === 'string' ) && response . body . includes ( 'ZAP API UI' ) ,
287+ seleniumContainer : ( response ) => Bourne . parse ( response . body ) . value . ready === true
276288 } ;
277289 const containersThatAreNotReady = results . filter ( ( e ) => ! ( isReady . appEmissary ( e ) || isReady . seleniumContainer ( e ) ) ) ;
278290 log . notice ( `containersThatAreNotReady is: ${ JSON . stringify ( containersThatAreNotReady ) } ` , { tags : [ 'app.emissary' , 's2ContainersReady' ] } ) ;
0 commit comments