Skip to content

Commit

Permalink
Integrate new Zap reports
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymist committed Jan 2, 2022
1 parent f4b34ff commit ea17ef5
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 8 deletions.
4 changes: 2 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ const schema = {
job: {
version: {
doc: 'The version of the Job accepted by this API.',
format: ['0.1.0-alpha.1', '1.0.0-alpha.3', '2.0.0-alpha.3', '3.0.0-alpha.3'],
default: '3.0.0-alpha.3'
format: ['0.1.0-alpha.1', '1.0.0-alpha.3', '2.0.0-alpha.3', '3.0.0-alpha.3', '3.1.0-alpha.3'],
default: '3.1.0-alpha.3'
}
},
outcomes: {
Expand Down
8 changes: 2 additions & 6 deletions src/api/orchestration/models/orchestrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Orchestrate {
// For a lib based and richer solution: https://github.com/archiverjs/node-archiver
const { compressionLvl, fileName, dir } = this.#outcomesConfig;
this.#log.info(`About to write outcomes file "${fileName}" to dir "${dir}"`, { tags: ['orchestrate'] });
exec(`zip ${compressionLvl} ${fileName} *`, { cwd: dir }, (error, stdout, stderr) => {
exec(`zip -r ${compressionLvl} ${fileName} *`, { cwd: dir }, (error, stdout, stderr) => {
if (error) {
this.#log.error(`Error occurred archiving the outcomes: ${error}.`, { tags: ['orchestrate'] });
return;
Expand Down Expand Up @@ -148,15 +148,11 @@ class Orchestrate {
}

async #clearOutcomesDir() {
// const promiseToChmod = promisify(fs.chmod);
const { dir } = this.#outcomesConfig;

try {
const fileNames = await fsPromises.readdir(dir);
if (fileNames.length) {
// const chmodPromises = fileNames.map(async (name) => promiseToChmod(name, Oo300));
// await Promise.all(chmodPromises);
const unlinkPromises = fileNames.map(async (name) => fsPromises.unlink(`${dir}${name}`));
const unlinkPromises = fileNames.map(async (name) => fsPromises.rm(`${dir}${name}`, { recursive: true }));
await Promise.all(unlinkPromises);
}
} catch (e) { // This may fail if the group permissions on the outcomes dir does not have wx.
Expand Down
32 changes: 32 additions & 0 deletions src/api/orchestration/schemas/job.aPi.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,38 @@ const schema = {
scanningStrategy: { type: 'string', enum: ['ApiStandard'], default: 'ApiStandard' },
postScanningStrategy: { type: 'string', enum: ['ApiStandard'], default: 'ApiStandard' },
reportingStrategy: { type: 'string', enum: ['Standard'], default: 'Standard' },
reports: {
type: 'object',
additionalProperties: false,
properties: {
templateThemes: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
properties: {
name: {
type: 'string',
enum: [
'traditionalHtml',
'traditionalHtmlPlusLight',
'traditionalHtmlPlusDark',
'traditionalJson',
'traditionalMd',
'traditionalXml',
'riskConfidenceHtmlDark',
'modernMarketing',
'highLevelReport'
]
}
},
required: ['name']
},
minItems: 1
}
},
required: ['templateThemes']
},
openApi: { $ref: '#/definitions/OpenApi' },
soap: { $ref: '#/definitions/Soap' },
graphQl: { $ref: '#/definitions/GraphQl' },
Expand Down
32 changes: 32 additions & 0 deletions src/api/orchestration/schemas/job.browserApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,38 @@ const schema = {
scanningStrategy: { type: 'string', enum: ['BrowserAppStandard'], default: 'BrowserAppStandard' },
postScanningStrategy: { type: 'string', enum: ['BrowserAppStandard'], default: 'BrowserAppStandard' },
reportingStrategy: { type: 'string', enum: ['Standard'], default: 'Standard' },
reports: {
type: 'object',
additionalProperties: false,
properties: {
templateThemes: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
properties: {
name: {
type: 'string',
enum: [
'traditionalHtml',
'traditionalHtmlPlusLight',
'traditionalHtmlPlusDark',
'traditionalJson',
'traditionalMd',
'traditionalXml',
'riskConfidenceHtmlDark',
'modernMarketing',
'highLevelReport'
]
}
},
required: ['name']
},
minItems: 1
}
},
required: ['templateThemes']
},
excludedRoutes: {
type: 'array',
items: { type: 'string' },
Expand Down

0 comments on commit ea17ef5

Please sign in to comment.