@contrast/contrast 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,72 +1,64 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getNumOfAndSeverityType = exports.buildFormattedHeaderNum = exports.gatherRemediationAdvice = exports.buildBody = exports.buildHeader = exports.printFormattedOutput = exports.printVulnerabilityResponse = exports.getReport = exports.createSummaryMessageBottom = exports.createSummaryMessageTop = void 0;
7
- const commonApi_1 = require("../../utils/commonApi");
8
- const reportListModel_1 = require("./models/reportListModel");
9
- const lodash_1 = require("lodash");
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const reportUtils_1 = require("./utils/reportUtils");
12
- const severityCountModel_1 = require("./models/severityCountModel");
13
- const reportOutputModel_1 = require("./models/reportOutputModel");
14
- const constants_1 = require("../../constants/constants");
15
- const cli_table3_1 = __importDefault(require("cli-table3"));
16
- const reportGuidanceModel_1 = require("./models/reportGuidanceModel");
2
+ const commonApi = require('../../utils/commonApi');
3
+ const { ReportCompositeKey, ReportList, ReportModelStructure } = require('./models/reportListModel');
4
+ const { orderBy } = require('lodash');
5
+ const chalk = require('chalk');
6
+ const { countVulnerableLibrariesBySeverity, orderByHighestPriority, findHighestSeverityCVE, findNameAndVersion, severityCountAllCVEs, findCVESeverity } = require('./utils/reportUtils');
7
+ const { SeverityCountModel } = require('./models/severityCountModel');
8
+ const { ReportOutputBodyModel, ReportOutputHeaderModel, ReportOutputModel } = require('./models/reportOutputModel');
9
+ const { CE_URL, CRITICAL_COLOUR, HIGH_COLOUR, LOW_COLOUR, MEDIUM_COLOUR, NOTE_COLOUR } = require('../../constants/constants');
10
+ const Table = require('cli-table3');
11
+ const { ReportGuidanceModel } = require('./models/reportGuidanceModel');
12
+ const i18n = require('i18n');
17
13
  const createSummaryMessageTop = (numberOfVulnerableLibraries, numberOfCves) => {
18
14
  numberOfVulnerableLibraries === 1
19
15
  ? console.log(`Found 1 vulnerable library containing ${numberOfCves} CVE`)
20
16
  : console.log(`Found ${numberOfVulnerableLibraries} vulnerable libraries containing ${numberOfCves} CVEs`);
21
17
  };
