@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
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.saveFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const saveFile = (config, rawResults) => {
|
|
9
|
-
const fileName = `${config.applicationId}-sbom
|
|
8
|
+
const saveFile = (config, type, rawResults) => {
|
|
9
|
+
const fileName = `${config.applicationId}-sbom-${type}.json`;
|
|
10
10
|
fs_1.default.writeFileSync(fileName, JSON.stringify(rawResults));
|
|
11
11
|
};
|
|
12
12
|
exports.saveFile = saveFile;
|
|
@@ -2,9 +2,8 @@
|
|
|
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, PYTHON, RUBY, JAVASCRIPT, NODE, PHP } } = require('../../../
|
|
6
|
+
const { supportedLanguages: { JAVA, GO, PYTHON, RUBY, JAVASCRIPT, NODE, PHP, DOTNET } } = require('../../../constants/constants');
|
|
8
7
|
const goAnalysis = require('../../../scaAnalysis/go/goAnalysis');
|
|
9
8
|
const phpAnalysis = require('../../../scaAnalysis/php/index');
|
|
10
9
|
const { rubyAnalysis } = require('../../../scaAnalysis/ruby');
|
|
@@ -15,14 +14,16 @@ const { returnOra, startSpinner, succeedSpinner } = require('../../../utils/oraW
|
|
|
15
14
|
const i18n = require('i18n');
|
|
16
15
|
const { vulnerabilityReportV2 } = require('../../../audit/languageAnalysisEngine/report/reportingFeature');
|
|
17
16
|
const auditSave = require('../../../audit/save');
|
|
17
|
+
const { dotNetAnalysis } = require('../../../scaAnalysis/dotnet');
|
|
18
18
|
const processSca = async (config) => {
|
|
19
|
+
const startTime = performance.now();
|
|
19
20
|
let filesFound;
|
|
20
21
|
if (config.file) {
|
|
21
22
|
config.file = config.file.concat('/');
|
|
22
|
-
filesFound = await
|
|
23
|
+
filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(config.file);
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
|
-
filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(
|
|
26
|
+
filesFound = await autoDetection.autoDetectAuditFilesAndLanguages(undefined);
|
|
26
27
|
config.file = process.cwd().concat('/');
|
|
27
28
|
}
|
|
28
29
|
let messageToSend = undefined;
|
|
@@ -52,27 +53,39 @@ const processSca = async (config) => {
|
|
|
52
53
|
messageToSend = goAnalysis.goAnalysis(config, filesFound[0]);
|
|
53
54
|
config.language = GO;
|
|
54
55
|
break;
|
|
56
|
+
case DOTNET:
|
|
57
|
+
messageToSend = dotNetAnalysis(config, filesFound[0]);
|
|
58
|
+
config.language = DOTNET;
|
|
59
|
+
break;
|
|
55
60
|
default:
|
|
56
|
-
console.log('language detected
|
|
61
|
+
console.log('No supported language detected in project path');
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
59
64
|
if (!config.applicationId) {
|
|
60
65
|
config.applicationId = await auditController.dealWithNoAppId(config);
|
|
61
66
|
}
|
|
67
|
+
console.log('');
|
|
62
68
|
const reportSpinner = returnOra(i18n.__('auditSCAAnalysisBegins'));
|
|
63
69
|
startSpinner(reportSpinner);
|
|
64
70
|
const snapshotResponse = await treeUpload.commonSendSnapShot(messageToSend, config);
|
|
65
71
|
await pollForSnapshotCompletition(config, snapshotResponse.id, reportSpinner);
|
|
66
|
-
succeedSpinner(reportSpinner, '
|
|
72
|
+
succeedSpinner(reportSpinner, i18n.__('auditSCAAnalysisComplete'));
|
|
67
73
|
await vulnerabilityReportV2(config, snapshotResponse.id);
|
|
68
|
-
|
|
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 -----`);
|
|
69
80
|
}
|
|
70
81
|
else {
|
|
71
82
|
if (filesFound.length === 0) {
|
|
72
|
-
console.log(
|
|
83
|
+
console.log(i18n.__('languageAnalysisNoLanguage'));
|
|
84
|
+
console.log(i18n.__('languageAnalysisNoLanguageHelpLine'));
|
|
85
|
+
throw new Error();
|
|
73
86
|
}
|
|
74
87
|
else {
|
|
75
|
-
|
|
88
|
+
throw new Error('multiple language files detected, please use --file to specify a directory or the file where dependencies are declared');
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
};
|
|
@@ -242,9 +242,9 @@ HTTPClient.prototype.checkLibrary = function checkLibrary(data) {
|
|
|
242
242
|
options.body = data;
|
|
243
243
|
return requestUtils.sendRequest({ method: 'post', options });
|
|
244
244
|
};
|
|
245
|
-
HTTPClient.prototype.getSbom = function getSbom(config) {
|
|
245
|
+
HTTPClient.prototype.getSbom = function getSbom(config, type) {
|
|
246
246
|
const options = _.cloneDeep(this.requestOptions);
|
|
247
|
-
options.url =
|
|
247
|
+
options.url = createSbomUrl(config, type);
|
|
248
248
|
return requestUtils.sendRequest({ method: 'get', options });
|
|
249
249
|
};
|
|
250
250
|
HTTPClient.prototype.getLatestVersion = function getLatestVersion() {
|
|
@@ -304,11 +304,11 @@ const createAppNameUrl = config => {
|
|
|
304
304
|
function createLibraryVulnerabilitiesUrl(config) {
|
|
305
305
|
return `${config.host}/Contrast/api/ng/${config.organizationId}/libraries/artifactsByGroupNameVersion`;
|
|
306
306
|
}
|
|
307
|
-
function createSpecificReportUrl(config, reportId) {
|
|
308
|
-
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
309
|
}
|
|
310
|
-
function createSpecificReportWithProdUrl(config, reportId) {
|
|
311
|
-
return createSpecificReportUrl(config, reportId).concat(
|
|
310
|
+
function createSpecificReportWithProdUrl(config, reportId, includeTree) {
|
|
311
|
+
return createSpecificReportUrl(config, reportId, includeTree).concat(`&nodesToInclude=PROD`);
|
|
312
312
|
}
|
|
313
313
|
function createSpecificReportStatusURL(config, reportId) {
|
|
314
314
|
return `${config.host}/Contrast/api/ng/sca/organizations/${config.organizationId}/applications/${config.applicationId}/snapshots/${reportId}/status`;
|
|
@@ -316,8 +316,8 @@ function createSpecificReportStatusURL(config, reportId) {
|
|
|
316
316
|
function createDataUrl() {
|
|
317
317
|
return `https://ardy.contrastsecurity.com/production`;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
320
|
-
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}`;
|
|
321
321
|
}
|
|
322
322
|
module.exports = HTTPClient;
|
|
323
323
|
module.exports.pollForAuthUrl = pollForAuthUrl;
|
|
@@ -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.
|
|
15
|
+
const APP_VERSION = '1.0.9';
|
|
16
16
|
const TIMEOUT = 120000;
|
|
17
17
|
const HIGH_COLOUR = '#ff9900';
|
|
18
18
|
const CRITICAL_COLOUR = '#e35858';
|
|
@@ -27,9 +27,12 @@ const NOTE_PRIORITY = 5;
|
|
|
27
27
|
const AUTH_UI_URL = 'https://cli-auth.contrastsecurity.com';
|
|
28
28
|
const AUTH_CALLBACK_URL = 'https://cli-auth-api.contrastsecurity.com';
|
|
29
29
|
const SARIF_FILE = 'SARIF';
|
|
30
|
+
const SBOM_CYCLONE_DX_FILE = 'cyclonedx';
|
|
31
|
+
const SBOM_SPDX_FILE = 'spdx';
|
|
30
32
|
const CE_URL = 'https://ce.contrastsecurity.com/';
|
|
31
33
|
module.exports = {
|
|
32
34
|
supportedLanguages: { NODE, DOTNET, JAVA, RUBY, PYTHON, GO, PHP, JAVASCRIPT },
|
|
35
|
+
supportedLanguagesScan: { JAVASCRIPT, DOTNET, JAVA },
|
|
33
36
|
LOW,
|
|
34
37
|
MEDIUM,
|
|
35
38
|
HIGH,
|
|
@@ -50,5 +53,7 @@ module.exports = {
|
|
|
50
53
|
HIGH_PRIORITY,
|
|
51
54
|
MEDIUM_PRIORITY,
|
|
52
55
|
LOW_PRIORITY,
|
|
53
|
-
NOTE_PRIORITY
|
|
56
|
+
NOTE_PRIORITY,
|
|
57
|
+
SBOM_CYCLONE_DX_FILE,
|
|
58
|
+
SBOM_SPDX_FILE
|
|
54
59
|
};
|
|
@@ -38,20 +38,22 @@ const en_locales = () => {
|
|
|
38
38
|
languageAnalysisMultipleLanguages2: 'Please specify which project file you would like analyzed with the %s CLI option.',
|
|
39
39
|
languageAnalysisProjectFiles: "Identified project language as '%s' but found multiple project files: %s. Please specify which project file you would like analyzed with the %s CLI option.",
|
|
40
40
|
languageAnalysisHasNoLockFile: "Identified project language as '%s' but no project lock file was found.",
|
|
41
|
-
|
|
41
|
+
languageAnalysisHasNoPackageJsonFile: 'Identified project language as javascript but no package.json file was found.',
|
|
42
|
+
languageAnalysisHasMultipleLockFiles: "Identified project language as '%s' but multiple project lock files were found.",
|
|
42
43
|
languageAnalysisProjectFileError: "Identified project language as '%s' but no project file was found.",
|
|
43
44
|
languageAnalysisProjectRootFileNameReadError: 'Failed to read the contents of the directory @ %s because: ',
|
|
44
45
|
languageAnalysisProjectRootFileNameMissingError: "%s isn't a file or directory",
|
|
45
46
|
languageAnalysisProjectRootFileNameFailure: 'Failed to get information about the file or directory @ %s because: ',
|
|
46
47
|
languageAnalysisFailure: ' analysis failed because: ',
|
|
47
|
-
languageAnalysisNoLanguage: '
|
|
48
|
+
languageAnalysisNoLanguage: 'We cannot detect a project, use --f <path> to specify a file or folder to analyze.',
|
|
49
|
+
languageAnalysisNoLanguageHelpLine: `${chalk.bold('contrast audit --help')} for more information.`,
|
|
48
50
|
NodeAnalysisFailure: 'NODE analysis failed because: ',
|
|
49
51
|
phpAnalysisFailure: 'PHP analysis failed because: ',
|
|
50
|
-
NodeParseNPM:
|
|
52
|
+
NodeParseNPM: 'Failed to parse NODE package-lock.json file because: ',
|
|
51
53
|
phpParseComposerLock: "Failed to parse PHP composer.lock file @ '%s' because: ",
|
|
52
54
|
NodeReadNpmError: 'Failed to read the package-lock.json file @ "%s" because: ',
|
|
53
55
|
phpReadError: 'Failed to read the composer.lock file @ "%s" because: ',
|
|
54
|
-
NodeParseYarn:
|
|
56
|
+
NodeParseYarn: 'Failed to parse yarn.lock version %s because: ',
|
|
55
57
|
NodeParseYarn2: "Failed to parse Node yarn.lock version 2 @ '%s' because: ",
|
|
56
58
|
nodeReadProjectFileError: 'Failed to read the NODE project file @ "%s" because: ',
|
|
57
59
|
phpReadProjectFileError: 'Failed to read the PHP project file @ "%s" because: ',
|
|
@@ -78,7 +80,7 @@ const en_locales = () => {
|
|
|
78
80
|
constantsApplicationName: 'The name of the application cataloged by Contrast UI',
|
|
79
81
|
constantsCatalogueApplication: 'Provide this if you want to catalogue an application',
|
|
80
82
|
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',
|
|
81
|
-
constantsFilePath:
|
|
83
|
+
constantsFilePath: `Path of the file you want to perform an SCA audit on. If no folder is specified, Contrast searches for dependency files in the working directory.`,
|
|
82
84
|
constantsSilent: 'Silences JSON output.',
|
|
83
85
|
constantsAppGroups: 'Assign your application to one or more pre-existing groups when using the catalogue command. Group lists should be comma separated.',
|
|
84
86
|
constantsVersion: 'Displays CLI Version you are currently on.',
|
|
@@ -95,7 +97,7 @@ const en_locales = () => {
|
|
|
95
97
|
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.',
|
|
96
98
|
constantsCount: 'The number of CVEs that must be exceeded to fail a build',
|
|
97
99
|
constantsHeader: 'CodeSec by Contrast Security',
|
|
98
|
-
constantsPrerequisitesContentScanLanguages: 'Java
|
|
100
|
+
constantsPrerequisitesContentScanLanguages: 'Java, Javascript and .NET supported',
|
|
99
101
|
constantsContrastContent: "Use the 'contrast' command for fast and accurate security analysis of your applications and APIs (Java, JavaScript and .NET ) as well as serverless functions (AWS lambda, Java and Python).",
|
|
100
102
|
constantsUsageGuideContentRecommendation: 'Our recommendation is that this is invoked as part of a CI pipeline so that running the cli is automated as part of your build process.',
|
|
101
103
|
constantsPrerequisitesHeader: 'Pre-requisites',
|
|
@@ -162,7 +164,7 @@ const en_locales = () => {
|
|
|
162
164
|
constantsIgnoreCertErrors: 'For EOP users with a local Teamserver install, this will bypass the SSL certificate and recognise a self signed certificate.',
|
|
163
165
|
constantsSave: 'Saves the Scan Results SARIF to file.',
|
|
164
166
|
scanLabel: "adds a label to the scan - defaults to 'Started by CLI tool at current date'",
|
|
165
|
-
constantsIgnoreDev: 'Excludes developer dependencies from the
|
|
167
|
+
constantsIgnoreDev: 'Excludes developer dependencies from the results. All dependencies are included by default.',
|
|
166
168
|
constantsCommands: 'Commands',
|
|
167
169
|
constantsScanOptions: 'Scan Options',
|
|
168
170
|
sbomError: 'All required parameters are not present.',
|
|
@@ -253,31 +255,23 @@ const en_locales = () => {
|
|
|
253
255
|
connectionError: 'An error has occurred when trying to get the Project Id please check your internet connection or provide the Project Id manually',
|
|
254
256
|
internalServerErrorHeader: '500 error - Internal server error',
|
|
255
257
|
resourceLockedErrorHeader: '423 error - Resource is locked',
|
|
256
|
-
auditHeader: 'Contrast
|
|
257
|
-
auditHeaderMessage:
|
|
258
|
-
Performs software composition analysis (SCA) on your application/code time to show you the dependencies between open source libraries, including where vulnerabilities were introduced.\n
|
|
259
|
-
Our recommendation is that this is invoked as part of a CI pipeline so that running the cli is automated as part of your build process.`,
|
|
258
|
+
auditHeader: 'Contrast audit help',
|
|
259
|
+
auditHeaderMessage: "Use 'contrast audit' to analyze a project’s dependencies for vulnerabilities.",
|
|
260
260
|
constantsAuditPrerequisitesContentSupportedLanguages: 'Supported languages and their requirements are:',
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
For a Gradle project (v4.8+) use build.gradle. A gradle-wrapper.properties file is also required.
|
|
265
|
-
Kotlin is also supported requiring a build.gradle.kts file.`,
|
|
266
|
-
constantsAuditPrerequisitesContentDotNet: '.NET framework and .NET core: ',
|
|
261
|
+
constantsAuditPrerequisitesJavaContentMessage: `
|
|
262
|
+
${chalk.bold('Java:')} pom.xml ${chalk.bold('and')} Maven build platform including the dependency plugin.
|
|
263
|
+
${chalk.bold('Or')} build.gradle ${chalk.bold('and')} gradle dependencies or ./gradlew dependencies must be supported`,
|
|
267
264
|
constantsAuditPrerequisitesContentDotNetMessage: `
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
constantsAuditPrerequisitesContentLanguagePythonMessage: 'pipfile AND pipfile.lock',
|
|
265
|
+
${chalk.bold('.NET framework and .NET core:')} MSBuild 15.0 or greater and a packages.lock.json file.
|
|
266
|
+
Note: If the packages.lock.json file is unavailable it can be generated by setting RestorePackagesWithLockFile to true within each *.csproj file and running dotnet build.\n`,
|
|
267
|
+
constantsAuditPrerequisitesContentNodeMessage: `${chalk.bold('Node:')} package.json and a lock file (either .package-lock.json or .yarn.lock.)\n`,
|
|
268
|
+
constantsAuditPrerequisitesContentRubyMessage: `${chalk.bold('Ruby:')} gemfile and gemfile.lock\n`,
|
|
269
|
+
constantsAuditPrerequisitesContentPythonMessage: `${chalk.bold('Python:')} pipfile and pipfile.lock\n`,
|
|
270
|
+
constantsAuditPrerequisitesContentGoMessage: `${chalk.bold('Go:')} go.mod\n`,
|
|
271
|
+
constantsAuditPrerequisitesContentPHPMessage: `${chalk.bold('PHP:')} composer.json and composer.lock\n`,
|
|
276
272
|
constantsAuditOptions: 'Audit Options',
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
auditOptionsSave: '-s, --save',
|
|
280
|
-
auditOptionsSaveDescription: 'saves the output in specified format, options: sbom',
|
|
273
|
+
auditOptionsSaveDescription: 'Generate and save an SBOM (Software Bill of Materials)\n',
|
|
274
|
+
auditOptionsSaveOptionsDescription: 'Valid options are: spdx, cyclonedx (cycloneDX is the default format)',
|
|
281
275
|
scanNotCompleted: 'Scan not completed. Check for framework and language support here: %s',
|
|
282
276
|
auditNotCompleted: 'audit not completed. Please try again',
|
|
283
277
|
scanNoVulnerabilitiesFound: '🎉 No vulnerabilities found.',
|
|
@@ -292,7 +286,7 @@ const en_locales = () => {
|
|
|
292
286
|
auditReportSuccessMessage: 'Report successfully retrieved',
|
|
293
287
|
auditReportFailureMessage: 'Unable to generate library report',
|
|
294
288
|
auditSCAAnalysisBegins: 'Contrast SCA audit started',
|
|
295
|
-
auditSCAAnalysisComplete: 'Contrast
|
|
289
|
+
auditSCAAnalysisComplete: 'Contrast audit complete',
|
|
296
290
|
...lambda
|
|
297
291
|
};
|
|
298
292
|
};
|
package/dist/constants.js
CHANGED
|
@@ -235,14 +235,6 @@ const auditOptionDefinitions = [
|
|
|
235
235
|
{
|
|
236
236
|
name: 'maven-settings-path'
|
|
237
237
|
},
|
|
238
|
-
{
|
|
239
|
-
name: 'language',
|
|
240
|
-
alias: 'l',
|
|
241
|
-
description: '{bold ' +
|
|
242
|
-
i18n.__('constantsRequiredCatalogue') +
|
|
243
|
-
'}: ' +
|
|
244
|
-
i18n.__('constantsLanguage')
|
|
245
|
-
},
|
|
246
238
|
{
|
|
247
239
|
name: 'organization-id',
|
|
248
240
|
alias: 'o',
|
|
@@ -294,12 +286,22 @@ const auditOptionDefinitions = [
|
|
|
294
286
|
description: '{bold ' +
|
|
295
287
|
i18n.__('constantsOptional') +
|
|
296
288
|
'}: ' +
|
|
297
|
-
i18n.__('auditOptionsSaveDescription')
|
|
289
|
+
i18n.__('auditOptionsSaveDescription') +
|
|
290
|
+
i18n.__('auditOptionsSaveOptionsDescription')
|
|
298
291
|
},
|
|
299
292
|
{
|
|
300
293
|
name: 'experimental',
|
|
301
294
|
alias: 'e',
|
|
302
295
|
type: Boolean
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'timeout',
|
|
299
|
+
alias: 't',
|
|
300
|
+
type: Number,
|
|
301
|
+
description: '{bold ' +
|
|
302
|
+
i18n.__('constantsOptional') +
|
|
303
|
+
'}: ' +
|
|
304
|
+
i18n.__('scanOptionsTimeoutSummary')
|
|
303
305
|
}
|
|
304
306
|
];
|
|
305
307
|
const mainUsageGuide = commandLineUsage([
|
package/dist/index.js
CHANGED
|
@@ -30,55 +30,64 @@ const getMainOption = () => {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
const start = async () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
config.set('numOfRuns',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
33
|
+
try {
|
|
34
|
+
if (await (0, versionChecker_1.isCorrectNodeVersion)(process.version)) {
|
|
35
|
+
const { mainOptions, argv: argvMain } = getMainOption();
|
|
36
|
+
const command = mainOptions.command != undefined
|
|
37
|
+
? mainOptions.command.toLowerCase()
|
|
38
|
+
: '';
|
|
39
|
+
if (command === 'version' ||
|
|
40
|
+
argvMain.includes('--v') ||
|
|
41
|
+
argvMain.includes('--version')) {
|
|
42
|
+
console.log(constants_2.APP_VERSION);
|
|
43
|
+
await (0, versionChecker_1.findLatestCLIVersion)(config);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
config.set('numOfRuns', config.get('numOfRuns') + 1);
|
|
47
|
+
if (config.get('numOfRuns') >= 1) {
|
|
48
|
+
await (0, versionChecker_1.findLatestCLIVersion)(config);
|
|
49
|
+
config.set('numOfRuns', 0);
|
|
50
|
+
}
|
|
51
|
+
if (command === 'config') {
|
|
52
|
+
return (0, config_1.processConfig)(argvMain, config);
|
|
53
|
+
}
|
|
54
|
+
if (command === 'auth') {
|
|
55
|
+
return await (0, auth_1.processAuth)(argvMain, config);
|
|
56
|
+
}
|
|
57
|
+
if (command === 'lambda') {
|
|
58
|
+
return await (0, lambda_1.processLambda)(argvMain);
|
|
59
|
+
}
|
|
60
|
+
if (command === 'scan') {
|
|
61
|
+
return await (0, processScan_1.processScan)(argvMain);
|
|
62
|
+
}
|
|
63
|
+
if (command === 'audit') {
|
|
64
|
+
return await (0, processAudit_1.processAudit)(argvMain);
|
|
65
|
+
}
|
|
66
|
+
if (command === 'help' ||
|
|
67
|
+
argvMain.includes('--help') ||
|
|
68
|
+
Object.keys(mainOptions).length === 0) {
|
|
69
|
+
console.log(mainUsageGuide);
|
|
70
|
+
}
|
|
71
|
+
else if (mainOptions._unknown !== undefined) {
|
|
72
|
+
const foundCommand = (0, errorHandling_1.findCommandOnError)(mainOptions._unknown);
|
|
73
|
+
foundCommand
|
|
74
|
+
? console.log(`Unknown Command: Did you mean "${foundCommand}"? \nUse "${foundCommand} --help" for the full list of options`)
|
|
75
|
+
: console.log(`Unknown Command: ${command} \nUse --help for the full list`);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(`Unknown Command: ${command} \nUse --help for the full list`);
|
|
79
|
+
}
|
|
80
|
+
process.exit(9);
|
|
73
81
|
}
|
|
74
82
|
else {
|
|
75
|
-
console.log(
|
|
83
|
+
console.log('Contrast supports Node versions >=16.13.2 <17. Please use one of those versions.');
|
|
84
|
+
process.exit(9);
|
|
76
85
|
}
|
|
77
|
-
process.exit(9);
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
console.log(
|
|
81
|
-
|
|
87
|
+
catch (err) {
|
|
88
|
+
console.log();
|
|
89
|
+
console.log(err.message.toString());
|
|
90
|
+
process.exit(1);
|
|
82
91
|
}
|
|
83
92
|
};
|
|
84
93
|
start();
|
package/dist/lambda/lambda.js
CHANGED
|
@@ -22,6 +22,7 @@ const requestUtils_1 = require("../utils/requestUtils");
|
|
|
22
22
|
const oraWrapper_1 = __importDefault(require("../utils/oraWrapper"));
|
|
23
23
|
const analytics_1 = require("./analytics");
|
|
24
24
|
const types_1 = require("./types");
|
|
25
|
+
const constants_2 = require("../constants/constants");
|
|
25
26
|
const failedStates = [
|
|
26
27
|
'UNSUPPORTED',
|
|
27
28
|
'EXCLUDED',
|
|
@@ -68,7 +69,8 @@ const processLambda = async (argv) => {
|
|
|
68
69
|
const startCommandAnalytics = {
|
|
69
70
|
arguments: lambdaOptions,
|
|
70
71
|
sessionId: commandSessionId,
|
|
71
|
-
eventType: types_1.EventType.START
|
|
72
|
+
eventType: types_1.EventType.START,
|
|
73
|
+
packageVersion: constants_2.APP_VERSION
|
|
72
74
|
};
|
|
73
75
|
(0, analytics_1.postAnalytics)(startCommandAnalytics).catch((error) => {
|
|
74
76
|
});
|
|
@@ -95,7 +97,8 @@ const processLambda = async (argv) => {
|
|
|
95
97
|
const endCommandAnalytics = {
|
|
96
98
|
sessionId: commandSessionId,
|
|
97
99
|
eventType: types_1.EventType.END,
|
|
98
|
-
status: errorMsg ? types_1.StatusType.FAILED : types_1.StatusType.SUCCESS
|
|
100
|
+
status: errorMsg ? types_1.StatusType.FAILED : types_1.StatusType.SUCCESS,
|
|
101
|
+
packageVersion: constants_2.APP_VERSION
|
|
99
102
|
};
|
|
100
103
|
if (errorMsg) {
|
|
101
104
|
endCommandAnalytics.errorMsg = errorMsg;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateSbom = void 0;
|
|
4
4
|
const commonApi_1 = require("../utils/commonApi");
|
|
5
|
-
const generateSbom = (config) => {
|
|
5
|
+
const generateSbom = (config, type) => {
|
|
6
6
|
const client = (0, commonApi_1.getHttpClient)(config);
|
|
7
7
|
return client
|
|
8
|
-
.getSbom(config)
|
|
8
|
+
.getSbom(config, type)
|
|
9
9
|
.then((res) => {
|
|
10
10
|
if (res.statusCode === 200) {
|
|
11
11
|
return res.body;
|
|
@@ -46,11 +46,17 @@ const createPhpTSMessage = phpTree => {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
const createDotNetTSMessage = dotnetTree => {
|
|
50
|
+
return {
|
|
51
|
+
dotnet: dotnetTree
|
|
52
|
+
};
|
|
53
|
+
};
|
|
49
54
|
module.exports = {
|
|
50
55
|
createJavaScriptTSMessage,
|
|
51
56
|
createJavaTSMessage,
|
|
52
57
|
createGoTSMessage,
|
|
53
58
|
createPhpTSMessage,
|
|
54
59
|
createRubyTSMessage,
|
|
55
|
-
createPythonTSMessage
|
|
60
|
+
createPythonTSMessage,
|
|
61
|
+
createDotNetTSMessage
|
|
56
62
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const commonApi = require('../../utils/commonApi');
|
|
3
3
|
const { APP_VERSION } = require('../../constants/constants');
|
|
4
4
|
const commonSendSnapShot = async (analysis, config) => {
|
|
5
5
|
const requestBody = {
|
|
@@ -7,7 +7,7 @@ const commonSendSnapShot = async (analysis, config) => {
|
|
|
7
7
|
cliVersion: APP_VERSION,
|
|
8
8
|
snapshot: analysis
|
|
9
9
|
};
|
|
10
|
-
const client = getHttpClient(config);
|
|
10
|
+
const client = commonApi.getHttpClient(config);
|
|
11
11
|
return client
|
|
12
12
|
.sendSnapshot(requestBody, config)
|
|
13
13
|
.then(res => {
|
|
@@ -15,12 +15,11 @@ const commonSendSnapShot = async (analysis, config) => {
|
|
|
15
15
|
return res.body;
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
|
|
19
|
-
console.log('error processing dependencies');
|
|
18
|
+
throw new Error(res.statusCode + ` error processing dependencies`);
|
|
20
19
|
}
|
|
21
20
|
})
|
|
22
21
|
.catch(err => {
|
|
23
|
-
|
|
22
|
+
throw err;
|
|
24
23
|
});
|
|
25
24
|
};
|
|
26
25
|
module.exports = {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const xml2js = require('xml2js');
|
|
4
|
+
const i18n = require('i18n');
|
|
5
|
+
const readAndParseProjectFile = projectFilePath => {
|
|
6
|
+
const projectFile = fs.readFileSync(projectFilePath);
|
|
7
|
+
return new xml2js.Parser({
|
|
8
|
+
explicitArray: false,
|
|
9
|
+
mergeAttrs: true
|
|
10
|
+
}).parseString(projectFile);
|
|
11
|
+
};
|
|
12
|
+
const readAndParseLockFile = lockFilePath => {
|
|
13
|
+
const lockFile = JSON.parse(fs.readFileSync(lockFilePath).toString());
|
|
14
|
+
let count = 0;
|
|
15
|
+
for (const dependenciesNode in lockFile.dependencies) {
|
|
16
|
+
for (const innerNode in lockFile.dependencies[dependenciesNode]) {
|
|
17
|
+
const nodeValidation = JSON.stringify(lockFile.dependencies[dependenciesNode][innerNode]);
|
|
18
|
+
if (nodeValidation.includes('"type":"Project"')) {
|
|
19
|
+
count += 1;
|
|
20
|
+
delete lockFile.dependencies[dependenciesNode][innerNode];
|
|
21
|
+
lockFile.additionalInfo = 'dependenciesNote';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (count > 0) {
|
|
26
|
+
const multiLevelProjectWarning = () => {
|
|
27
|
+
console.log('');
|
|
28
|
+
console.log(i18n.__('dependenciesNote'));
|
|
29
|
+
};
|
|
30
|
+
setTimeout(multiLevelProjectWarning, 7000);
|
|
31
|
+
}
|
|
32
|
+
return lockFile;
|
|
33
|
+
};
|
|
34
|
+
const getDotNetDeps = (filePath, languageFiles) => {
|
|
35
|
+
const projectFile = readAndParseProjectFile(filePath + `/${languageFiles[0]}`);
|
|
36
|
+
const lockFile = readAndParseLockFile(filePath + `/${languageFiles[1]}`);
|
|
37
|
+
return { projectFile, lockFile };
|
|
38
|
+
};
|
|
39
|
+
module.exports = {
|
|
40
|
+
getDotNetDeps,
|
|
41
|
+
readAndParseProjectFile,
|
|
42
|
+
readAndParseLockFile
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getDotNetDeps } = require('./analysis');
|
|
3
|
+
const { createDotNetTSMessage } = require('../common/formatMessage');
|
|
4
|
+
const dotNetAnalysis = (config, languageFiles) => {
|
|
5
|
+
const dotNetDeps = getDotNetDeps(config.file, languageFiles.DOTNET);
|
|
6
|
+
return createDotNetTSMessage(dotNetDeps);
|
|
7
|
+
};
|
|
8
|
+
module.exports = {
|
|
9
|
+
dotNetAnalysis
|
|
10
|
+
};
|
|
@@ -10,7 +10,7 @@ const readFile = async (config, languageFiles, nameOfFile) => {
|
|
|
10
10
|
return fs.readFileSync(config.file.concat(languageFiles[index]), 'utf8');
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
|
|
13
|
+
throw new Error('could not find file');
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
const readYarn = async (config, languageFiles, nameOfFile) => {
|
|
@@ -29,8 +29,7 @@ const readYarn = async (config, languageFiles, nameOfFile) => {
|
|
|
29
29
|
return yarn;
|
|
30
30
|
}
|
|
31
31
|
catch (err) {
|
|
32
|
-
|
|
33
|
-
return;
|
|
32
|
+
throw new Error(i18n.__('nodeReadYarnLockFileError') + `${err.message}`);
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
35
|
const parseNpmLockFile = async (js) => {
|
|
@@ -67,8 +66,7 @@ const parseNpmLockFile = async (js) => {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
catch (err) {
|
|
70
|
-
|
|
71
|
-
return;
|
|
69
|
+
throw new Error(i18n.__('NodeParseNPM') + `${err.message}`);
|
|
72
70
|
}
|
|
73
71
|
};
|
|
74
72
|
const addDepToLockFile = (js, depObj, key) => {
|
|
@@ -97,8 +95,7 @@ const parseYarnLockFile = async (js) => {
|
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
catch (err) {
|
|
100
|
-
|
|
101
|
-
return;
|
|
98
|
+
throw new Error(i18n.__('NodeParseYarn', js.yarn.yarnVersion) + `${err.message}`);
|
|
102
99
|
}
|
|
103
100
|
};
|
|
104
101
|
module.exports = {
|