@contrast/contrast 1.0.6 → 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/.prettierignore +0 -6
- package/dist/audit/catalogueApplication/catalogueApplication.js +23 -5
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +10 -19
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +98 -37
- package/dist/audit/languageAnalysisEngine/report/models/reportListModel.js +2 -1
- package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +4 -3
- package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +3 -0
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +87 -19
- package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +46 -16
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +57 -19
- package/dist/audit/save.js +37 -0
- package/dist/commands/audit/auditConfig.js +0 -16
- package/dist/commands/audit/auditController.js +18 -11
- package/dist/commands/audit/help.js +31 -25
- package/dist/commands/audit/processAudit.js +3 -3
- package/dist/commands/audit/saveFile.js +8 -4
- package/dist/commands/scan/sca/scaAnalysis.js +55 -10
- package/dist/common/HTTPClient.js +64 -23
- package/dist/common/errorHandling.js +6 -1
- package/dist/common/versionChecker.js +20 -5
- package/dist/constants/constants.js +7 -2
- package/dist/constants/locales.js +35 -38
- package/dist/constants.js +20 -13
- package/dist/index.js +55 -45
- package/dist/lambda/analytics.js +11 -0
- package/dist/lambda/lambda.js +38 -4
- package/dist/lambda/types.js +13 -0
- package/dist/sbom/generateSbom.js +5 -4
- package/dist/scaAnalysis/common/formatMessage.js +44 -1
- package/dist/scaAnalysis/common/treeUpload.js +4 -6
- package/dist/scaAnalysis/dotnet/analysis.js +43 -0
- package/dist/scaAnalysis/dotnet/index.js +10 -0
- package/dist/scaAnalysis/go/goReadDepFile.js +1 -3
- package/dist/scaAnalysis/java/analysis.js +5 -8
- package/dist/scaAnalysis/java/index.js +2 -2
- package/dist/scaAnalysis/javascript/analysis.js +107 -0
- package/dist/scaAnalysis/javascript/index.js +50 -0
- package/dist/scaAnalysis/php/analysis.js +70 -0
- package/dist/scaAnalysis/php/index.js +17 -0
- package/dist/scaAnalysis/python/analysis.js +42 -0
- package/dist/scaAnalysis/python/index.js +10 -0
- package/dist/scaAnalysis/ruby/analysis.js +218 -0
- package/dist/scaAnalysis/ruby/index.js +10 -0
- package/dist/scan/autoDetection.js +23 -22
- package/dist/scan/fileUtils.js +57 -20
- package/dist/scan/formatScanOutput.js +12 -14
- package/dist/scan/models/groupedResultsModel.js +1 -1
- package/dist/scan/models/scanResultsModel.js +3 -1
- package/dist/scan/populateProjectIdAndProjectName.js +2 -1
- package/dist/scan/scan.js +1 -0
- package/dist/scan/scanConfig.js +8 -3
- package/dist/scan/scanController.js +16 -3
- package/dist/scan/scanResults.js +5 -1
- package/dist/utils/commonApi.js +4 -1
- package/dist/utils/filterProjectPath.js +7 -2
- package/dist/utils/getConfig.js +1 -6
- package/package.json +12 -9
- package/src/audit/catalogueApplication/catalogueApplication.js +28 -7
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +10 -39
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +183 -68
- package/src/audit/languageAnalysisEngine/report/models/reportLibraryModel.ts +3 -3
- package/src/audit/languageAnalysisEngine/report/models/reportListModel.ts +18 -11
- package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +11 -5
- package/src/audit/languageAnalysisEngine/report/models/reportSeverityModel.ts +6 -1
- package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +4 -0
- package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +86 -32
- package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +87 -32
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +69 -20
- package/src/audit/save.js +48 -0
- package/src/commands/audit/auditConfig.ts +0 -25
- package/src/commands/audit/auditController.ts +18 -20
- package/src/commands/audit/help.ts +31 -25
- package/src/commands/audit/processAudit.ts +3 -6
- package/src/commands/audit/saveFile.ts +6 -2
- package/src/commands/scan/processScan.js +0 -1
- package/src/commands/scan/sca/scaAnalysis.js +84 -30
- package/src/common/HTTPClient.js +81 -34
- package/src/common/errorHandling.ts +10 -1
- package/src/common/versionChecker.ts +24 -5
- package/src/constants/constants.js +9 -3
- package/src/constants/locales.js +58 -43
- package/src/constants.js +21 -14
- package/src/index.ts +70 -58
- package/src/lambda/analytics.ts +9 -0
- package/src/lambda/arn.ts +2 -1
- package/src/lambda/lambda.ts +40 -17
- package/src/lambda/types.ts +36 -0
- package/src/lambda/utils.ts +2 -7
- package/src/sbom/generateSbom.ts +2 -2
- package/src/scaAnalysis/common/formatMessage.js +48 -1
- package/src/scaAnalysis/common/treeUpload.js +4 -6
- package/src/scaAnalysis/dotnet/analysis.js +54 -0
- package/src/scaAnalysis/dotnet/index.js +11 -0
- package/src/scaAnalysis/go/goAnalysis.js +2 -3
- package/src/scaAnalysis/go/goReadDepFile.js +1 -3
- package/src/scaAnalysis/java/analysis.js +7 -8
- package/src/scaAnalysis/java/index.js +2 -2
- package/src/scaAnalysis/javascript/analysis.js +126 -0
- package/src/scaAnalysis/javascript/index.js +72 -0
- package/src/scaAnalysis/php/analysis.js +78 -0
- package/src/scaAnalysis/php/index.js +22 -0
- package/src/scaAnalysis/python/analysis.js +49 -0
- package/src/scaAnalysis/python/index.js +11 -0
- package/src/scaAnalysis/ruby/analysis.js +273 -0
- package/src/scaAnalysis/ruby/index.js +11 -0
- package/src/scan/autoDetection.js +24 -26
- package/src/scan/fileUtils.js +60 -20
- package/src/scan/formatScanOutput.ts +14 -15
- package/src/scan/models/groupedResultsModel.ts +3 -3
- package/src/scan/models/resultContentModel.ts +1 -1
- package/src/scan/models/scanResultsModel.ts +5 -2
- package/src/scan/populateProjectIdAndProjectName.js +3 -1
- package/src/scan/scan.ts +1 -0
- package/src/scan/scanConfig.js +7 -5
- package/src/scan/scanController.js +18 -4
- package/src/scan/scanResults.js +10 -0
- package/src/utils/commonApi.js +4 -1
- package/src/utils/filterProjectPath.js +6 -2
- 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 -153
- 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 -24
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -24
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -35
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -23
- 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 -87
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -150
- 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 -222
- 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 -35
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -41
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -54
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -32
- 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 -116
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -249
- 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
|
@@ -1,29 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
const client = getHttpClient(analysis.config);
|
|
2
|
+
const commonApi = require('../../utils/commonApi');
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const oraFunctions = require('../../utils/oraWrapper');
|
|
5
|
+
const i18n = require('i18n');
|
|
6
|
+
const oraWrapper = require('../../utils/oraWrapper');
|
|
7
|
+
const requestUtils = require('../../utils/requestUtils');
|
|
8
|
+
const { performance } = require('perf_hooks');
|
|
9
|
+
const pollSnapshotResults = async (config, snapshotId, client) => {
|
|
10
|
+
await requestUtils.sleep(5000);
|
|
13
11
|
return client
|
|
14
|
-
.
|
|
12
|
+
.getReportStatusById(config, snapshotId)
|
|
15
13
|
.then(res => {
|
|
16
|
-
|
|
17
|
-
return res.body;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
handleResponseErrors(res, 'snapshot');
|
|
21
|
-
}
|
|
14
|
+
return res;
|
|
22
15
|
})
|
|
23
16
|
.catch(err => {
|
|
24
17
|
console.log(err);
|
|
25
18
|
});
|
|
26
19
|
};
|
|
20
|
+
const getTimeout = config => {
|
|
21
|
+
if (config.timeout) {
|
|
22
|
+
return config.timeout;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (config.verbose) {
|
|
26
|
+
console.log('Timeout set to 5 minutes');
|
|
27
|
+
}
|
|
28
|
+
return 300;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const pollForSnapshotCompletition = async (config, snapshotId, reportSpinner) => {
|
|
32
|
+
const client = commonApi.getHttpClient(config);
|
|
33
|
+
const startTime = performance.now();
|
|
34
|
+
const timeout = getTimeout(config);
|
|
35
|
+
let complete = false;
|
|
36
|
+
if (!_.isNil(snapshotId)) {
|
|
37
|
+
while (!complete) {
|
|
38
|
+
let result = await pollSnapshotResults(config, snapshotId, client);
|
|
39
|
+
if (result.statusCode === 200) {
|
|
40
|
+
if (result.body.status === 'PROCESSED') {
|
|
41
|
+
complete = true;
|
|
42
|
+
return result.body;
|
|
43
|
+
}
|
|
44
|
+
if (result.body.status === 'FAILED') {
|
|
45
|
+
complete = true;
|
|
46
|
+
if (config.debug) {
|
|
47
|
+
oraFunctions.failSpinner(reportSpinner, i18n.__('auditNotCompleted'));
|
|
48
|
+
}
|
|
49
|
+
console.log(result.body.errorMessage);
|
|
50
|
+
oraWrapper.stopSpinner(reportSpinner);
|
|
51
|
+
console.log('Contrast audit finished');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const endTime = performance.now() - startTime;
|
|
56
|
+
if (requestUtils.millisToSeconds(endTime) > timeout) {
|
|
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');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
27
65
|
module.exports = {
|
|
28
|
-
|
|
66
|
+
pollForSnapshotCompletition: pollForSnapshotCompletition
|
|
29
67
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const i18n = require('i18n');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const save = require('../commands/audit/saveFile');
|
|
6
|
+
const sbom = require('../sbom/generateSbom');
|
|
7
|
+
const { SBOM_CYCLONE_DX_FILE, SBOM_SPDX_FILE } = require('../constants/constants');
|
|
8
|
+
async function auditSave(config) {
|
|
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}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.log(chalk.yellow.bold(`\n Unable to save ${filename} Software Bill of Materials (SBOM)`));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log(i18n.__('auditBadFiletypeSpecifiedForSave'));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
module.exports = {
|
|
36
|
+
auditSave
|
|
37
|
+
};
|
|
@@ -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,12 +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.
|
|
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
|
-
const { v4: uuidv4 } = require('uuid');
|
|
12
9
|
const dealWithNoAppId = async (config) => {
|
|
13
10
|
let appID;
|
|
14
11
|
try {
|
|
@@ -17,8 +14,11 @@ const dealWithNoAppId = async (config) => {
|
|
|
17
14
|
return await (0, catalogueApplication_1.catalogueApplication)(config);
|
|
18
15
|
}
|
|
19
16
|
if (!appID && !config.applicationName) {
|
|
20
|
-
config.applicationName =
|
|
21
|
-
|
|
17
|
+
config.applicationName = (0, exports.getAppName)(config.file);
|
|
18
|
+
appID = await commonApi_1.default.returnAppId(config);
|
|
19
|
+
if (!appID) {
|
|
20
|
+
return await (0, catalogueApplication_1.catalogueApplication)(config);
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
catch (e) {
|
|
@@ -31,10 +31,17 @@ const dealWithNoAppId = async (config) => {
|
|
|
31
31
|
return appID;
|
|
32
32
|
};
|
|
33
33
|
exports.dealWithNoAppId = dealWithNoAppId;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const getAppName = (file) => {
|
|
35
|
+
const last = file.charAt(file.length - 1);
|
|
36
|
+
if (last !== '/') {
|
|
37
|
+
return file.split('/').pop();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const str = removeLastChar(file);
|
|
41
|
+
return str.split('/').pop();
|
|
37
42
|
}
|
|
38
|
-
identifyLanguageAE(config.projectPath, languageFactory, config.applicationId, config);
|
|
39
43
|
};
|
|
40
|
-
exports.
|
|
44
|
+
exports.getAppName = getAppName;
|
|
45
|
+
const removeLastChar = (str) => {
|
|
46
|
+
return str.substring(0, str.length - 1);
|
|
47
|
+
};
|
|
@@ -18,35 +18,41 @@ 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
|
{
|
|
48
31
|
header: i18n_1.default.__('constantsAuditOptions'),
|
|
49
|
-
optionList: constants_1.default.commandLineDefinitions.auditOptionDefinitions
|
|
32
|
+
optionList: constants_1.default.commandLineDefinitions.auditOptionDefinitions,
|
|
33
|
+
hide: [
|
|
34
|
+
'application-id',
|
|
35
|
+
'application-name',
|
|
36
|
+
'organization-id',
|
|
37
|
+
'api-key',
|
|
38
|
+
'authorization',
|
|
39
|
+
'host',
|
|
40
|
+
'proxy',
|
|
41
|
+
'help',
|
|
42
|
+
'ff',
|
|
43
|
+
'ignore-cert-errors',
|
|
44
|
+
'verbose',
|
|
45
|
+
'debug',
|
|
46
|
+
'experimental',
|
|
47
|
+
'tags',
|
|
48
|
+
'sub-project',
|
|
49
|
+
'code',
|
|
50
|
+
'maven-settings-path',
|
|
51
|
+
'language',
|
|
52
|
+
'experimental',
|
|
53
|
+
'app-groups',
|
|
54
|
+
'metadata'
|
|
55
|
+
]
|
|
50
56
|
}
|
|
51
57
|
]);
|
|
52
58
|
exports.auditUsageGuide = auditUsageGuide;
|
|
@@ -1,16 +1,16 @@
|
|
|
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");
|
|
6
|
+
const scaAnalysis_1 = require("../scan/sca/scaAnalysis");
|
|
7
7
|
const processAudit = async (argv) => {
|
|
8
8
|
if (argv.indexOf('--help') != -1) {
|
|
9
9
|
printHelpMessage();
|
|
10
|
-
process.exit(
|
|
10
|
+
process.exit(0);
|
|
11
11
|
}
|
|
12
12
|
const config = (0, auditConfig_1.getAuditConfig)(argv);
|
|
13
|
-
|
|
13
|
+
await (0, scaAnalysis_1.processSca)(config);
|
|
14
14
|
};
|
|
15
15
|
exports.processAudit = processAudit;
|
|
16
16
|
const printHelpMessage = () => {
|
|
@@ -3,9 +3,13 @@ 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.saveFile = void 0;
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
|
|
8
|
-
const fileName = `${config.applicationId}-sbom
|
|
8
|
+
const saveFile = (config, type, rawResults) => {
|
|
9
|
+
const fileName = `${config.applicationId}-sbom-${type}.json`;
|
|
9
10
|
fs_1.default.writeFileSync(fileName, JSON.stringify(rawResults));
|
|
10
|
-
}
|
|
11
|
-
exports.
|
|
11
|
+
};
|
|
12
|
+
exports.saveFile = saveFile;
|
|
13
|
+
module.exports = {
|
|
14
|
+
saveFile: exports.saveFile
|
|
15
|
+
};
|
|
@@ -2,17 +2,29 @@
|
|
|
2
2
|
const autoDetection = require('../../../scan/autoDetection');
|
|
3
3
|
const javaAnalysis = require('../../../scaAnalysis/java');
|
|
4
4
|
const treeUpload = require('../../../scaAnalysis/common/treeUpload');
|
|
5
|
-
const { manualDetectAuditFilesAndLanguages } = require('../../../scan/autoDetection');
|
|
6
5
|
const auditController = require('../../audit/auditController');
|
|
7
|
-
const { supportedLanguages: { JAVA, GO } } = require('../../../
|
|
6
|
+
const { supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, NODE, PHP, DOTNET } } = require('../../../constants/constants');
|
|
8
7
|
const goAnalysis = require('../../../scaAnalysis/go/goAnalysis');
|
|
8
|
+
const phpAnalysis = require('../../../scaAnalysis/php/index');
|
|
9
|
+
const { rubyAnalysis } = require('../../../scaAnalysis/ruby');
|
|
10
|
+
const { pythonAnalysis } = require('../../../scaAnalysis/python');
|
|
11
|
+
const javascriptAnalysis = require('../../../scaAnalysis/javascript');
|
|
12
|
+
const { pollForSnapshotCompletition } = require('../../../audit/languageAnalysisEngine/sendSnapshot');
|
|
13
|
+
const { returnOra, startSpinner, succeedSpinner } = require('../../../utils/oraWrapper');
|
|
14
|
+
const i18n = require('i18n');
|
|
15
|
+
const { vulnerabilityReportV2 } = require('../../../audit/languageAnalysisEngine/report/reportingFeature');
|
|
16
|
+
const auditSave = require('../../../audit/save');
|
|
17
|
+
const { dotNetAnalysis } = require('../../../scaAnalysis/dotnet');
|
|
9
18
|
const processSca = async (config) => {
|
|
19
|
+
const startTime = performance.now();
|
|
10
20
|
let filesFound;
|
|
11
|
-
if (config.
|
|
12
|
-
|
|
21
|
+
if (config.file) {
|
|
22
|
+
config.file = config.file.concat('/');
|
|
23
|
+
filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(config.file);
|
|
13
24
|
}
|
|
14
25
|
else {
|
|
15
|
-
filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(
|
|
26
|
+
filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(undefined);
|
|
27
|
+
config.file = process.cwd().concat('/');
|
|
16
28
|
}
|
|
17
29
|
let messageToSend = undefined;
|
|
18
30
|
if (filesFound.length === 1) {
|
|
@@ -21,26 +33,59 @@ const processSca = async (config) => {
|
|
|
21
33
|
messageToSend = javaAnalysis.javaAnalysis(config, filesFound[0]);
|
|
22
34
|
config.language = JAVA;
|
|
23
35
|
break;
|
|
36
|
+
case JAVASCRIPT:
|
|
37
|
+
messageToSend = await javascriptAnalysis.jsAnalysis(config, filesFound[0]);
|
|
38
|
+
config.language = NODE;
|
|
39
|
+
break;
|
|
40
|
+
case PYTHON:
|
|
41
|
+
messageToSend = pythonAnalysis(config, filesFound[0]);
|
|
42
|
+
config.language = PYTHON;
|
|
43
|
+
break;
|
|
44
|
+
case RUBY:
|
|
45
|
+
messageToSend = rubyAnalysis(config, filesFound[0]);
|
|
46
|
+
config.language = RUBY;
|
|
47
|
+
break;
|
|
48
|
+
case 'PHP':
|
|
49
|
+
messageToSend = phpAnalysis.phpAnalysis(config, filesFound[0]);
|
|
50
|
+
config.language = PHP;
|
|
51
|
+
break;
|
|
24
52
|
case GO:
|
|
25
53
|
messageToSend = goAnalysis.goAnalysis(config, filesFound[0]);
|
|
26
54
|
config.language = GO;
|
|
27
55
|
break;
|
|
56
|
+
case DOTNET:
|
|
57
|
+
messageToSend = dotNetAnalysis(config, filesFound[0]);
|
|
58
|
+
config.language = DOTNET;
|
|
59
|
+
break;
|
|
28
60
|
default:
|
|
29
|
-
console.log('language detected
|
|
61
|
+
console.log('No supported language detected in project path');
|
|
30
62
|
return;
|
|
31
63
|
}
|
|
32
64
|
if (!config.applicationId) {
|
|
33
65
|
config.applicationId = await auditController.dealWithNoAppId(config);
|
|
34
66
|
}
|
|
35
|
-
console.log('
|
|
36
|
-
const
|
|
67
|
+
console.log('');
|
|
68
|
+
const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'));
|
|
69
|
+
startSpinner(reportSpinner);
|
|
70
|
+
const snapshotResponse = await treeUpload.commonSendSnapShot(messageToSend, config);
|
|
71
|
+
await pollForSnapshotCompletition(config, snapshotResponse.id, reportSpinner);
|
|
72
|
+
succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
|
|
73
|
+
await vulnerabilityReportV2(config, snapshotResponse.id);
|
|
74
|
+
if (config.save !== undefined) {
|
|
75
|
+
await auditSave.auditSave(config);
|
|
76
|
+
}
|
|
77
|
+
const endTime = performance.now() - startTime;
|
|
78
|
+
const scanDurationMs = endTime - startTime;
|
|
79
|
+
console.log(`----- completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`);
|
|
37
80
|
}
|
|
38
81
|
else {
|
|
39
82
|
if (filesFound.length === 0) {
|
|
40
|
-
console.log(
|
|
83
|
+
console.log(i18n.__('languageAnalysisNoLanguage'));
|
|
84
|
+
console.log(i18n.__('languageAnalysisNoLanguageHelpLine'));
|
|
85
|
+
throw new Error();
|
|
41
86
|
}
|
|
42
87
|
else {
|
|
43
|
-
|
|
88
|
+
throw new Error('multiple language files detected, please use --file to specify a directory or the file where dependencies are declared');
|
|
44
89
|
}
|
|
45
90
|
}
|
|
46
91
|
};
|
|
@@ -20,7 +20,8 @@ function HTTPClient(config) {
|
|
|
20
20
|
Authorization: authToken,
|
|
21
21
|
'API-Key': apiKey,
|
|
22
22
|
SuperAuthorization: superAuthToken,
|
|
23
|
-
'Super-API-Key': superApiKey
|
|
23
|
+
'Super-API-Key': superApiKey,
|
|
24
|
+
'User-Agent': 'contrast-cli-v2'
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
27
|
if (config.proxy) {
|
|
@@ -66,10 +67,24 @@ HTTPClient.prototype.getSpecificScanResult = function getSpecificScanResult(conf
|
|
|
66
67
|
options.url = url;
|
|
67
68
|
return requestUtils.sendRequest({ method: 'get', options });
|
|
68
69
|
};
|
|
69
|
-
HTTPClient.prototype.getSpecificScanResultSarif =
|
|
70
|
+
HTTPClient.prototype.getSpecificScanResultSarif =
|
|
71
|
+
function getSpecificScanResultSarif(config, scanId) {
|
|
72
|
+
const options = _.cloneDeep(this.requestOptions);
|
|
73
|
+
options.url = createRawOutputURL(config, scanId);
|
|
74
|
+
return requestUtils.sendRequest({ method: 'get', options });
|
|
75
|
+
};
|
|
76
|
+
HTTPClient.prototype.createNewEvent = function createNewEvent(config, scanId, newProject) {
|
|
70
77
|
const options = _.cloneDeep(this.requestOptions);
|
|
71
|
-
options.url =
|
|
72
|
-
|
|
78
|
+
options.url = createEventCollectorURL(config, scanId);
|
|
79
|
+
options.body = {
|
|
80
|
+
eventSource: process.env.CODESEC_INVOCATION_ENVIRONMENT,
|
|
81
|
+
trackingProperties: {
|
|
82
|
+
projectNameSource: config.projectNameSource,
|
|
83
|
+
waitedForResults: !config.ff,
|
|
84
|
+
newProject
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return requestUtils.sendRequest({ method: 'post', options });
|
|
73
88
|
};
|
|
74
89
|
HTTPClient.prototype.getScanId = function getScanId(config, codeArtifactId) {
|
|
75
90
|
const options = _.cloneDeep(this.requestOptions);
|
|
@@ -145,8 +160,6 @@ HTTPClient.prototype.catalogueCommand = function catalogueCommand(config) {
|
|
|
145
160
|
return requestUtils.sendRequest({ method: 'post', options });
|
|
146
161
|
};
|
|
147
162
|
HTTPClient.prototype.sendSnapshot = function sendSnapshot(requestBody, config) {
|
|
148
|
-
if (config.language.toUpperCase() === 'RUBY') {
|
|
149
|
-
}
|
|
150
163
|
const options = _.cloneDeep(this.requestOptions);
|
|
151
164
|
let url = createSnapshotURL(config);
|
|
152
165
|
options.url = url;
|
|
@@ -163,12 +176,18 @@ HTTPClient.prototype.getReportById = function getReportById(config, reportId) {
|
|
|
163
176
|
}
|
|
164
177
|
return requestUtils.sendRequest({ method: 'get', options });
|
|
165
178
|
};
|
|
166
|
-
HTTPClient.prototype.
|
|
179
|
+
HTTPClient.prototype.getReportStatusById = function getReportStatusById(config, snapshotId) {
|
|
167
180
|
const options = _.cloneDeep(this.requestOptions);
|
|
168
|
-
options.url =
|
|
169
|
-
|
|
170
|
-
return requestUtils.sendRequest({ method: 'put', options });
|
|
181
|
+
options.url = createSpecificReportStatusURL(config, snapshotId);
|
|
182
|
+
return requestUtils.sendRequest({ method: 'get', options });
|
|
171
183
|
};
|
|
184
|
+
HTTPClient.prototype.getLibraryVulnerabilities =
|
|
185
|
+
function getLibraryVulnerabilities(config, requestBody) {
|
|
186
|
+
const options = _.cloneDeep(this.requestOptions);
|
|
187
|
+
options.url = createLibraryVulnerabilitiesUrl(config);
|
|
188
|
+
options.body = requestBody;
|
|
189
|
+
return requestUtils.sendRequest({ method: 'put', options });
|
|
190
|
+
};
|
|
172
191
|
HTTPClient.prototype.getAppId = function getAppId(config) {
|
|
173
192
|
const options = _.cloneDeep(this.requestOptions);
|
|
174
193
|
let url = createAppNameUrl(config);
|
|
@@ -210,11 +229,12 @@ HTTPClient.prototype.getScanResources = async function getScanResources(config,
|
|
|
210
229
|
const options = { ...this.requestOptions, url };
|
|
211
230
|
return requestUtils.sendRequest({ method: 'get', options });
|
|
212
231
|
};
|
|
213
|
-
HTTPClient.prototype.getFunctionScanResults =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
};
|
|
232
|
+
HTTPClient.prototype.getFunctionScanResults =
|
|
233
|
+
async function getFunctionScanResults(config, params, scanId, functionArn) {
|
|
234
|
+
const url = createScanResultsGetUrl(config, params, scanId, functionArn);
|
|
235
|
+
const options = { ...this.requestOptions, url };
|
|
236
|
+
return requestUtils.sendRequest({ method: 'get', options });
|
|
237
|
+
};
|
|
218
238
|
HTTPClient.prototype.checkLibrary = function checkLibrary(data) {
|
|
219
239
|
const options = _.cloneDeep(this.requestOptions);
|
|
220
240
|
let url = createDataUrl();
|
|
@@ -222,11 +242,26 @@ HTTPClient.prototype.checkLibrary = function checkLibrary(data) {
|
|
|
222
242
|
options.body = data;
|
|
223
243
|
return requestUtils.sendRequest({ method: 'post', options });
|
|
224
244
|
};
|
|
225
|
-
HTTPClient.prototype.getSbom = function getSbom(config) {
|
|
245
|
+
HTTPClient.prototype.getSbom = function getSbom(config, type) {
|
|
246
|
+
const options = _.cloneDeep(this.requestOptions);
|
|
247
|
+
options.url = createSbomUrl(config, type);
|
|
248
|
+
return requestUtils.sendRequest({ method: 'get', options });
|
|
249
|
+
};
|
|
250
|
+
HTTPClient.prototype.getLatestVersion = function getLatestVersion() {
|
|
226
251
|
const options = _.cloneDeep(this.requestOptions);
|
|
227
|
-
options.url =
|
|
252
|
+
options.url =
|
|
253
|
+
'https://pkg.contrastsecurity.com/artifactory/cli/latest-version.txt';
|
|
228
254
|
return requestUtils.sendRequest({ method: 'get', options });
|
|
229
255
|
};
|
|
256
|
+
HTTPClient.prototype.postAnalyticsFunction = function (config, provider, body) {
|
|
257
|
+
const url = createAnalyticsFunctionPostUrl(config, provider);
|
|
258
|
+
const options = { ...this.requestOptions, body, url };
|
|
259
|
+
return requestUtils.sendRequest({ method: 'post', options });
|
|
260
|
+
};
|
|
261
|
+
const createAnalyticsFunctionPostUrl = (config, provider) => {
|
|
262
|
+
const url = getServerlessHost(config);
|
|
263
|
+
return `${url}/organizations/${config.organizationId}/providers/${provider}/analytics`;
|
|
264
|
+
};
|
|
230
265
|
const createGetScanIdURL = config => {
|
|
231
266
|
return `${config.host}/Contrast/api/sast/v1/organizations/${config.organizationId}/projects/${config.projectId}/scans/`;
|
|
232
267
|
};
|
|
@@ -248,6 +283,9 @@ function createHarmonyProjectsUrl(config) {
|
|
|
248
283
|
function createScanProjectUrl(config) {
|
|
249
284
|
return `${config.host}/Contrast/api/sast/v1/organizations/${config.organizationId}/projects/${config.projectId}`;
|
|
250
285
|
}
|
|
286
|
+
const createEventCollectorURL = (config, scanId) => {
|
|
287
|
+
return `${config.host}/Contrast/api/sast/organizations/${config.organizationId}/projects/${config.projectId}/scans/${scanId}/events`;
|
|
288
|
+
};
|
|
251
289
|
const createGlobalPropertiesUrl = protocol => {
|
|
252
290
|
return `${protocol}/Contrast/api/ng/global/properties`;
|
|
253
291
|
};
|
|
@@ -266,17 +304,20 @@ const createAppNameUrl = config => {
|
|
|
266
304
|
function createLibraryVulnerabilitiesUrl(config) {
|
|
267
305
|
return `${config.host}/Contrast/api/ng/${config.organizationId}/libraries/artifactsByGroupNameVersion`;
|
|
268
306
|
}
|
|
269
|
-
function createSpecificReportUrl(config, reportId) {
|
|
270
|
-
return `${config.host}/Contrast/api/ng/sca/organizations/${config.organizationId}/applications/${config.applicationId}/reports/${reportId}`;
|
|
307
|
+
function createSpecificReportUrl(config, reportId, includeTree = false) {
|
|
308
|
+
return `${config.host}/Contrast/api/ng/sca/organizations/${config.organizationId}/applications/${config.applicationId}/reports/${reportId}?&includeTree=${includeTree}`;
|
|
309
|
+
}
|
|
310
|
+
function createSpecificReportWithProdUrl(config, reportId, includeTree) {
|
|
311
|
+
return createSpecificReportUrl(config, reportId, includeTree).concat(`&nodesToInclude=PROD`);
|
|
271
312
|
}
|
|
272
|
-
function
|
|
273
|
-
return
|
|
313
|
+
function createSpecificReportStatusURL(config, reportId) {
|
|
314
|
+
return `${config.host}/Contrast/api/ng/sca/organizations/${config.organizationId}/applications/${config.applicationId}/snapshots/${reportId}/status`;
|
|
274
315
|
}
|
|
275
316
|
function createDataUrl() {
|
|
276
317
|
return `https://ardy.contrastsecurity.com/production`;
|
|
277
318
|
}
|
|
278
|
-
function
|
|
279
|
-
return `${config.host}/Contrast/api/ng/${config.organizationId}/applications/${config.applicationId}/libraries/sbom
|
|
319
|
+
function createSbomUrl(config, type) {
|
|
320
|
+
return `${config.host}/Contrast/api/ng/${config.organizationId}/applications/${config.applicationId}/libraries/sbom/${type}`;
|
|
280
321
|
}
|
|
281
322
|
module.exports = HTTPClient;
|
|
282
323
|
module.exports.pollForAuthUrl = pollForAuthUrl;
|
|
@@ -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.reportFailureError = exports.vulnerabilitiesFailureError = exports.snapshotFailureError = exports.findCommandOnError = exports.libraryAnalysisError = exports.handleResponseErrors = exports.getErrorMessage = exports.generalError = exports.failOptionError = exports.proxyError = exports.forbiddenError = exports.badRequestError = exports.unauthenticatedError = exports.genericError = void 0;
|
|
6
|
+
exports.maxAppError = exports.reportFailureError = exports.vulnerabilitiesFailureError = exports.snapshotFailureError = exports.findCommandOnError = exports.libraryAnalysisError = exports.handleResponseErrors = exports.getErrorMessage = exports.generalError = exports.failOptionError = exports.proxyError = exports.forbiddenError = exports.badRequestError = exports.unauthenticatedError = exports.genericError = void 0;
|
|
7
7
|
const i18n_1 = __importDefault(require("i18n"));
|
|
8
8
|
const handleResponseErrors = (res, api) => {
|
|
9
9
|
if (res.statusCode === 400) {
|
|
@@ -72,6 +72,11 @@ const proxyError = () => {
|
|
|
72
72
|
generalError('proxyErrorHeader', 'proxyErrorMessage');
|
|
73
73
|
};
|
|
74
74
|
exports.proxyError = proxyError;
|
|
75
|
+
const maxAppError = () => {
|
|
76
|
+
generalError('No applications remaining', 'You have reached the maximum number of application you can create.');
|
|
77
|
+
process.exit(1);
|
|
78
|
+
};
|
|
79
|
+
exports.maxAppError = maxAppError;
|
|
75
80
|
const failOptionError = () => {
|
|
76
81
|
console.log('\n ******************************** ' +
|
|
77
82
|
i18n_1.default.__('snapshotFailureHeader') +
|
|
@@ -4,14 +4,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isCorrectNodeVersion = exports.findLatestCLIVersion = void 0;
|
|
7
|
-
const latest_version_1 = __importDefault(require("latest-version"));
|
|
8
7
|
const constants_1 = require("../constants/constants");
|
|
9
8
|
const boxen_1 = __importDefault(require("boxen"));
|
|
10
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
10
|
const semver_1 = __importDefault(require("semver"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const commonApi_1 = __importDefault(require("../utils/commonApi"));
|
|
12
|
+
const http2_1 = require("http2");
|
|
13
|
+
const getLatestVersion = async (config) => {
|
|
14
|
+
const client = commonApi_1.default.getHttpClient(config);
|
|
15
|
+
try {
|
|
16
|
+
const res = await client.getLatestVersion();
|
|
17
|
+
if (res.statusCode === http2_1.constants.HTTP_STATUS_OK) {
|
|
18
|
+
return res.body;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
async function findLatestCLIVersion(config) {
|
|
26
|
+
const messageHidden = config.get('updateMessageHidden');
|
|
27
|
+
if (!messageHidden) {
|
|
28
|
+
let latestCLIVersion = await getLatestVersion(config);
|
|
29
|
+
latestCLIVersion = latestCLIVersion.substring(8);
|
|
15
30
|
if (semver_1.default.lt(constants_1.APP_VERSION, latestCLIVersion)) {
|
|
16
31
|
const updateAvailableMessage = `Update available ${chalk_1.default.yellow(constants_1.APP_VERSION)} → ${chalk_1.default.green(latestCLIVersion)}`;
|
|
17
32
|
const npmUpdateAvailableCommand = `Run ${chalk_1.default.cyan('npm i @contrast/contrast -g')} to update via npm`;
|
|
@@ -27,6 +42,6 @@ async function findLatestCLIVersion(updateMessageHidden) {
|
|
|
27
42
|
}
|
|
28
43
|
exports.findLatestCLIVersion = findLatestCLIVersion;
|
|
29
44
|
async function isCorrectNodeVersion(currentVersion) {
|
|
30
|
-
return semver_1.default.satisfies(currentVersion, '>=16
|
|
45
|
+
return semver_1.default.satisfies(currentVersion, '>=16');
|
|
31
46
|
}
|
|
32
47
|
exports.isCorrectNodeVersion = isCorrectNodeVersion;
|