@@ -49,18 +49,18 @@ const internals = {
4949 numberOfTestSessions : 0 ,
5050 testSessionDoneCount : 0 ,
5151 // In the Cloud we use ECS Tasks which combine the two image types, so we do both in the single Lambda invocation.
52- // Locally we need to provision app slaves and selenium standalones separately.
52+ // Locally we need to provision app emissaries and selenium standalones separately.
5353 lambdaProvisioningFuncNames : {
54- cloud : [ 'provisionAppSlaves ' ] ,
55- local : [ 'provisionAppSlaves ' , 'provisionSeleniumStandalones' ]
54+ cloud : [ 'provisionAppEmissaries ' ] ,
55+ local : [ 'provisionAppEmissaries ' , 'provisionSeleniumStandalones' ]
5656 } ,
5757 // These environment variables are set in IaC ecs.tf and only used in cloud environment.
5858 // Doc: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html
5959 clientContext : {
6060 Custom : {
6161 customer : process . env . CUSTOMER ,
6262 customerClusterArn : process . env . CUSTOMER_CLUSTER_ARN ,
63- serviceDiscoveryServices : Object . entries ( process . env ) . filter ( ( [ key ] ) => key . startsWith ( 's2_app_slave_ ' ) ) . reduce ( ( accumulator , [ key , value ] ) => ( { ...accumulator , [ key ] : value } ) , { } )
63+ serviceDiscoveryServices : Object . entries ( process . env ) . filter ( ( [ key ] ) => key . startsWith ( 's2_app_emissary_ ' ) ) . reduce ( ( accumulator , [ key , value ] ) => ( { ...accumulator , [ key ] : value } ) , { } )
6464 }
6565 } ,
6666 isCloudEnv : process . env . NODE_ENV === 'cloud'
@@ -146,7 +146,7 @@ internals.mergeProvisionedViaLambdaDtoCollection = (provisionedViaLambdaDtoColle
146146 const provisionedViaLambdaDtoItems = provisionedViaLambdaDtoCollection . map ( ( provisionedViaLambdaDto ) => provisionedViaLambdaDto . items ) ;
147147 // local may look like this:
148148 // provisionedViaLambdaDtoItems = [
149- // [ // Result of provisionAppSlaves
149+ // [ // Result of provisionAppEmissaries
150150 // {testSessionId: 'lowPrivUser', ...},
151151 // {testSessionId: 'adminUser', ...},
152152 // {testSessionId: 'anotherExample', ...}
@@ -161,21 +161,21 @@ internals.mergeProvisionedViaLambdaDtoCollection = (provisionedViaLambdaDtoColle
161161 // Todo: The following will require more testing, especially in local env.
162162 for ( let i = 0 ; i < numberOfItems ; i += 1 ) { // 3 items for example
163163 const itemCollector = [ ] ;
164- provisionedViaLambdaDtoItems . forEach ( ( items ) => { // 2. provisionAppSlaves and provisionSeleniumStandalones ... if running in local env.
164+ provisionedViaLambdaDtoItems . forEach ( ( items ) => { // 2. provisionAppEmissaries and provisionSeleniumStandalones ... if running in local env.
165165 itemCollector . push ( items [ i ] ) ;
166166 } ) ;
167167 toMerge . push ( itemCollector ) ;
168168 }
169169 // If running in local env:
170170 // toMerge = [
171171 // [
172- // {testSessionId: 'lowPrivUser', ...}, // Result of provisionAppSlaves
172+ // {testSessionId: 'lowPrivUser', ...}, // Result of provisionAppEmissaries
173173 // {testSessionId: 'lowPrivUser', ...} // Result of provisionSeleniumStandalones
174174 // ], [
175- // {testSessionId: 'adminUser', ...}, // Result of provisionAppSlaves
175+ // {testSessionId: 'adminUser', ...}, // Result of provisionAppEmissaries
176176 // {testSessionId: 'adminUser', ...} // Result of provisionSeleniumStandalones
177177 // ], [
178- // {testSessionId: 'anotherExample', ...}, // Result of provisionAppSlaves
178+ // {testSessionId: 'anotherExample', ...}, // Result of provisionAppEmissaries
179179 // {testSessionId: 'anotherExample', ...} // Result of provisionSeleniumStandalones
180180 // ]
181181 // ]
@@ -185,14 +185,14 @@ internals.mergeProvisionedViaLambdaDtoCollection = (provisionedViaLambdaDtoColle
185185 mergedProvisionedViaLambdaDto . items = toMerge . map ( ( mCV ) => {
186186 // If running in local env:
187187 // First iteration: mCV = [
188- // {testSessionId: 'lowPrivUser', ...}, // Result of provisionAppSlaves
188+ // {testSessionId: 'lowPrivUser', ...}, // Result of provisionAppEmissaries
189189 // {testSessionId: 'lowPrivUser', ...} // Result of provisionSeleniumStandalones
190190 // ]
191191 const { browser, testSessionId } = mCV [ 0 ] ;
192192 return {
193193 browser,
194194 testSessionId,
195- appSlaveContainerName : mCV . find ( ( e ) => e . appSlaveContainerName ) . appSlaveContainerName ,
195+ appEmissaryContainerName : mCV . find ( ( e ) => e . appEmissaryContainerName ) . appEmissaryContainerName ,
196196 seleniumContainerName : mCV . find ( ( e ) => e . seleniumContainerName ) . seleniumContainerName ,
197197 ...( isCloudEnv && { appEcsServiceName : mCV . find ( ( e ) => e . appEcsServiceName ) . appEcsServiceName } ) ,
198198 ...( isCloudEnv && { seleniumEcsServiceName : mCV . find ( ( e ) => e . seleniumEcsServiceName ) . seleniumEcsServiceName } ) ,
@@ -224,15 +224,15 @@ internals.provisionViaLambda = async ({ cloudFuncOpts, provisionViaLambdaDto })
224224 // Doc: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#constructor-property
225225 const lambda = new Lambda ( cloudFuncOpts ) ;
226226
227- // local env calls two lambda functions which each start app slave zap or app slave selenium,
228- // cloud env calls one lambda function which starts app slave zap and app slave selenium tasks.
227+ // local env calls two lambda functions which each start app emissary zap or app emissary selenium,
228+ // cloud env calls one lambda function which starts app emissary zap and app emissary selenium tasks.
229229 const collectionOfWrappedProvisionedViaLambdaDtos = lambdaFuncNames . map ( ( f ) => provisionContainers ( { lambda, provisionViaLambdaDto, lambdaFunc : f } ) ) ;
230230
231231 const provisionedViaLambdaDtoCollection = await resolvePromises ( collectionOfWrappedProvisionedViaLambdaDtos ) ;
232232 // local may look like this,
233- // where as cloud will only have the provisionAppSlaves result with each item containing both app slave and selenium values for each test session:
233+ // where as cloud will only have the provisionAppEmissaries result with each item containing both app emissary and selenium values for each test session:
234234 // provisionedViaLambdaDtoCollection = [
235- // { // Result of provisionAppSlaves
235+ // { // Result of provisionAppEmissaries
236236 // items: [
237237 // {testSessionId: 'lowPrivUser', ...},
238238 // {testSessionId: 'adminUser', ...},
@@ -256,7 +256,7 @@ internals.provisionViaLambda = async ({ cloudFuncOpts, provisionViaLambdaDto })
256256
257257internals . s2ContainersReady = async ( { collectionOfS2ContainerHostNamesWithPorts } ) => {
258258 // Todo: port should be more specific, I.E. zap container port (container port): https://gitlab.com/purpleteam-labs/purpleteam/-/issues/26
259- const { log, model : { slave : { protocol, port } } } = internals ;
259+ const { log, model : { emissary : { protocol, port } } } = internals ;
260260 log . notice ( 'Checking whether S2 app containers are ready yet.' , { tags : [ 'app.parallel' ] } ) ;
261261 let containersAreReady = false ;
262262
@@ -265,8 +265,8 @@ internals.s2ContainersReady = async ({ collectionOfS2ContainerHostNamesWithPorts
265265 // https://github.com/zaproxy/zaproxy/issues/3796#issuecomment-319376915
266266 // https://github.com/zaproxy/zaproxy/issues/3594
267267 {
268- cloud ( ) { return axios . get ( `${ protocol } ://zap:${ port } /UI` , { httpAgent : new HttpProxyAgent ( `${ protocol } ://${ mCV . appSlaveHostName } :${ mCV . appSlavePort } ` ) } ) ; } ,
269- local ( ) { return axios . get ( `${ protocol } ://${ mCV . appSlaveHostName } :${ mCV . appSlavePort } /UI` ) ; }
268+ cloud ( ) { return axios . get ( `${ protocol } ://zap:${ port } /UI` , { httpAgent : new HttpProxyAgent ( `${ protocol } ://${ mCV . appEmissaryHostName } :${ mCV . appEmissaryPort } ` ) } ) ; } ,
269+ local ( ) { return axios . get ( `${ protocol } ://${ mCV . appEmissaryHostName } :${ mCV . appEmissaryPort } /UI` ) ; }
270270 } [ process . env . NODE_ENV ] ( ) ,
271271 axios . get ( `http://${ mCV . seleniumHostName } :${ mCV . seleniumPort } /wd/hub/status` )
272272 ] ) ;
@@ -280,7 +280,7 @@ internals.s2ContainersReady = async ({ collectionOfS2ContainerHostNamesWithPorts
280280 log . warning ( `${ error . response . status } ` , { tags : [ 'app.parallel' ] } ) ;
281281 log . warning ( `${ error . response . headers } ` , { tags : [ 'app.parallel' ] } ) ;
282282 } else if ( error . request && error . message ) {
283- log . warning ( `The request was made to check slave health but no response was received.\nThe error.message was: ${ error . message } \nThe error.stack was: ${ error . stack } ` , { tags : [ 'app.parallel' ] } ) ;
283+ 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.parallel' ] } ) ;
284284 } else {
285285 log . warning ( 'Something happened in setting up the request that triggered an Error' , { tags : [ 'app.parallel' ] } ) ;
286286 log . warning ( `${ error . message } ` , { tags : [ 'app.parallel' ] } ) ;
@@ -289,10 +289,10 @@ internals.s2ContainersReady = async ({ collectionOfS2ContainerHostNamesWithPorts
289289
290290 if ( results ) {
291291 const isReady = {
292- appSlave : ( response ) => ( typeof response . data === 'string' ) && response . data . includes ( 'ZAP API UI' ) ,
292+ appEmissary : ( response ) => ( typeof response . data === 'string' ) && response . data . includes ( 'ZAP API UI' ) ,
293293 seleniumContainer : ( response ) => response . data . value . ready === true
294294 } ;
295- const containersThatAreNotReady = results . filter ( ( e ) => ! ( isReady . appSlave ( e ) || isReady . seleniumContainer ( e ) ) ) ;
295+ const containersThatAreNotReady = results . filter ( ( e ) => ! ( isReady . appEmissary ( e ) || isReady . seleniumContainer ( e ) ) ) ;
296296 log . debug ( `containersThatAreNotReady is: ${ JSON . stringify ( containersThatAreNotReady ) } ` , { tags : [ 'app.parallel' , 's2ContainersReady' ] } ) ;
297297 containersAreReady = ! containersThatAreNotReady . length ;
298298 }
@@ -359,8 +359,8 @@ internals.getS2ContainerHostNamesWithPorts = ({ provisionedViaLambdaDto, cloudFu
359359 log . debug ( `The value of allS2ServiceDiscoveryServiceInstancesNowAvailable is: ${ allS2ServiceDiscoveryServiceInstancesNowAvailable } ` , { tags : [ 'app.parallel' , 'getS2ContainerHostNamesWithPorts' ] } ) ;
360360 if ( allS2ServiceDiscoveryServiceInstancesNowAvailable ) {
361361 collectionOfS2ContainerHostNamesWithPorts = collectionOfS2ServiceDiscoveryServiceInstances . map ( ( mCV ) => ( {
362- appSlaveHostName : mCV . s2AppServiceDiscoveryServiceInstances . Instances [ 0 ] . Attributes . AWS_INSTANCE_IPV4 ,
363- appSlavePort : mCV . s2AppServiceDiscoveryServiceInstances . Instances [ 0 ] . Attributes . AWS_INSTANCE_PORT ,
362+ appEmissaryHostName : mCV . s2AppServiceDiscoveryServiceInstances . Instances [ 0 ] . Attributes . AWS_INSTANCE_IPV4 ,
363+ appEmissaryPort : mCV . s2AppServiceDiscoveryServiceInstances . Instances [ 0 ] . Attributes . AWS_INSTANCE_PORT ,
364364 seleniumHostName : mCV . s2SeleniumServiceDiscoveryServiceInstances . Instances [ 0 ] . Attributes . AWS_INSTANCE_IPV4 ,
365365 seleniumPort : mCV . s2SeleniumServiceDiscoveryServiceInstances . Instances [ 0 ] . Attributes . AWS_INSTANCE_PORT
366366 } ) ) ;
@@ -378,8 +378,8 @@ internals.getS2ContainerHostNamesWithPorts = ({ provisionedViaLambdaDto, cloudFu
378378 log . debug ( 'Called setTimeout for the first time.' , { tags : [ 'app.parallel' , 'getS2ContainerHostNamesWithPorts' ] } ) ;
379379 } else {
380380 collectionOfS2ContainerHostNamesWithPorts = provisionedViaLambdaDto . items . map ( ( mCV ) => ( {
381- appSlaveHostName : mCV . appSlaveContainerName ,
382- appSlavePort : model . slave . port ,
381+ appEmissaryHostName : mCV . appEmissaryContainerName ,
382+ appEmissaryPort : model . emissary . port ,
383383 seleniumHostName : mCV . seleniumContainerName ,
384384 seleniumPort : '4444'
385385 } ) ) ;
@@ -488,7 +488,7 @@ internals.runTestSession = (cloudFuncOpts, runableSessionProps, deprovisionViaLa
488488 const message = `child process "cucumber Cli" running session with id: "${ runableSessionProps . sessionProps . testSession . id } " exited with code: "${ code } ", and signal: "${ signal } ".` ;
489489 log . notice ( message , { tags : [ 'app.parallel' ] } ) ;
490490 internals . testSessionDoneCount += 1 ;
491- if ( model . slave . shutdownSlavesAfterTest && internals . testSessionDoneCount >= numberOfTestSessions ) {
491+ if ( model . emissary . shutdownEmissariesAfterTest && internals . testSessionDoneCount >= numberOfTestSessions ) {
492492 internals . testSessionDoneCount = 0 ;
493493 internals . deprovisionS2ContainersViaLambda ( cloudFuncOpts , deprovisionViaLambdaDto ) ;
494494 }
@@ -521,7 +521,7 @@ const parallel = async ({ model, model: { log, debug, cloud: { function: { regio
521521 items : sessionsProps . map ( ( s ) => ( {
522522 testSessionId : s . testSession . id ,
523523 browser : s . browser ,
524- appSlaveContainerName : null ,
524+ appEmissaryContainerName : null ,
525525 seleniumContainerName : null ,
526526 appEcsServiceName : null , // Populated in the cloud lambda function, so we can destroy the ECS services after testing.
527527 seleniumEcsServiceName : null // Populated in the cloud lambda function, so we can destroy the ECS services after testing.
@@ -532,7 +532,7 @@ const parallel = async ({ model, model: { log, debug, cloud: { function: { regio
532532 log . debug ( `The value of provisionedViaLambdaDto is: ${ JSON . stringify ( provisionedViaLambdaDto ) } ` , { tags : [ 'app.parallel' , 'parallel' ] } ) ;
533533
534534 const deprovisionViaLambdaDto = {
535- local : { items : [ 'app-slave ' , 'selenium-standalone' ] } ,
535+ local : { items : [ 'app-emissary ' , 'selenium-standalone' ] } ,
536536 cloud : { items : provisionedViaLambdaDto . items . flatMap ( ( cV ) => [ cV . appEcsServiceName , cV . seleniumEcsServiceName ] ) }
537537 } [ process . env . NODE_ENV ] ;
538538 log . debug ( `The value of deprovisionViaLambdaDto is: ${ JSON . stringify ( deprovisionViaLambdaDto ) } ` , { tags : [ 'app.parallel' , 'parallel' ] } ) ;
@@ -547,9 +547,9 @@ const parallel = async ({ model, model: { log, debug, cloud: { function: { regio
547547
548548 const runableSessionsProps = resolved . collectionOfS2ContainerHostNamesWithPorts . map ( ( cV , i ) => ( {
549549 sessionProps : sessionsProps [ i ] ,
550- slaveHost : cV . appSlaveHostName ,
550+ emissaryHost : cV . appEmissaryHostName ,
551551 seleniumContainerName : cV . seleniumHostName ,
552- appSlavePort : cV . appSlavePort ,
552+ appEmissaryPort : cV . appEmissaryPort ,
553553 seleniumPort : cV . seleniumPort
554554 } ) ) ;
555555 // Todo: obfuscate sensitive values from runableSessionProps.
0 commit comments