@contrast/contrast 1.0.8 → 1.0.9
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.
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +3 -12
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +88 -53
- package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +4 -3
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +58 -11
- package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +38 -5
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +6 -30
- package/dist/audit/save.js +21 -13
- package/dist/commands/audit/auditConfig.js +0 -16
- package/dist/commands/audit/auditController.js +1 -10
- package/dist/commands/audit/help.js +7 -24
- package/dist/commands/audit/processAudit.js +1 -7
- package/dist/commands/audit/saveFile.js +2 -2
- package/dist/commands/scan/sca/scaAnalysis.js +22 -9
- package/dist/common/HTTPClient.js +8 -8
- package/dist/constants/constants.js +7 -2
- package/dist/constants/locales.js +24 -30
- package/dist/constants.js +11 -9
- package/dist/index.js +54 -45
- package/dist/lambda/lambda.js +5 -2
- package/dist/sbom/generateSbom.js +2 -2
- package/dist/scaAnalysis/common/formatMessage.js +7 -1
- package/dist/scaAnalysis/common/treeUpload.js +4 -5
- package/dist/scaAnalysis/dotnet/analysis.js +43 -0
- package/dist/scaAnalysis/dotnet/index.js +10 -0
- package/dist/scaAnalysis/javascript/analysis.js +4 -7
- package/dist/scaAnalysis/javascript/index.js +14 -5
- package/dist/scaAnalysis/php/analysis.js +14 -33
- package/dist/scaAnalysis/php/index.js +11 -4
- package/dist/scaAnalysis/ruby/analysis.js +2 -10
- package/dist/scan/autoDetection.js +18 -21
- package/dist/scan/fileUtils.js +31 -12
- package/dist/scan/formatScanOutput.js +3 -3
- package/dist/scan/scanConfig.js +2 -2
- package/dist/utils/getConfig.js +1 -6
- package/package.json +2 -3
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +3 -32
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +128 -68
- package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +11 -5
- package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +41 -19
- package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +43 -4
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +6 -32
- package/src/audit/save.js +32 -16
- package/src/commands/audit/auditConfig.ts +0 -25
- package/src/commands/audit/auditController.ts +0 -11
- package/src/commands/audit/help.ts +7 -24
- package/src/commands/audit/processAudit.ts +1 -7
- package/src/commands/audit/saveFile.ts +2 -2
- package/src/commands/scan/processScan.js +0 -1
- package/src/commands/scan/sca/scaAnalysis.js +28 -13
- package/src/common/HTTPClient.js +9 -9
- package/src/constants/constants.js +9 -3
- package/src/constants/locales.js +47 -35
- package/src/constants.js +12 -10
- package/src/index.ts +76 -66
- package/src/lambda/lambda.ts +5 -2
- package/src/lambda/types.ts +1 -0
- package/src/sbom/generateSbom.ts +2 -2
- package/src/scaAnalysis/common/formatMessage.js +8 -1
- package/src/scaAnalysis/common/treeUpload.js +4 -5
- package/src/scaAnalysis/dotnet/analysis.js +54 -0
- package/src/scaAnalysis/dotnet/index.js +11 -0
- package/src/scaAnalysis/javascript/analysis.js +6 -7
- package/src/scaAnalysis/javascript/index.js +23 -7
- package/src/scaAnalysis/php/analysis.js +15 -35
- package/src/scaAnalysis/php/index.js +15 -4
- package/src/scaAnalysis/ruby/analysis.js +2 -11
- package/src/scan/autoDetection.js +18 -24
- package/src/scan/fileUtils.js +33 -12
- package/src/scan/formatScanOutput.ts +3 -3
- package/src/scan/scanConfig.js +2 -4
- package/src/utils/getConfig.ts +1 -12
- package/dist/audit/AnalysisEngine.js +0 -37
- package/dist/audit/autodetection/autoDetectLanguage.js +0 -32
- package/dist/audit/dotnetAnalysisEngine/index.js +0 -25
- package/dist/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -35
- package/dist/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -15
- package/dist/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -18
- package/dist/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -14
- package/dist/audit/dotnetAnalysisEngine/sanitizer.js +0 -9
- package/dist/audit/goAnalysisEngine/index.js +0 -17
- package/dist/audit/goAnalysisEngine/parseProjectFileContents.js +0 -164
- package/dist/audit/goAnalysisEngine/readProjectFileContents.js +0 -21
- package/dist/audit/goAnalysisEngine/sanitizer.js +0 -5
- package/dist/audit/javaAnalysisEngine/index.js +0 -34
- package/dist/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -155
- package/dist/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -353
- package/dist/audit/javaAnalysisEngine/readProjectFileContents.js +0 -98
- package/dist/audit/javaAnalysisEngine/sanitizer.js +0 -5
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -25
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -25
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -35
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -24
- package/dist/audit/languageAnalysisEngine/constants.js +0 -20
- package/dist/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -25
- package/dist/audit/languageAnalysisEngine/index.js +0 -39
- package/dist/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -66
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -166
- package/dist/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -40
- package/dist/audit/nodeAnalysisEngine/index.js +0 -31
- package/dist/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -18
- package/dist/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -18
- package/dist/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -17
- package/dist/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -14
- package/dist/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -24
- package/dist/audit/nodeAnalysisEngine/sanitizer.js +0 -9
- package/dist/audit/phpAnalysisEngine/index.js +0 -23
- package/dist/audit/phpAnalysisEngine/parseLockFileContents.js +0 -52
- package/dist/audit/phpAnalysisEngine/readLockFileContents.js +0 -13
- package/dist/audit/phpAnalysisEngine/readProjectFileContents.js +0 -16
- package/dist/audit/phpAnalysisEngine/sanitizer.js +0 -5
- package/dist/audit/pythonAnalysisEngine/index.js +0 -25
- package/dist/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -17
- package/dist/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -21
- package/dist/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -13
- package/dist/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -14
- package/dist/audit/pythonAnalysisEngine/sanitizer.js +0 -7
- package/dist/audit/rubyAnalysisEngine/index.js +0 -25
- package/dist/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -176
- package/dist/audit/rubyAnalysisEngine/parsedGemfile.js +0 -22
- package/dist/audit/rubyAnalysisEngine/readGemfileContents.js +0 -14
- package/dist/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -14
- package/dist/audit/rubyAnalysisEngine/sanitizer.js +0 -6
- package/src/audit/AnalysisEngine.js +0 -103
- package/src/audit/autodetection/autoDetectLanguage.ts +0 -40
- package/src/audit/dotnetAnalysisEngine/index.js +0 -26
- package/src/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -47
- package/src/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -29
- package/src/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -30
- package/src/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -26
- package/src/audit/dotnetAnalysisEngine/sanitizer.js +0 -11
- package/src/audit/goAnalysisEngine/index.js +0 -18
- package/src/audit/goAnalysisEngine/parseProjectFileContents.js +0 -209
- package/src/audit/goAnalysisEngine/readProjectFileContents.js +0 -31
- package/src/audit/goAnalysisEngine/sanitizer.js +0 -7
- package/src/audit/javaAnalysisEngine/index.js +0 -41
- package/src/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -225
- package/src/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -420
- package/src/audit/javaAnalysisEngine/readProjectFileContents.js +0 -141
- package/src/audit/javaAnalysisEngine/sanitizer.js +0 -6
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -36
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -42
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -54
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -33
- package/src/audit/languageAnalysisEngine/constants.js +0 -23
- package/src/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -41
- package/src/audit/languageAnalysisEngine/index.js +0 -45
- package/src/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -96
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -251
- package/src/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -49
- package/src/audit/nodeAnalysisEngine/index.js +0 -35
- package/src/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -20
- package/src/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -26
- package/src/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -23
- package/src/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -27
- package/src/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -36
- package/src/audit/nodeAnalysisEngine/sanitizer.js +0 -11
- package/src/audit/phpAnalysisEngine/index.js +0 -27
- package/src/audit/phpAnalysisEngine/parseLockFileContents.js +0 -60
- package/src/audit/phpAnalysisEngine/readLockFileContents.js +0 -14
- package/src/audit/phpAnalysisEngine/readProjectFileContents.js +0 -25
- package/src/audit/phpAnalysisEngine/sanitizer.js +0 -4
- package/src/audit/pythonAnalysisEngine/index.js +0 -55
- package/src/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -23
- package/src/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -33
- package/src/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -16
- package/src/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -22
- package/src/audit/pythonAnalysisEngine/sanitizer.js +0 -9
- package/src/audit/rubyAnalysisEngine/index.js +0 -30
- package/src/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -215
- package/src/audit/rubyAnalysisEngine/parsedGemfile.js +0 -39
- package/src/audit/rubyAnalysisEngine/readGemfileContents.js +0 -18
- package/src/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -17
- package/src/audit/rubyAnalysisEngine/sanitizer.js +0 -8
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const i18n = require('i18n');
|
|
5
|
-
module.exports = exports = (analysis, next) => {
|
|
6
|
-
const { file, languageAnalysis } = analysis;
|
|
7
|
-
try {
|
|
8
|
-
languageAnalysis.projectRootFilenames = getProjectRootFilenames(file);
|
|
9
|
-
}
|
|
10
|
-
catch (err) {
|
|
11
|
-
next(err);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
next();
|
|
15
|
-
};
|
|
16
5
|
const getProjectRootFilenames = file => {
|
|
17
6
|
let projectStats = null;
|
|
18
7
|
try {
|
|
@@ -36,4 +25,6 @@ const getProjectRootFilenames = file => {
|
|
|
36
25
|
}
|
|
37
26
|
throw new Error(i18n.__('languageAnalysisProjectRootFileNameMissingError'), file);
|
|
38
27
|
};
|
|
39
|
-
exports
|
|
28
|
+
module.exports = {
|
|
29
|
+
getProjectRootFilenames
|
|
30
|
+
};
|
|
@@ -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.getNumOfAndSeverityType = exports.buildFormattedHeaderNum = exports.buildBody = exports.buildHeader = exports.printFormattedOutput = exports.printVulnerabilityResponse = exports.getReport = exports.
|
|
6
|
+
exports.getNumOfAndSeverityType = exports.buildFormattedHeaderNum = exports.gatherRemediationAdvice = exports.buildBody = exports.buildHeader = exports.printFormattedOutput = exports.printVulnerabilityResponse = exports.getReport = exports.createSummaryMessage = void 0;
|
|
7
7
|
const commonApi_1 = require("../../../utils/commonApi");
|
|
8
8
|
const reportListModel_1 = require("./models/reportListModel");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -12,12 +12,13 @@ const reportUtils_1 = require("./utils/reportUtils");
|
|
|
12
12
|
const severityCountModel_1 = require("./models/severityCountModel");
|
|
13
13
|
const reportOutputModel_1 = require("./models/reportOutputModel");
|
|
14
14
|
const constants_1 = require("../../../constants/constants");
|
|
15
|
-
const
|
|
15
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
16
|
+
const createSummaryMessage = (numberOfVulnerableLibraries, numberOfCves) => {
|
|
16
17
|
numberOfVulnerableLibraries === 1
|
|
17
|
-
? console.log(`Found 1 vulnerable library containing ${numberOfCves}
|
|
18
|
-
: console.log(`Found ${numberOfVulnerableLibraries} vulnerable libraries containing ${numberOfCves} CVEs
|
|
18
|
+
? console.log(`Found 1 vulnerable library containing ${numberOfCves} CVE`)
|
|
19
|
+
: console.log(`Found ${numberOfVulnerableLibraries} vulnerable libraries containing ${numberOfCves} CVEs`);
|
|
19
20
|
};
|
|
20
|
-
exports.
|
|
21
|
+
exports.createSummaryMessage = createSummaryMessage;
|
|
21
22
|
const getReport = async (config, reportId) => {
|
|
22
23
|
const client = (0, commonApi_1.getHttpClient)(config);
|
|
23
24
|
return client
|
|
@@ -36,16 +37,18 @@ const getReport = async (config, reportId) => {
|
|
|
36
37
|
});
|
|
37
38
|
};
|
|
38
39
|
exports.getReport = getReport;
|
|
39
|
-
const printVulnerabilityResponse = (
|
|
40
|
+
const printVulnerabilityResponse = (config, vulnerableLibraries, numberOfVulnerableLibraries, numberOfCves, guidance) => {
|
|
40
41
|
let hasSomeVulnerabilitiesReported = false;
|
|
41
|
-
(0, exports.printFormattedOutput)(
|
|
42
|
-
if (Object.keys(
|
|
42
|
+
(0, exports.printFormattedOutput)(config, vulnerableLibraries, numberOfVulnerableLibraries, numberOfCves, guidance);
|
|
43
|
+
if (Object.keys(vulnerableLibraries).length > 0) {
|
|
43
44
|
hasSomeVulnerabilitiesReported = true;
|
|
44
45
|
}
|
|
45
46
|
return hasSomeVulnerabilitiesReported;
|
|
46
47
|
};
|
|
47
48
|
exports.printVulnerabilityResponse = printVulnerabilityResponse;
|
|
48
|
-
const printFormattedOutput = (libraries,
|
|
49
|
+
const printFormattedOutput = (config, libraries, numberOfVulnerableLibraries, numberOfCves, guidance) => {
|
|
50
|
+
(0, exports.createSummaryMessage)(numberOfVulnerableLibraries, numberOfCves);
|
|
51
|
+
console.log();
|
|
49
52
|
const report = new reportListModel_1.ReportList();
|
|
50
53
|
for (const library of libraries) {
|
|
51
54
|
const { name, version } = (0, reportUtils_1.findNameAndVersion)(library, config);
|
|
@@ -59,23 +62,46 @@ const printFormattedOutput = (libraries, config) => {
|
|
|
59
62
|
(reportListItem) => {
|
|
60
63
|
return reportListItem.compositeKey.numberOfSeverities;
|
|
61
64
|
}
|
|
62
|
-
], ['desc']);
|
|
63
|
-
let contrastHeaderNumCounter =
|
|
65
|
+
], ['asc', 'desc']);
|
|
66
|
+
let contrastHeaderNumCounter = 0;
|
|
64
67
|
for (const reportModel of outputOrderedByLowestSeverityAndLowestNumOfCvesFirst) {
|
|
65
|
-
contrastHeaderNumCounter
|
|
68
|
+
contrastHeaderNumCounter++;
|
|
66
69
|
const { libraryName, libraryVersion, highestSeverity } = reportModel.compositeKey;
|
|
67
70
|
const numOfCVEs = reportModel.cveArray.length;
|
|
71
|
+
const table = new cli_table3_1.default({
|
|
72
|
+
chars: {
|
|
73
|
+
top: '',
|
|
74
|
+
'top-mid': '',
|
|
75
|
+
'top-left': '',
|
|
76
|
+
'top-right': '',
|
|
77
|
+
bottom: '',
|
|
78
|
+
'bottom-mid': '',
|
|
79
|
+
'bottom-left': '',
|
|
80
|
+
'bottom-right': '',
|
|
81
|
+
left: '',
|
|
82
|
+
'left-mid': '',
|
|
83
|
+
mid: '',
|
|
84
|
+
'mid-mid': '',
|
|
85
|
+
right: '',
|
|
86
|
+
'right-mid': '',
|
|
87
|
+
middle: ' '
|
|
88
|
+
},
|
|
89
|
+
style: { 'padding-left': 0, 'padding-right': 0 },
|
|
90
|
+
colAligns: ['right'],
|
|
91
|
+
wordWrap: true,
|
|
92
|
+
colWidths: [12, 1, 100]
|
|
93
|
+
});
|
|
68
94
|
const header = buildHeader(highestSeverity, contrastHeaderNumCounter, libraryName, libraryVersion, numOfCVEs);
|
|
69
|
-
const
|
|
95
|
+
const advice = gatherRemediationAdvice(guidance, reportModel);
|
|
96
|
+
const body = buildBody(reportModel.cveArray, advice);
|
|
70
97
|
const reportOutputModel = new reportOutputModel_1.ReportOutputModel(header, body);
|
|
98
|
+
table.push(reportOutputModel.body.issueMessage, reportOutputModel.body.issueMessageCves, reportOutputModel.body.adviceMessage);
|
|
71
99
|
console.log(reportOutputModel.header.vulnMessage, reportOutputModel.header.introducesMessage);
|
|
72
|
-
console.log(
|
|
73
|
-
console.log(reportOutputModel.body.adviceMessage + '\n');
|
|
74
|
-
}
|
|
75
|
-
const { criticalMessage, highMessage, mediumMessage, lowMessage, noteMessage, total } = buildFooter(libraries);
|
|
76
|
-
if (total > 1) {
|
|
77
|
-
console.log(`${criticalMessage} | ${highMessage} | ${mediumMessage} | ${lowMessage} | ${noteMessage}`);
|
|
100
|
+
console.log(table.toString() + '\n');
|
|
78
101
|
}
|
|
102
|
+
(0, exports.createSummaryMessage)(numberOfVulnerableLibraries, numberOfCves);
|
|
103
|
+
const { criticalMessage, highMessage, mediumMessage, lowMessage, noteMessage } = buildFooter(outputOrderedByLowestSeverityAndLowestNumOfCvesFirst);
|
|
104
|
+
console.log(`${criticalMessage} | ${highMessage} | ${mediumMessage} | ${lowMessage} | ${noteMessage}`);
|
|
79
105
|
};
|
|
80
106
|
exports.printFormattedOutput = printFormattedOutput;
|
|
81
107
|
function buildHeader(highestSeverity, contrastHeaderNum, libraryName, version, numOfCVEs) {
|
|
@@ -84,56 +110,48 @@ function buildHeader(highestSeverity, contrastHeaderNum, libraryName, version, n
|
|
|
84
110
|
const vulnMessage = chalk_1.default
|
|
85
111
|
.hex(highestSeverity.outputColour)
|
|
86
112
|
.bold(`${formattedHeaderNum} - [${highestSeverity.severity}] ${libraryName}-${version}`);
|
|
87
|
-
const introducesMessage =
|
|
113
|
+
const introducesMessage = `introduces ${numOfCVEs} ${vulnerabilityPluralised}`;
|
|
88
114
|
return new reportOutputModel_1.ReportOutputHeaderModel(vulnMessage, introducesMessage);
|
|
89
115
|
}
|
|
90
116
|
exports.buildHeader = buildHeader;
|
|
91
|
-
function buildBody(cveArray) {
|
|
117
|
+
function buildBody(cveArray, advice) {
|
|
92
118
|
const cveMessages = [];
|
|
93
119
|
(0, reportUtils_1.findCVESeveritiesAndOrderByHighestPriority)(cveArray).forEach(reportSeverityModel => {
|
|
94
120
|
const { outputColour, severity, cveName } = reportSeverityModel;
|
|
95
121
|
const severityShorthand = chalk_1.default
|
|
96
122
|
.hex(outputColour)
|
|
97
123
|
.bold(`[${severity.charAt(0).toUpperCase()}]`);
|
|
98
|
-
const builtMessage =
|
|
124
|
+
const builtMessage = severityShorthand + cveName;
|
|
99
125
|
cveMessages.push(builtMessage);
|
|
100
126
|
});
|
|
101
127
|
const numAndSeverityType = getNumOfAndSeverityType(cveArray);
|
|
102
|
-
const issueMessage =
|
|
103
|
-
const
|
|
104
|
-
|
|
128
|
+
const issueMessage = [chalk_1.default.bold('Issue'), ':', `${numAndSeverityType}`];
|
|
129
|
+
const issueMessageCves = ['', '', cveMessages.join(', ')];
|
|
130
|
+
const displayAdvice = advice?.minimum
|
|
131
|
+
? `Update to version ${chalk_1.default.bold(advice.minimum)}`
|
|
132
|
+
: `Update to latest version`;
|
|
133
|
+
const adviceMessage = [chalk_1.default.bold('Advice'), ':', displayAdvice];
|
|
134
|
+
return new reportOutputModel_1.ReportOutputBodyModel(issueMessage, issueMessageCves, adviceMessage);
|
|
105
135
|
}
|
|
106
136
|
exports.buildBody = buildBody;
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const highMessage = chalk_1.default.hex(constants_1.HIGH_COLOUR).bold(`${high} High`);
|
|
113
|
-
const mediumMessage = chalk_1.default.hex(constants_1.MEDIUM_COLOUR).bold(`${medium} Medium`);
|
|
114
|
-
const lowMessage = chalk_1.default.hex(constants_1.LOW_COLOUR).bold(`${low} Low`);
|
|
115
|
-
const noteMessage = chalk_1.default.hex(constants_1.NOTE_COLOUR).bold(`${note} Note`);
|
|
116
|
-
return {
|
|
117
|
-
criticalMessage,
|
|
118
|
-
highMessage,
|
|
119
|
-
mediumMessage,
|
|
120
|
-
lowMessage,
|
|
121
|
-
noteMessage,
|
|
122
|
-
total: getTotal
|
|
137
|
+
function gatherRemediationAdvice(guidance, reportModel) {
|
|
138
|
+
const guidanceData = {
|
|
139
|
+
minimum: undefined,
|
|
140
|
+
maximum: undefined,
|
|
141
|
+
latest: undefined
|
|
123
142
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
else if (contrastHeaderNum >= 10 && contrastHeaderNum < 100) {
|
|
131
|
-
formattedHeaderNum = `0${contrastHeaderNum}`;
|
|
132
|
-
}
|
|
133
|
-
else if (contrastHeaderNum >= 100) {
|
|
134
|
-
formattedHeaderNum = contrastHeaderNum;
|
|
143
|
+
const data = guidance[reportModel.compositeKey.libraryName +
|
|
144
|
+
'@' +
|
|
145
|
+
reportModel.compositeKey.libraryVersion];
|
|
146
|
+
if (data) {
|
|
147
|
+
guidanceData.minimum = data.minUpgradeVersion;
|
|
148
|
+
guidanceData.maximum = data.maxUpgradeVersion;
|
|
135
149
|
}
|
|
136
|
-
return
|
|
150
|
+
return guidanceData;
|
|
151
|
+
}
|
|
152
|
+
exports.gatherRemediationAdvice = gatherRemediationAdvice;
|
|
153
|
+
function buildFormattedHeaderNum(contrastHeaderNum) {
|
|
154
|
+
return `CONTRAST-${contrastHeaderNum.toString().padStart(3, '0')}`;
|
|
137
155
|
}
|
|
138
156
|
exports.buildFormattedHeaderNum = buildFormattedHeaderNum;
|
|
139
157
|
function getNumOfAndSeverityType(cveArray) {
|
|
@@ -148,3 +166,20 @@ function getNumOfAndSeverityType(cveArray) {
|
|
|
148
166
|
.trim();
|
|
149
167
|
}
|
|
150
168
|
exports.getNumOfAndSeverityType = getNumOfAndSeverityType;
|
|
169
|
+
const buildFooter = (reportModelStructure) => {
|
|
170
|
+
const { critical, high, medium, low, note } = (0, reportUtils_1.countVulnerableLibrariesBySeverity)(reportModelStructure);
|
|
171
|
+
const criticalMessage = chalk_1.default
|
|
172
|
+
.hex(constants_1.CRITICAL_COLOUR)
|
|
173
|
+
.bold(`${critical} Critical`);
|
|
174
|
+
const highMessage = chalk_1.default.hex(constants_1.HIGH_COLOUR).bold(`${high} High`);
|
|
175
|
+
const mediumMessage = chalk_1.default.hex(constants_1.MEDIUM_COLOUR).bold(`${medium} Medium`);
|
|
176
|
+
const lowMessage = chalk_1.default.hex(constants_1.LOW_COLOUR).bold(`${low} Low`);
|
|
177
|
+
const noteMessage = chalk_1.default.hex(constants_1.NOTE_COLOUR).bold(`${note} Note`);
|
|
178
|
+
return {
|
|
179
|
+
criticalMessage,
|
|
180
|
+
highMessage,
|
|
181
|
+
mediumMessage,
|
|
182
|
+
lowMessage,
|
|
183
|
+
noteMessage
|
|
184
|
+
};
|
|
185
|
+
};
|
|
@@ -16,9 +16,10 @@ class ReportOutputHeaderModel {
|
|
|
16
16
|
}
|
|
17
17
|
exports.ReportOutputHeaderModel = ReportOutputHeaderModel;
|
|
18
18
|
class ReportOutputBodyModel {
|
|
19
|
-
constructor(
|
|
20
|
-
this.issueMessage =
|
|
21
|
-
this.
|
|
19
|
+
constructor(issueMessage, issueMessageCves, adviceMessage) {
|
|
20
|
+
this.issueMessage = issueMessage;
|
|
21
|
+
this.issueMessageCves = issueMessageCves;
|
|
22
|
+
this.adviceMessage = adviceMessage;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.ReportOutputBodyModel = ReportOutputBodyModel;
|
|
@@ -1,23 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.vulnerabilityReportV2 = exports.formatVulnerabilityOutput = exports.
|
|
29
|
+
exports.vulnerabilityReportV2 = exports.formatVulnerabilityOutput = exports.convertJSDotNetPython = exports.convertKeysToStandardFormat = void 0;
|
|
7
30
|
const commonReportingFunctions_1 = require("./commonReportingFunctions");
|
|
8
31
|
const reportUtils_1 = require("./utils/reportUtils");
|
|
9
32
|
const i18n_1 = __importDefault(require("i18n"));
|
|
10
33
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
const constants = __importStar(require("../../../constants/constants"));
|
|
35
|
+
function convertKeysToStandardFormat(config, guidance) {
|
|
36
|
+
let convertedGuidance = guidance;
|
|
37
|
+
switch (config.language) {
|
|
38
|
+
case constants.supportedLanguages.JAVA:
|
|
39
|
+
case constants.supportedLanguages.GO:
|
|
40
|
+
case constants.supportedLanguages.PHP:
|
|
41
|
+
break;
|
|
42
|
+
case constants.supportedLanguages.NODE:
|
|
43
|
+
case constants.supportedLanguages.DOTNET:
|
|
44
|
+
case constants.supportedLanguages.PYTHON:
|
|
45
|
+
case constants.supportedLanguages.RUBY:
|
|
46
|
+
convertedGuidance = convertJSDotNetPython(guidance);
|
|
47
|
+
break;
|
|
16
48
|
}
|
|
49
|
+
return convertedGuidance;
|
|
50
|
+
}
|
|
51
|
+
exports.convertKeysToStandardFormat = convertKeysToStandardFormat;
|
|
52
|
+
function convertJSDotNetPython(guidance) {
|
|
53
|
+
const returnObject = {};
|
|
54
|
+
Object.entries(guidance).forEach(([key, value]) => {
|
|
55
|
+
const splitKey = key.split('/');
|
|
56
|
+
if (splitKey.length === 2) {
|
|
57
|
+
returnObject[splitKey[1]] = value;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return returnObject;
|
|
17
61
|
}
|
|
18
|
-
exports.
|
|
19
|
-
function formatVulnerabilityOutput(libraryVulnerabilityResponse, id, config) {
|
|
62
|
+
exports.convertJSDotNetPython = convertJSDotNetPython;
|
|
63
|
+
function formatVulnerabilityOutput(libraryVulnerabilityResponse, id, config, remediationGuidance) {
|
|
20
64
|
const vulnerableLibraries = (0, reportUtils_1.convertGenericToTypedLibraryVulns)(libraryVulnerabilityResponse);
|
|
65
|
+
const guidance = convertKeysToStandardFormat(config, remediationGuidance);
|
|
21
66
|
const numberOfVulnerableLibraries = vulnerableLibraries.length;
|
|
22
67
|
if (numberOfVulnerableLibraries === 0) {
|
|
23
68
|
console.log(i18n_1.default.__('scanNoVulnerabilitiesFound'));
|
|
@@ -29,8 +74,7 @@ function formatVulnerabilityOutput(libraryVulnerabilityResponse, id, config) {
|
|
|
29
74
|
else {
|
|
30
75
|
let numberOfCves = 0;
|
|
31
76
|
vulnerableLibraries.forEach(lib => (numberOfCves += lib.cveArray.length));
|
|
32
|
-
(0, commonReportingFunctions_1.
|
|
33
|
-
const hasSomeVulnerabilitiesReported = (0, commonReportingFunctions_1.printVulnerabilityResponse)(vulnerableLibraries, config);
|
|
77
|
+
const hasSomeVulnerabilitiesReported = (0, commonReportingFunctions_1.printVulnerabilityResponse)(config, vulnerableLibraries, numberOfVulnerableLibraries, numberOfCves, guidance);
|
|
34
78
|
return [
|
|
35
79
|
hasSomeVulnerabilitiesReported,
|
|
36
80
|
numberOfCves,
|
|
@@ -40,10 +84,13 @@ function formatVulnerabilityOutput(libraryVulnerabilityResponse, id, config) {
|
|
|
40
84
|
}
|
|
41
85
|
exports.formatVulnerabilityOutput = formatVulnerabilityOutput;
|
|
42
86
|
async function vulnerabilityReportV2(config, reportId) {
|
|
87
|
+
console.log();
|
|
43
88
|
const reportResponse = await (0, commonReportingFunctions_1.getReport)(config, reportId);
|
|
44
89
|
if (reportResponse !== undefined) {
|
|
45
90
|
const name = config.applicationName;
|
|
46
|
-
formatVulnerabilityOutput(reportResponse.vulnerabilities, config.applicationId, config
|
|
91
|
+
formatVulnerabilityOutput(reportResponse.vulnerabilities, config.applicationId, config, reportResponse.remediationGuidance
|
|
92
|
+
? reportResponse.remediationGuidance
|
|
93
|
+
: {});
|
|
47
94
|
}
|
|
48
95
|
}
|
|
49
96
|
exports.vulnerabilityReportV2 = vulnerabilityReportV2;
|
|
@@ -3,10 +3,10 @@ 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.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.findCVESeveritiesAndOrderByHighestPriority = exports.findHighestSeverityCVE = void 0;
|
|
7
7
|
const reportLibraryModel_1 = require("../models/reportLibraryModel");
|
|
8
8
|
const reportSeverityModel_1 = require("../models/reportSeverityModel");
|
|
9
|
-
const constants_1 = __importDefault(require("
|
|
9
|
+
const constants_1 = __importDefault(require("./../../../../constants/constants"));
|
|
10
10
|
const constants_2 = require("../../../../constants/constants");
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
const severityCountModel_1 = require("../models/severityCountModel");
|
|
@@ -86,11 +86,44 @@ function findNameAndVersion(library, config) {
|
|
|
86
86
|
return { name, version };
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
const
|
|
90
|
-
const nameVersion =
|
|
91
|
-
|
|
89
|
+
const uniqueSplitLibraryName = [...new Set(library.name.split('/'))];
|
|
90
|
+
const nameVersion = uniqueSplitLibraryName[1].split('@');
|
|
91
|
+
let parentLibrary;
|
|
92
|
+
let name;
|
|
93
|
+
if (uniqueSplitLibraryName[0] !== 'null' &&
|
|
94
|
+
uniqueSplitLibraryName[0] !== '' &&
|
|
95
|
+
!uniqueSplitLibraryName[1].includes(uniqueSplitLibraryName[0])) {
|
|
96
|
+
parentLibrary = uniqueSplitLibraryName[0];
|
|
97
|
+
name = `${parentLibrary}/${nameVersion[0]}`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
name = nameVersion[0];
|
|
101
|
+
}
|
|
92
102
|
const version = nameVersion[1];
|
|
93
103
|
return { name, version };
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
exports.findNameAndVersion = findNameAndVersion;
|
|
107
|
+
function countVulnerableLibrariesBySeverity(reportModelStructure) {
|
|
108
|
+
const severityCount = new severityCountModel_1.SeverityCountModel();
|
|
109
|
+
reportModelStructure.forEach(vuln => {
|
|
110
|
+
const currentSeverity = vuln.compositeKey.highestSeverity.severity;
|
|
111
|
+
if (currentSeverity === 'CRITICAL') {
|
|
112
|
+
severityCount.critical += 1;
|
|
113
|
+
}
|
|
114
|
+
else if (currentSeverity === 'HIGH') {
|
|
115
|
+
severityCount.high += 1;
|
|
116
|
+
}
|
|
117
|
+
else if (currentSeverity === 'MEDIUM') {
|
|
118
|
+
severityCount.medium += 1;
|
|
119
|
+
}
|
|
120
|
+
else if (currentSeverity === 'LOW') {
|
|
121
|
+
severityCount.low += 1;
|
|
122
|
+
}
|
|
123
|
+
else if (currentSeverity === 'NOTE') {
|
|
124
|
+
severityCount.note += 1;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return severityCount;
|
|
128
|
+
}
|
|
129
|
+
exports.countVulnerableLibrariesBySeverity = countVulnerableLibrariesBySeverity;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { handleResponseErrors } = require('../../common/errorHandling');
|
|
3
|
-
const { APP_VERSION } = require('../../constants/constants');
|
|
4
2
|
const commonApi = require('../../utils/commonApi');
|
|
5
3
|
const _ = require('lodash');
|
|
6
4
|
const oraFunctions = require('../../utils/oraWrapper');
|
|
@@ -8,28 +6,6 @@ const i18n = require('i18n');
|
|
|
8
6
|
const oraWrapper = require('../../utils/oraWrapper');
|
|
9
7
|
const requestUtils = require('../../utils/requestUtils');
|
|
10
8
|
const { performance } = require('perf_hooks');
|
|
11
|
-
const newSendSnapShot = async (analysis) => {
|
|
12
|
-
const analysisLanguage = analysis.config.language.toLowerCase();
|
|
13
|
-
const requestBody = {
|
|
14
|
-
appID: analysis.config.applicationId,
|
|
15
|
-
cliVersion: APP_VERSION,
|
|
16
|
-
snapshot: { [analysisLanguage]: analysis[analysisLanguage] }
|
|
17
|
-
};
|
|
18
|
-
const client = commonApi.getHttpClient(analysis.config);
|
|
19
|
-
return client
|
|
20
|
-
.sendSnapshot(requestBody, analysis.config)
|
|
21
|
-
.then(res => {
|
|
22
|
-
if (res.statusCode === 201) {
|
|
23
|
-
return res.body;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
handleResponseErrors(res, 'snapshot');
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
.catch(err => {
|
|
30
|
-
console.log(err);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
9
|
const pollSnapshotResults = async (config, snapshotId, client) => {
|
|
34
10
|
await requestUtils.sleep(5000);
|
|
35
11
|
return client
|
|
@@ -47,9 +23,9 @@ const getTimeout = config => {
|
|
|
47
23
|
}
|
|
48
24
|
else {
|
|
49
25
|
if (config.verbose) {
|
|
50
|
-
console.log('Timeout set to
|
|
26
|
+
console.log('Timeout set to 5 minutes');
|
|
51
27
|
}
|
|
52
|
-
return
|
|
28
|
+
return 300;
|
|
53
29
|
}
|
|
54
30
|
};
|
|
55
31
|
const pollForSnapshotCompletition = async (config, snapshotId, reportSpinner) => {
|
|
@@ -78,14 +54,14 @@ const pollForSnapshotCompletition = async (config, snapshotId, reportSpinner) =>
|
|
|
78
54
|
}
|
|
79
55
|
const endTime = performance.now() - startTime;
|
|
80
56
|
if (requestUtils.millisToSeconds(endTime) > timeout) {
|
|
81
|
-
oraFunctions.failSpinner(reportSpinner, 'Contrast audit timed out at the specified
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
oraFunctions.failSpinner(reportSpinner, 'Contrast audit timed out at the specified timeout of ' +
|
|
58
|
+
timeout +
|
|
59
|
+
' seconds.');
|
|
60
|
+
throw new Error('You can update the timeout using --timeout');
|
|
84
61
|
}
|
|
85
62
|
}
|
|
86
63
|
}
|
|
87
64
|
};
|
|
88
65
|
module.exports = {
|
|
89
|
-
newSendSnapShot: newSendSnapShot,
|
|
90
66
|
pollForSnapshotCompletition: pollForSnapshotCompletition
|
|
91
67
|
};
|
package/dist/audit/save.js
CHANGED
|
@@ -4,24 +4,32 @@ const i18n = require('i18n');
|
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const save = require('../commands/audit/saveFile');
|
|
6
6
|
const sbom = require('../sbom/generateSbom');
|
|
7
|
+
const { SBOM_CYCLONE_DX_FILE, SBOM_SPDX_FILE } = require('../constants/constants');
|
|
7
8
|
async function auditSave(config) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
let fileFormat;
|
|
10
|
+
switch (config.save) {
|
|
11
|
+
case null:
|
|
12
|
+
case SBOM_CYCLONE_DX_FILE:
|
|
13
|
+
fileFormat = SBOM_CYCLONE_DX_FILE;
|
|
14
|
+
break;
|
|
15
|
+
case SBOM_SPDX_FILE:
|
|
16
|
+
fileFormat = SBOM_SPDX_FILE;
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (fileFormat) {
|
|
22
|
+
save.saveFile(config, fileFormat, await sbom.generateSbom(config, fileFormat));
|
|
23
|
+
const filename = `${config.applicationId}-sbom-${fileFormat}.json`;
|
|
24
|
+
if (fs.existsSync(filename)) {
|
|
25
|
+
console.log(i18n.__('auditSBOMSaveSuccess') + ` - ${filename}`);
|
|
18
26
|
}
|
|
19
27
|
else {
|
|
20
|
-
console.log(
|
|
28
|
+
console.log(chalk.yellow.bold(`\n Unable to save ${filename} Software Bill of Materials (SBOM)`));
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
|
-
else
|
|
24
|
-
console.log(i18n.__('
|
|
31
|
+
else {
|
|
32
|
+
console.log(i18n.__('auditBadFiletypeSpecifiedForSave'));
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
module.exports = {
|
|
@@ -7,25 +7,9 @@ exports.getAuditConfig = void 0;
|
|
|
7
7
|
const paramHandler_1 = __importDefault(require("../../utils/paramsUtil/paramHandler"));
|
|
8
8
|
const constants_1 = __importDefault(require("../../constants"));
|
|
9
9
|
const parsedCLIOptions_1 = __importDefault(require("../../utils/parsedCLIOptions"));
|
|
10
|
-
const constants_2 = __importDefault(require("../../audit/languageAnalysisEngine/constants"));
|
|
11
|
-
const autoDetectLanguage_1 = require("../../audit/autodetection/autoDetectLanguage");
|
|
12
|
-
const { supportedLanguages: { NODE, JAVASCRIPT } } = constants_2.default;
|
|
13
10
|
const getAuditConfig = (argv) => {
|
|
14
11
|
const auditParameters = parsedCLIOptions_1.default.getCommandLineArgsCustom(argv, constants_1.default.commandLineDefinitions.auditOptionDefinitions);
|
|
15
12
|
const paramsAuth = paramHandler_1.default.getAuth(auditParameters);
|
|
16
|
-
if (auditParameters.language === undefined ||
|
|
17
|
-
auditParameters.language === null) {
|
|
18
|
-
try {
|
|
19
|
-
auditParameters.language = (0, autoDetectLanguage_1.determineProjectLanguage)((0, autoDetectLanguage_1.identifyLanguages)(auditParameters));
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
console.log(err.message);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else if (auditParameters.language.toUpperCase() === JAVASCRIPT) {
|
|
27
|
-
auditParameters.language = NODE.toLowerCase();
|
|
28
|
-
}
|
|
29
13
|
return { ...paramsAuth, ...auditParameters };
|
|
30
14
|
};
|
|
31
15
|
exports.getAuditConfig = getAuditConfig;
|
|
@@ -3,11 +3,9 @@ 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.getAppName = exports.
|
|
6
|
+
exports.getAppName = exports.dealWithNoAppId = void 0;
|
|
7
7
|
const catalogueApplication_1 = require("../../audit/catalogueApplication/catalogueApplication");
|
|
8
8
|
const commonApi_1 = __importDefault(require("../../audit/languageAnalysisEngine/commonApi"));
|
|
9
|
-
const identifyLanguageAE = require('./../../audit/languageAnalysisEngine');
|
|
10
|
-
const languageFactory = require('../../audit/languageAnalysisEngine/languageAnalysisFactory');
|
|
11
9
|
const dealWithNoAppId = async (config) => {
|
|
12
10
|
let appID;
|
|
13
11
|
try {
|
|
@@ -33,13 +31,6 @@ const dealWithNoAppId = async (config) => {
|
|
|
33
31
|
return appID;
|
|
34
32
|
};
|
|
35
33
|
exports.dealWithNoAppId = dealWithNoAppId;
|
|
36
|
-
const startAudit = async (config) => {
|
|
37
|
-
if (!config.applicationId) {
|
|
38
|
-
config.applicationId = await (0, exports.dealWithNoAppId)(config);
|
|
39
|
-
}
|
|
40
|
-
identifyLanguageAE(config.file, languageFactory, config.applicationId, config);
|
|
41
|
-
};
|
|
42
|
-
exports.startAudit = startAudit;
|
|
43
34
|
const getAppName = (file) => {
|
|
44
35
|
const last = file.charAt(file.length - 1);
|
|
45
36
|
if (last !== '/') {
|
|
@@ -18,30 +18,13 @@ const auditUsageGuide = (0, command_line_usage_1.default)([
|
|
|
18
18
|
'{bold ' +
|
|
19
19
|
i18n_1.default.__('constantsAuditPrerequisitesContentSupportedLanguages') +
|
|
20
20
|
'}',
|
|
21
|
-
'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'',
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'',
|
|
29
|
-
'{bold ' +
|
|
30
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentDotNet') +
|
|
31
|
-
'}' +
|
|
32
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentDotNetMessage'),
|
|
33
|
-
'{bold ' +
|
|
34
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentLanguageNode') +
|
|
35
|
-
'}' +
|
|
36
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentLanguageNodeMessage'),
|
|
37
|
-
'{bold ' +
|
|
38
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentLanguageRuby') +
|
|
39
|
-
'}' +
|
|
40
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentLanguageRubyMessage'),
|
|
41
|
-
'{bold ' +
|
|
42
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentLanguagePython') +
|
|
43
|
-
'}' +
|
|
44
|
-
i18n_1.default.__('constantsAuditPrerequisitesContentLanguagePythonMessage')
|
|
21
|
+
i18n_1.default.__('constantsAuditPrerequisitesJavaContentMessage'),
|
|
22
|
+
i18n_1.default.__('constantsAuditPrerequisitesContentDotNetMessage'),
|
|
23
|
+
i18n_1.default.__('constantsAuditPrerequisitesContentNodeMessage'),
|
|
24
|
+
i18n_1.default.__('constantsAuditPrerequisitesContentRubyMessage'),
|
|
25
|
+
i18n_1.default.__('constantsAuditPrerequisitesContentPythonMessage'),
|
|
26
|
+
i18n_1.default.__('constantsAuditPrerequisitesContentGoMessage'),
|
|
27
|
+
i18n_1.default.__('constantsAuditPrerequisitesContentPHPMessage')
|
|
45
28
|
]
|
|
46
29
|
},
|
|
47
30
|
{
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processAudit = void 0;
|
|
4
|
-
const auditController_1 = require("./auditController");
|
|
5
4
|
const auditConfig_1 = require("./auditConfig");
|
|
6
5
|
const help_1 = require("./help");
|
|
7
6
|
const scaAnalysis_1 = require("../scan/sca/scaAnalysis");
|
|
@@ -11,12 +10,7 @@ const processAudit = async (argv) => {
|
|
|
11
10
|
process.exit(0);
|
|
12
11
|
}
|
|
13
12
|
const config = (0, auditConfig_1.getAuditConfig)(argv);
|
|
14
|
-
|
|
15
|
-
await (0, scaAnalysis_1.processSca)(config);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
await (0, auditController_1.startAudit)(config);
|
|
19
|
-
}
|
|
13
|
+
await (0, scaAnalysis_1.processSca)(config);
|
|
20
14
|
};
|
|
21
15
|
exports.processAudit = processAudit;
|
|
22
16
|
const printHelpMessage = () => {
|