Skip to content

Commit 0acc84f

Browse files
committed
slave -> emissary renaming
1 parent 539a5fd commit 0acc84f

File tree

12 files changed

+66
-66
lines changed

12 files changed

+66
-66
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Take the Zap API Key that you set-up in the [purpleteam-s2-containers](https://g
4545

4646
The following two values should be the same. They should also match the value of the orchestrator `outcomes.dir`:
4747

48-
**`slave.report.dir`** Configure this value. This needs to be a directory of your choosing that both the orchestrator and app-scanner containers use. The directory you choose and configure needs group `rwx` permissions applied to it becuase the orchestrator and tester containers share the same group, they also read, write and delete outcome files within this directory.
48+
**`emissary.report.dir`** Configure this value. This needs to be a directory of your choosing that both the orchestrator and app-scanner containers use. The directory you choose and configure needs group `rwx` permissions applied to it becuase the orchestrator and tester containers share the same group, they also read, write and delete outcome files within this directory.
4949

5050
**`results.dir`** Configure this value. This needs to be a directory of your choosing that both the orchestrator and app-scanner containers use. The directory you choose and configure needs group `rwx` permissions applied to it becuase the orchestrator and tester containers share the same group, they also read, write and delete outcome files within this directory.
5151

config/config.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"host": {
66
"host": "172.25.0.120"
77
},
8-
"slave": {
8+
"emissary": {
99
"protocol": "http",
1010
"hostname": "172.17.0.2",
1111
"apiKey": "<zap-api-key-here>",

config/config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ const schema = {
7474
}
7575
}
7676
},
77-
slave: {
77+
emissary: {
7878
protocol: {
79-
doc: 'The protocol that the slave is listening as.',
79+
doc: 'The protocol that the emissary is listening as.',
8080
format: ['https', 'http'],
8181
default: 'https'
8282
},
8383
hostname: {
84-
doc: 'The hostname (IP or name) address of the slave host.',
84+
doc: 'The hostname (IP or name) address of the emissary host.',
8585
format: String,
8686
default: '240.0.0.0'
8787
},
8888
port: {
89-
doc: 'The port that the slave is listening on.',
89+
doc: 'The port that the emissary is listening on.',
9090
format: 'port',
9191
default: 8080
9292
},
@@ -125,8 +125,8 @@ const schema = {
125125
default: 10
126126
}
127127
},
128-
shutdownSlavesAfterTest: {
129-
doc: 'Useful for inspecting slave containers during debugging.',
128+
shutdownEmissariesAfterTest: {
129+
doc: 'Useful for inspecting emissary containers during debugging.',
130130
format: 'Boolean',
131131
default: true
132132
}

src/api/app/do/sut.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ const getProperties = (selecter) => {
111111
};
112112

113113

114-
const initialiseBrowser = async (slaveProperties, selenium) => {
115-
const { knownZapErrorsWithHelpMessageForBuildUser: knownZapFormatStringErrorsWithHelpMessageForBuildUser } = slaveProperties;
114+
const initialiseBrowser = async (emissaryProperties, selenium) => {
115+
const { knownZapErrorsWithHelpMessageForBuildUser: knownZapFormatStringErrorsWithHelpMessageForBuildUser } = emissaryProperties;
116116
const webDriverFactory = new WebDriverFactory();
117117
log.debug(`selenium is: ${JSON.stringify(selenium)}`, { tags: [`pid-${process.pid}`, 'sut', 'initialiseBrowser'] });
118118
webDriver = await webDriverFactory.webDriver({
119119
log,
120120
selenium,
121121
browser: properties.browser,
122-
slave: slaveProperties,
122+
emissary: emissaryProperties,
123123
sutProtocol: properties.protocol
124124
});
125125

src/api/app/models/app.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ const statusMap = {
2929

3030
class App {
3131
constructor(options) {
32-
const { log, strings, slave, cucumber: cucumberConfig, results, publisher, runType, cloud, debug } = options;
32+
const { log, strings, emissary, cucumber: cucumberConfig, results, publisher, runType, cloud, debug } = options;
3333

3434
this.log = log;
3535
this.strings = strings;
36-
this.slave = slave;
36+
this.emissary = emissary;
3737
this.cucumber = cucumberConfig;
3838
this.results = results;
3939
this.publisher = publisher;
@@ -89,24 +89,24 @@ class App {
8989
return testPlan;
9090
}
9191

92-
// Receiving appSlavePort and seleniumPort are only essential if running in cloud environment.
93-
createCucumberArgs({ sessionProps = {}, slaveHost = this.slave.hostname, seleniumContainerName = '', appSlavePort = this.slave.port, seleniumPort = 4444 }) {
92+
// Receiving appEmissaryPort and seleniumPort are only essential if running in cloud environment.
93+
createCucumberArgs({ sessionProps = {}, emissaryHost = this.emissary.hostname, seleniumContainerName = '', appEmissaryPort = this.emissary.port, seleniumPort = 4444 }) {
9494
// sut.validateProperties(sutProperties);
9595
this.log.debug(`seleniumContainerName is: ${seleniumContainerName}`, { tags: ['app'] });
96-
const slaveProperties = {
97-
hostname: slaveHost,
98-
protocol: this.slave.protocol,
99-
port: appSlavePort,
100-
apiKey: this.slave.apiKey,
101-
apiFeedbackSpeed: this.slave.apiFeedbackSpeed,
102-
reportDir: this.slave.report.dir,
103-
spider: this.slave.spider
96+
const emissaryProperties = {
97+
hostname: emissaryHost,
98+
protocol: this.emissary.protocol,
99+
port: appEmissaryPort,
100+
apiKey: this.emissary.apiKey,
101+
apiFeedbackSpeed: this.emissary.apiFeedbackSpeed,
102+
reportDir: this.emissary.report.dir,
103+
spider: this.emissary.spider
104104
};
105105

106-
// zap.validateProperties(slaveProperties);
106+
// zap.validateProperties(emissaryProperties);
107107

108108
const cucumberParameters = {
109-
slaveProperties,
109+
emissaryProperties,
110110
seleniumContainerName,
111111
seleniumPort,
112112
sutProperties: sessionProps,

src/api/app/models/app.parallel.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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

257257
internals.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.

src/api/app/models/app.publisher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const publisher = (runParams) => {
1919
const { model, model: { log, publisher: p }, sessionsProps } = runParams;
2020

2121
setInterval(() => {
22-
model.slavesDeployed = true;
22+
model.emissariesDeployed = true;
2323
const sessionId = `${sessionsProps[0].testSession.id}`;
2424
log.debug('publishing to redis', { tags: ['app', sessionId] });
2525
try {

src/api/app/models/app.sequential.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const sequential = (runParams) => {
3939
stdout: cucumberCliStdout
4040
});
4141

42-
model.slavesDeployed = true;
42+
model.emissariesDeployed = true;
4343
// If you want to debug the tests before execution returns, uncomment the await, make this function async and add await to the calling function.
4444
/* await */cucumberCliInstance.run()
4545
.then(async (succeeded) => {

0 commit comments

Comments
 (0)