22
- exports.createSummaryMessageTop = createSummaryMessageTop;
23
- const createSummaryMessageBottom = (numberOfVulnerableLibraries) => {
18
+ const createSummaryMessageBottom = numberOfVulnerableLibraries => {
24
19
  numberOfVulnerableLibraries === 1
25
- ? console.log(`Found 1 vulnerable library`)
26
- : console.log(`Found ${numberOfVulnerableLibraries} vulnerable libraries`);
20
+ ? console.log(`Found 1 vulnerability`)
21
+ : console.log(`Found ${numberOfVulnerableLibraries} vulnerabilities`);
27
22
  };
28
- exports.createSummaryMessageBottom = createSummaryMessageBottom;
29
23
  const getReport = async (config, reportId) => {
30
- const client = (0, commonApi_1.getHttpClient)(config);
24
+ const client = commonApi.getHttpClient(config);
31
25
  return client
32
26
  .getReportById(config, reportId)
33
- .then((res) => {
27
+ .then(res => {
34
28
  if (res.statusCode === 200) {
35
29
  return res.body;
36
30
  }
37
31
  else {
38
- console.log(JSON.stringify(res));
39
- (0, commonApi_1.handleResponseErrors)(res, 'report');
32
+ console.log(JSON.stringify(res.statusCode));
33
+ commonApi.handleResponseErrors(res, 'report');
40
34
  }
41
35
  })
42
- .catch((err) => {
36
+ .catch(err => {
43
37
  console.log(err);
44
38
  });
45
39
  };
46
- exports.getReport = getReport;
47
40
  const printVulnerabilityResponse = (config, vulnerableLibraries, numberOfVulnerableLibraries, numberOfCves, guidance) => {
48
41
  let hasSomeVulnerabilitiesReported = false;
49
- (0, exports.printFormattedOutput)(config, vulnerableLibraries, numberOfVulnerableLibraries, numberOfCves, guidance);
42
+ printFormattedOutput(config, vulnerableLibraries, numberOfVulnerableLibraries, numberOfCves, guidance);
50
43
  if (Object.keys(vulnerableLibraries).length > 0) {
51
44
  hasSomeVulnerabilitiesReported = true;
52
45
  }
53
46
  return hasSomeVulnerabilitiesReported;
54
47
  };
55
- exports.printVulnerabilityResponse = printVulnerabilityResponse;
56
48
  const printFormattedOutput = (config, libraries, numberOfVulnerableLibraries, numberOfCves, guidance) => {
57
- (0, exports.createSummaryMessageTop)(numberOfVulnerableLibraries, numberOfCves);
49
+ createSummaryMessageTop(numberOfVulnerableLibraries, numberOfCves);
58
50
  console.log();
59
- const report = new reportListModel_1.ReportList();
51
+ const report = new ReportList();
60
52
  for (const library of libraries) {
61
- const { name, version } = (0, reportUtils_1.findNameAndVersion)(library, config);
62
- const newOutputModel = new reportListModel_1.ReportModelStructure(new reportListModel_1.ReportCompositeKey(name, version, (0, reportUtils_1.findHighestSeverityCVE)(library.cveArray), (0, reportUtils_1.severityCountAllCVEs)(library.cveArray, new severityCountModel_1.SeverityCountModel()).getTotal), library.cveArray);
53
+ const { name, version } = findNameAndVersion(library, config);
54
+ const newOutputModel = new ReportModelStructure(new ReportCompositeKey(name, version, findHighestSeverityCVE(library.cveArray), severityCountAllCVEs(library.cveArray, new SeverityCountModel()).getTotal), library.cveArray);
63
55
  report.reportOutputList.push(newOutputModel);
64
56
  }
65
- const outputOrderedByLowestSeverityAndLowestNumOfCvesFirst = (0, lodash_1.orderBy)(report.reportOutputList, [
66
- (reportListItem) => {
57
+ const outputOrderedByLowestSeverityAndLowestNumOfCvesFirst = orderBy(report.reportOutputList, [
58
+ reportListItem => {
67
59
  return reportListItem.compositeKey.highestSeverity.priority;
68
60
  },
69
- (reportListItem) => {
61
+ reportListItem => {
70
62
  return reportListItem.compositeKey.numberOfSeverities;
71
63
  }
72
64
  ], ['asc', 'desc']);
@@ -75,83 +67,81 @@ const printFormattedOutput = (config, libraries, numberOfVulnerableLibraries, nu
75
67
  contrastHeaderNumCounter++;
76
68
  const { libraryName, libraryVersion, highestSeverity } = reportModel.compositeKey;
77
69
  const numOfCVEs = reportModel.cveArray.length;
78
- const table = new cli_table3_1.default({
79
- chars: {
80
- top: '',
81
- 'top-mid': '',
82
- 'top-left': '',
83
- 'top-right': '',
84
- bottom: '',
85
- 'bottom-mid': '',
86
- 'bottom-left': '',
87
- 'bottom-right': '',
88
- left: '',
89
- 'left-mid': '',
90
- mid: '',
91
- 'mid-mid': '',
92
- right: '',
93
- 'right-mid': '',
94
- middle: ' '
95
- },
96
- style: { 'padding-left': 0, 'padding-right': 0 },
97
- colAligns: ['right'],
98
- wordWrap: true,
99
- colWidths: [12, 1, 100]
100
- });
70
+ const table = getReportTable();
101
71
  const header = buildHeader(highestSeverity, contrastHeaderNumCounter, libraryName, libraryVersion, numOfCVEs);
102
72
  const advice = gatherRemediationAdvice(guidance, libraryName, libraryVersion);
103
73
  const body = buildBody(reportModel.cveArray, advice);
104
- const reportOutputModel = new reportOutputModel_1.ReportOutputModel(header, body);
74
+ const reportOutputModel = new ReportOutputModel(header, body);
105
75
  table.push(reportOutputModel.body.issueMessage, reportOutputModel.body.adviceMessage);
106
76
  console.log(reportOutputModel.header.vulnMessage, reportOutputModel.header.introducesMessage);
107
77
  console.log(table.toString() + '\n');
108
78
  }
109
- (0, exports.createSummaryMessageBottom)(numberOfVulnerableLibraries);
79
+ createSummaryMessageBottom(numberOfVulnerableLibraries);
110
80
  const { criticalMessage, highMessage, mediumMessage, lowMessage, noteMessage } = buildFooter(outputOrderedByLowestSeverityAndLowestNumOfCvesFirst);
111
81
  console.log(`${criticalMessage} | ${highMessage} | ${mediumMessage} | ${lowMessage} | ${noteMessage}`);
112
- if (config.host !== constants_1.CE_URL) {
113
- console.log('\n' + chalk_1.default.bold('View your full dependency tree in Contrast:'));
82
+ if (config.host !== CE_URL) {
83
+ console.log('\n' + chalk.bold('View your full dependency tree in Contrast:'));
114
84
  console.log(`${config.host}/Contrast/static/ng/index.html#/${config.organizationId}/applications/${config.applicationId}/libs/dependency-tree`);
115
85
  }
116
86
  };
117
- exports.printFormattedOutput = printFormattedOutput;
87
+ function getReportTable() {
88
+ return new Table({
89
+ chars: {
90
+ top: '',
91
+ 'top-mid': '',
92
+ 'top-left': '',
93
+ 'top-right': '',
94
+ bottom: '',
95
+ 'bottom-mid': '',
96
+ 'bottom-left': '',
97
+ 'bottom-right': '',
98
+ left: '',
99
+ 'left-mid': '',
100
+ mid: '',
101
+ 'mid-mid': '',
102
+ right: '',
103
+ 'right-mid': '',
104
+ middle: ' '
105
+ },
106
+ style: { 'padding-left': 0, 'padding-right': 0 },
107
+ colAligns: ['right'],
108
+ wordWrap: true,
109
+ colWidths: [12, 1, 100]
110
+ });
111
+ }
118
112
  function buildHeader(highestSeverity, contrastHeaderNum, libraryName, version, numOfCVEs) {
119
113
  const vulnerabilityPluralised = numOfCVEs > 1 ? 'vulnerabilities' : 'vulnerability';
120
114
  const formattedHeaderNum = buildFormattedHeaderNum(contrastHeaderNum);
121
- const headerColour = chalk_1.default.hex(highestSeverity.outputColour);
115
+ const headerColour = chalk.hex(highestSeverity.colour);
122
116
  const headerNumAndSeverity = headerColour(`${formattedHeaderNum} - [${highestSeverity.severity}]`);
123
117
  const libraryNameAndVersion = headerColour.bold(`${libraryName}-${version}`);
124
118
  const vulnMessage = `${headerNumAndSeverity} ${libraryNameAndVersion}`;
125
119
  const introducesMessage = `introduces ${numOfCVEs} ${vulnerabilityPluralised}`;
126
- return new reportOutputModel_1.ReportOutputHeaderModel(vulnMessage, introducesMessage);
120
+ return new ReportOutputHeaderModel(vulnMessage, introducesMessage);
127
121
  }
128
- exports.buildHeader = buildHeader;
129
122
  function buildBody(cveArray, advice) {
130
- const cveMessages = [];
131
- (0, reportUtils_1.findCVESeveritiesAndOrderByHighestPriority)(cveArray).forEach(reportSeverityModel => {
132
- const { outputColour, severity, cveName } = reportSeverityModel;
133
- const severityShorthand = chalk_1.default
134
- .hex(outputColour)
135
- .bold(`[${severity.charAt(0).toUpperCase()}]`);
136
- const builtMessage = severityShorthand + cveName;
137
- cveMessages.push(builtMessage);
138
- });
139
- const numAndSeverityType = getNumOfAndSeverityType(cveArray);
140
- const issueMessage = [
141
- chalk_1.default.bold('Issue'),
142
- ':',
143
- `${numAndSeverityType} ${cveMessages.join(', ')}`
144
- ];
123
+ let assignPriorityToVulns = cveArray.map(result => findCVESeverity(result));
124
+ const issueMessage = getIssueRow(assignPriorityToVulns);
145
125
  const minOrMax = advice.maximum ? advice.maximum : advice.minimum;
146
126
  const displayAdvice = minOrMax
147
- ? `Change to version ${chalk_1.default.bold(minOrMax)}`
127
+ ? `Change to version ${chalk.bold(minOrMax)}`
148
128
  : 'No recommendation is available according to our data. Upgrade to the latest stable is the best advice we can give.';
149
- const adviceMessage = [chalk_1.default.bold('Advice'), ':', displayAdvice];
150
- return new reportOutputModel_1.ReportOutputBodyModel(issueMessage, adviceMessage);
129
+ const adviceMessage = [chalk.bold('Advice'), ':', displayAdvice];
130
+ return new ReportOutputBodyModel(issueMessage, adviceMessage);
131
+ }
132
+ function getIssueRow(cveArray) {
133
+ orderByHighestPriority(cveArray);
134
+ const cveMessagesList = getIssueCveMsgList(cveArray);
135
+ const cveNumbers = getSeverityCounts(cveArray);
136
+ const numAndSeverityTypeDesc = getNumOfAndSeverityType(cveNumbers);
137
+ return [
138
+ chalk.bold('Issue'),
139
+ ':',
140
+ `${numAndSeverityTypeDesc} ${cveMessagesList.join(', ')}`
141
+ ];
151
142
  }
152
- exports.buildBody = buildBody;
153
143
  function gatherRemediationAdvice(guidance, libraryName, libraryVersion) {
154
- const guidanceModel = new reportGuidanceModel_1.ReportGuidanceModel();
144
+ const guidanceModel = new ReportGuidanceModel();
155
145
  const data = guidance[libraryName + '@' + libraryVersion];
156
146
  if (data) {
157
147
  guidanceModel.minimum = data.minUpgradeVersion;
@@ -159,43 +149,29 @@ function gatherRemediationAdvice(guidance, libraryName, libraryVersion) {
159
149
  }
160
150
  return guidanceModel;
161
151
  }
162
- exports.gatherRemediationAdvice = gatherRemediationAdvice;
163
152
  function buildFormattedHeaderNum(contrastHeaderNum) {
164
153
  return `CONTRAST-${contrastHeaderNum.toString().padStart(3, '0')}`;
165
154
  }
166
- exports.buildFormattedHeaderNum = buildFormattedHeaderNum;
167
- function getNumOfAndSeverityType(cveArray) {
168
- const { critical, high, medium, low, note } = (0, reportUtils_1.severityCountAllCVEs)(cveArray, new severityCountModel_1.SeverityCountModel());
169
- const criticalNumCheck = critical > 0;
170
- const highNumCheck = high > 0;
171
- const highDivider = highNumCheck ? '|' : '';
172
- const mediumNumCheck = medium > 0;
173
- const mediumDivider = mediumNumCheck ? '|' : '';
174
- const lowNumCheck = low > 0;
175
- const lowDivider = lowNumCheck ? '|' : '';
176
- const noteNumCheck = low > 0;
177
- const noteDivider = noteNumCheck ? '|' : '';
178
- const criticalMessage = criticalNumCheck
179
- ? `${critical} Critical ${highDivider}`
180
- : '';
181
- const highMessage = highNumCheck ? `${high} High ${mediumDivider}` : '';
182
- const mediumMessage = mediumNumCheck ? `${medium} Medium ${lowDivider}` : '';
183
- const lowMessage = lowNumCheck ? `${low} Low ${noteDivider}` : '';
184
- const noteMessage = noteNumCheck ? `${note} Note` : '';
185
- return `${criticalMessage} ${highMessage} ${mediumMessage} ${lowMessage} ${noteMessage}`
155
+ function getNumOfAndSeverityType(cveNumbers) {
156
+ const { critical, high, medium, low, note } = cveNumbers;
157
+ const criticalMsg = critical > 0 ? `${critical} Critical | ` : '';
158
+ const highMsg = high > 0 ? `${high} High | ` : '';
159
+ const mediumMsg = medium > 0 ? `${medium} Medium | ` : '';
160
+ const lowMsg = low > 0 ? `${low} Low | ` : '';
161
+ const noteMsg = note > 0 ? `${note} Note` : '';
162
+ return `${criticalMsg} ${highMsg} ${mediumMsg} ${lowMsg} ${noteMsg}`
186
163
  .replace(/\s+/g, ' ')
187
164
  .trim();
188
165
  }
189
- exports.getNumOfAndSeverityType = getNumOfAndSeverityType;
190
- const buildFooter = (reportModelStructure) => {
191
- const { critical, high, medium, low, note } = (0, reportUtils_1.countVulnerableLibrariesBySeverity)(reportModelStructure);
192
- const criticalMessage = chalk_1.default
193
- .hex(constants_1.CRITICAL_COLOUR)
166
+ const buildFooter = reportModelStructure => {
167
+ const { critical, high, medium, low, note } = countVulnerableLibrariesBySeverity(reportModelStructure);
168
+ const criticalMessage = chalk
169
+ .hex(CRITICAL_COLOUR)
194
170
  .bold(`${critical} Critical`);
195
- const highMessage = chalk_1.default.hex(constants_1.HIGH_COLOUR).bold(`${high} High`);
196
- const mediumMessage = chalk_1.default.hex(constants_1.MEDIUM_COLOUR).bold(`${medium} Medium`);
197
- const lowMessage = chalk_1.default.hex(constants_1.LOW_COLOUR).bold(`${low} Low`);
198
- const noteMessage = chalk_1.default.hex(constants_1.NOTE_COLOUR).bold(`${note} Note`);
171
+ const highMessage = chalk.hex(HIGH_COLOUR).bold(`${high} High`);
172
+ const mediumMessage = chalk.hex(MEDIUM_COLOUR).bold(`${medium} Medium`);
173
+ const lowMessage = chalk.hex(LOW_COLOUR).bold(`${low} Low`);
174
+ const noteMessage = chalk.hex(NOTE_COLOUR).bold(`${note} Note`);
199
175
  return {
200
176
  criticalMessage,
201
177
  highMessage,
@@ -204,3 +180,86 @@ const buildFooter = (reportModelStructure) => {
204
180
  noteMessage
205
181
  };
206
182
  };
183
+ const getIssueCveMsgList = results => {
184
+ const cveMessages = [];
185
+ results.forEach(reportSeverityModel => {
186
+ const { colour, severity, name } = reportSeverityModel;
187
+ const severityShorthand = chalk
188
+ .hex(colour)
189
+ .bold(`[${severity.charAt(0).toUpperCase()}]`);
190
+ const builtMessage = severityShorthand + name;
191
+ cveMessages.push(builtMessage);
192
+ });
193
+ return cveMessages;
194
+ };
195
+ const getSeverityCounts = results => {
196
+ const acc = {
197
+ critical: 0,
198
+ high: 0,
199
+ medium: 0,
200
+ low: 0,
201
+ note: 0,
202
+ total: 0
203
+ };
204
+ if (results && results.length > 0) {
205
+ results.forEach(i => {
206
+ acc[i.severity.toLowerCase()] += 1;
207
+ acc.total += 1;
208
+ return acc;
209
+ });
210
+ }
211
+ return acc;
212
+ };
213
+ const printNoVulnFoundMsg = () => {
214
+ console.log(i18n.__('scanNoVulnerabilitiesFound'));
215
+ console.log(i18n.__('scanNoVulnerabilitiesFoundSecureCode'));
216
+ console.log(i18n.__('scanNoVulnerabilitiesFoundGoodWork'));
217
+ console.log(chalk.bold(`Found 0 vulnerabilities`));
218
+ console.log(i18n.__('foundDetailedVulnerabilities', String(0), String(0), String(0), String(0), String(0)));
219
+ };
220
+ const printVulnInfo = projectOverview => {
221
+ const totalVulnerabilities = projectOverview.total;
222
+ createSummaryMessageBottom(totalVulnerabilities);
223
+ const formattedValues = severityFormatted(projectOverview);
224
+ console.log(i18n.__('foundDetailedVulnerabilities', String(formattedValues.criticalFormatted), String(formattedValues.highFormatted), String(formattedValues.mediumFormatted), String(formattedValues.lowFormatted), String(formattedValues.noteFormatted)));
225
+ };
226
+ const severityFormatted = projectOverview => {
227
+ const criticalFormatted = chalk
228
+ .hex(CRITICAL_COLOUR)
229
+ .bold(`${projectOverview.critical} Critical`);
230
+ const highFormatted = chalk
231
+ .hex(HIGH_COLOUR)
232
+ .bold(`${projectOverview.high} High`);
233
+ const mediumFormatted = chalk
234
+ .hex(MEDIUM_COLOUR)
235
+ .bold(`${projectOverview.medium} Medium`);
236
+ const lowFormatted = chalk.hex(LOW_COLOUR).bold(`${projectOverview.low} Low`);
237
+ const noteFormatted = chalk
238
+ .hex(NOTE_COLOUR)
239
+ .bold(`${projectOverview.note} Note`);
240
+ return {
241
+ criticalFormatted,
242
+ highFormatted,
243
+ mediumFormatted,
244
+ lowFormatted,
245
+ noteFormatted
246
+ };
247
+ };
248
+ module.exports = {
249
+ createSummaryMessageTop,
250
+ getReport,
251
+ createSummaryMessageBottom,
252
+ printVulnerabilityResponse,
253
+ printFormattedOutput,
254
+ getReportTable,
255
+ buildHeader,
256
+ buildBody,
257
+ getIssueRow,
258
+ gatherRemediationAdvice,
259
+ buildFormattedHeaderNum,
260
+ getNumOfAndSeverityType,
261
+ getIssueCveMsgList,
262
+ getSeverityCounts,
263
+ printNoVulnFoundMsg,
264
+ printVulnInfo
265
+ };
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReportSeverityModel = void 0;
4
4
  class ReportSeverityModel {
5
- constructor(severity, priority, outputColour, cveName) {
5
+ constructor(severity, priority, colour, name) {
6
6
  this.severity = severity;
7
7
  this.priority = priority;
8
- this.outputColour = outputColour;
9
- this.cveName = cveName;
8
+ this.colour = colour;
9
+ this.name = name;
10
10
  }
11
11
  }
12
12
  exports.ReportSeverityModel = ReportSeverityModel;
@@ -22,15 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.vulnerabilityReportV2 = exports.formatVulnerabilityOutput = exports.convertJSDotNetPython = exports.convertKeysToStandardFormat = void 0;
30
27
  const commonReportingFunctions_1 = require("./commonReportingFunctions");
31
28
  const reportUtils_1 = require("./utils/reportUtils");
32
- const i18n_1 = __importDefault(require("i18n"));
33
- const chalk_1 = __importDefault(require("chalk"));
34
29
  const constants = __importStar(require("../../constants/constants"));
35
30
  const severityCountModel_1 = require("./models/severityCountModel");
36
31
  const common = __importStar(require("../../common/fail"));
@@ -67,11 +62,7 @@ function formatVulnerabilityOutput(libraryVulnerabilityResponse, id, config, rem
67
62
  const guidance = convertKeysToStandardFormat(config, remediationGuidance);
68
63
  const numberOfVulnerableLibraries = vulnerableLibraries.length;
69
64
  if (numberOfVulnerableLibraries === 0) {
70
- console.log(i18n_1.default.__('scanNoVulnerabilitiesFound'));
71
- console.log(i18n_1.default.__('scanNoVulnerabilitiesFoundSecureCode'));
72
- console.log(i18n_1.default.__('scanNoVulnerabilitiesFoundGoodWork'));
73
- console.log(chalk_1.default.bold(`Found ${numberOfVulnerableLibraries} vulnerabilities`));
74
- console.log(i18n_1.default.__('foundDetailedVulnerabilities', String(0), String(0), String(0), String(0), String(0)));
65
+ (0, commonReportingFunctions_1.printNoVulnFoundMsg)();
75
66
  return [false, 0, [new severityCountModel_1.SeverityCountModel()]];
76
67
  }
77
68
  else {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.countVulnerableLibrariesBySeverity = exports.findNameAndVersion = exports.severityCountSingleCVE = exports.severityCountAllCVEs = exports.severityCountAllLibraries = exports.convertGenericToTypedLibraryVulns = exports.findCVESeverity = exports.findCVESeveritiesAndOrderByHighestPriority = exports.findHighestSeverityCVE = void 0;
6
+ exports.countVulnerableLibrariesBySeverity = exports.findNameAndVersion = exports.severityCountSingleCVE = exports.severityCountAllCVEs = exports.severityCountAllLibraries = exports.convertGenericToTypedLibraryVulns = exports.findCVESeverity = exports.orderByHighestPriority = exports.findHighestSeverityCVE = void 0;
7
7
  const reportLibraryModel_1 = require("../models/reportLibraryModel");
8
8
  const reportSeverityModel_1 = require("../models/reportSeverityModel");
9
9
  const constants_1 = __importDefault(require("../../../constants/constants"));
@@ -16,10 +16,10 @@ function findHighestSeverityCVE(cveArray) {
16
16
  return (0, lodash_1.orderBy)(mappedToReportSeverityModels, cve => cve?.priority)[0];
17
17
  }
18
18
  exports.findHighestSeverityCVE = findHighestSeverityCVE;
19
- function findCVESeveritiesAndOrderByHighestPriority(cves) {
20
- return (0, lodash_1.orderBy)(cves.map(cve => findCVESeverity(cve)), ['priority'], ['asc']);
19
+ function orderByHighestPriority(cves) {
20
+ return (0, lodash_1.orderBy)(cves, ['priority'], ['asc']);
21
21
  }
22
- exports.findCVESeveritiesAndOrderByHighestPriority = findCVESeveritiesAndOrderByHighestPriority;
22
+ exports.orderByHighestPriority = orderByHighestPriority;
23
23
  function findCVESeverity(cve) {
24
24
  const cveName = cve.name;
25
25
  if (cve.cvss3SeverityCode === 'CRITICAL' || cve.severityCode === 'CRITICAL') {
@@ -2,7 +2,6 @@
2
2
  const autoDetection = require('../../../scan/autoDetection');
3
3
  const javaAnalysis = require('../../../scaAnalysis/java');
4
4
  const treeUpload = require('../../../scaAnalysis/common/treeUpload');
5
- const scaUpload = require('../../../scaAnalysis/common/scaServicesUpload');
6
5
  const auditController = require('../../audit/auditController');
7
6
  const { supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, NODE, PHP, DOTNET } } = require('../../../constants/constants');
8
7
  const goAnalysis = require('../../../scaAnalysis/go/goAnalysis');
@@ -47,8 +47,7 @@ const reportFailureError = () => {
47
47
  console.log(i18n_1.default.__('auditReportFailureMessage'));
48
48
  };
49
49
  exports.reportFailureError = reportFailureError;
50
- const genericError = (missingCliOption) => {
51
- console.log(missingCliOption);
50
+ const genericError = () => {
52
51
  console.error(i18n_1.default.__('genericErrorMessage'));
53
52
  process.exit(1);
54
53
  };
@@ -12,7 +12,7 @@ const MEDIUM = 'MEDIUM';
12
12
  const HIGH = 'HIGH';
13
13
  const CRITICAL = 'CRITICAL';
14
14
  const APP_NAME = 'contrast';
15
- const APP_VERSION = '1.0.13';
15
+ const APP_VERSION = '1.0.14';
16
16
  const TIMEOUT = 120000;
17
17
  const HIGH_COLOUR = '#ff9900';
18
18
  const CRITICAL_COLOUR = '#e35858';
@@ -80,6 +80,7 @@ const en_locales = () => {
80
80
  constantsApplicationName: 'The name of the application cataloged by Contrast UI',
81
81
  constantsCatalogueApplication: 'Provide this if you want to catalogue an application',
82
82
  failOptionErrorMessage: ' FAIL - CVEs have been detected that match at least the cve_severity option specified.',
83
+ failOptionMessage: ' Use with contrast scan or contrast audit. Detects failures based on the severity level specified with the --severity command. For example, "contrast scan --fail --severity high". Returns all failures if no severity level is specified.',
83
84
  constantsLanguage: 'Valid values are JAVA, DOTNET, NODE, PYTHON and RUBY. If there are multiple project configuration files in the project_path, language is also required. Also, provide this when cataloguing an application',
84
85
  constantsFilePath: `Specify a directory or the file where dependencies are declared. (By default, CodeSec will search for project files in the current directory.)`,
85
86
  constantsSilent: 'Silences JSON output.',
@@ -96,7 +97,7 @@ const en_locales = () => {
96
97
  constantsFail: 'Set the process to fail if this option is set in combination with --cve_severity.',
97
98
  failThresholdOptionErrorMessage: 'More than 0 vulnerabilities found',
98
99
  failSeverityOptionErrorMessage: ' FAIL - Results detected vulnerabilities over accepted severity level',
99
- constantsSeverity: 'Allows the user to report libraries with vulnerabilities above a chosen severity level. For example, cve_severity medium only reports libraries with vulnerabilities at medium or higher severity. Values for level are high, medium or low.',
100
+ constantsSeverity: 'Use with "contrast scan --fail --severity high" or "contrast audit --fail --severity high". Set the severity level to detect vulnerabilities or dependencies. Severity levels are critical, high, medium, low or note.',
100
101
  constantsCount: 'The number of CVEs that must be exceeded to fail a build',
101
102
  constantsHeader: 'CodeSec by Contrast Security',
102
103
  configHeader2: 'Config options',
@@ -113,7 +114,7 @@ const en_locales = () => {
113
114
  configHeader: 'Config',
114
115
  constantsConfigUsageContents: 'view / clear the configuration',
115
116
  constantsPrerequisitesContent: 'To scan a Java project you will need a .jar or .war file for analysis\n' +
116
- 'To scan a Javascript project you will need a .js or.zip file for analysis\n' +
117
+ 'To scan a Javascript project you will need a single .js or a .zip of multiple .js files\n' +
117
118
  'To scan a .NET c# webforms project you will need a .exe or a .zip file for analysis\n',
118
119
  constantsUsage: 'Usage',
119
120
  constantsUsageCommandExample: 'contrast [command] [options]',
@@ -213,16 +214,23 @@ const en_locales = () => {
213
214
  scanOptionsFileNameSummary: 'Path of the file you want to scan. If no file is specified, Contrast searches for a .jar, .war, .exe or .zip file in the working directory.',
214
215
  scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
215
216
  authSuccessMessage: 'Authentication successful',
216
- runAuthSuccessMessage: "Now you can use CodeSec by Contrast \nRun: \n'contrast scan' to run CodeSec’s industry leading SAST scanner \n'contrast audit' to find vulnerabilities in your open source dependencies \n'contrast lambda' to secure your AWS serverless functions\nor 'contrast help' to learn more about the capabilities.",
217
+ runAuthSuccessMessage: chalk.bold('CodeSec by Contrast') +
218
+ '\nScan, secure and ship your code in minutes for FREE. \n' +
219
+ chalk.bold('\nRun\n') +
220
+ chalk.bold('\ncontrast scan') +
221
+ " to run Contrast's industry leading SAST scanner. \nSupports Java, JavaScript and .Net \n" +
222
+ chalk.bold('\ncontrast audit') +
223
+ ' to find vulnerabilities in your open source dependencies.\nSupports Java, .NET, Node, Ruby, Python, Go and PHP \n' +
224
+ chalk.bold('\ncontrast lambda') +
225
+ ' to secure your AWS serverless functions. \nSupports Java and Python \n' +
226
+ chalk.bold('\ncontrast help') +
227
+ ' to learn more about the capabilities.',
217
228
  authWaitingMessage: 'Waiting for auth...',
218
229
  authTimedOutMessage: 'Auth Timed out, try again',
219
230
  zipErrorScan: 'We only support zip files for JAVASCRIPT language, please set the flag --language JAVASCRIPT',
220
231
  unknownFileErrorScan: 'Unsupported file selected for Scan.',
221
232
  foundScanFile: 'Found: %s',
222
- foundDetailedVulnerabilities: chalk.bold('%s Critical') +
223
- ' | ' +
224
- chalk.bold('%s High') +
225
- ' | %s Medium | %s Low | %s Note',
233
+ foundDetailedVulnerabilities: chalk.bold('%s') + ' | ' + chalk.bold('%s') + ' | %s | %s | %s ',
226
234
  requiredParams: 'All required parameters are not present.',
227
235
  timeoutScan: 'Timeout set to 5 minutes.',
228
236
  searchingScanFileDirectory: 'Searching for file to scan from %s...',
package/dist/constants.js CHANGED
@@ -101,7 +101,7 @@ const scanOptionDefinitions = [
101
101
  description: '{bold ' +
102
102
  i18n.__('constantsOptional') +
103
103
  '}: ' +
104
- i18n.__('failOptionErrorMessage')
104
+ i18n.__('failOptionMessage')
105
105
  },
106
106
  {
107
107
  name: 'severity',
@@ -219,7 +219,7 @@ const auditOptionDefinitions = [
219
219
  description: '{bold ' +
220
220
  i18n.__('constantsOptional') +
221
221
  '}: ' +
222
- i18n.__('failOptionErrorMessage')
222
+ i18n.__('failOptionMessage')
223
223
  },
224
224
  {
225
225
  name: 'severity',
package/dist/index.js CHANGED
@@ -73,11 +73,13 @@ const start = async () => {
73
73
  const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
74
74
  foundCommand
75
75
  ? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
76
- : console.log(`Unknown Command: ${command} \nUse --help for the full list`);
76
+ : console.log(`\nUnknown Command: ${command} \n`);
77
+ console.log(mainUsageGuide);
77
78
  await (0, telemetry_1.sendTelemetryConfigAsConfObj)(config, command, argvMain, 'FAILURE', 'undefined');
78
79
  }
79
80
  else {
80
- console.log(`Unknown Command: ${command} \nUse --help for the full list`);
81
+ console.log(`\nUnknown Command: ${command}\n`);
82
+ console.log(mainUsageGuide);
81
83
  await (0, telemetry_1.sendTelemetryConfigAsConfObj)(config, command, argvMain, 'FAILURE', 'undefined');
82
84
  }
83
85
  process.exit(9);
@@ -119,7 +119,7 @@ const processLambda = async (argv) => {
119
119
  exports.processLambda = processLambda;
120
120
  const getAvailableFunctions = async (lambdaOptions) => {
121
121
  const lambdas = await (0, lambdaUtils_1.getAllLambdas)(lambdaOptions);
122
- (0, lambdaUtils_1.printAvailableLambdas)(lambdas, { runtimes: ['python', 'java'] });
122
+ (0, lambdaUtils_1.printAvailableLambdas)(lambdas, { runtimes: ['python', 'java', 'node'] });
123
123
  };
124
124
  exports.getAvailableFunctions = getAvailableFunctions;
125
125
  const actualProcessLambda = async (lambdaOptions) => {