@contrast/contrast 2.3.1 → 2.4.0
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/auditRequests.js +8 -2
- package/dist/audit/processAudit.js +2 -0
- package/dist/cliConstants.js +8 -1
- package/dist/constants/constants.js +1 -1
- package/dist/constants/locales.js +1 -0
- package/dist/github/projectGroup.js +3 -0
- package/dist/index.js +1 -0
- package/dist/scaAnalysis/common/commonReportingFunctionsSca.js +12 -7
- package/dist/scaAnalysis/processServicesFlow.js +6 -0
- package/dist/scan/processScan.js +2 -0
- package/dist/utils/validationCheck.js +5 -0
- package/package.json +1 -1
|
@@ -50,13 +50,19 @@ const retrieveProjectByOrganizationIdUrl = (config) => {
|
|
|
50
50
|
: baseUrl.concat(`&type=CLI`);
|
|
51
51
|
return baseUrl;
|
|
52
52
|
};
|
|
53
|
-
export function registerProjectGroup(config, requestBody) {
|
|
53
|
+
export async function registerProjectGroup(config, requestBody) {
|
|
54
54
|
const options = buildBaseRequestOptions(config, ErrorType.GENERIC);
|
|
55
55
|
options.url = registerProjectGroupUrl(config);
|
|
56
56
|
options.json = requestBody;
|
|
57
57
|
logDebug(config, 'registerProjectGroup');
|
|
58
58
|
logDebug(config, `url ${options.url}`);
|
|
59
|
-
|
|
59
|
+
try {
|
|
60
|
+
return await got.post(options);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log(`\nResource group ${config.resourceGroup} does not exist`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
const registerProjectGroupUrl = (config) => {
|
|
62
68
|
return `${config.host}/api/v4/organizations/${config.organizationId}/project-groups`;
|
|
@@ -4,12 +4,14 @@ import { processSca } from '../scaAnalysis/scaAnalysis.js';
|
|
|
4
4
|
import { sendTelemetryConfigAsObject } from '../telemetry/telemetry.js';
|
|
5
5
|
import { postRunMessage } from '../common/commonHelp.js';
|
|
6
6
|
import { logInfo } from '../common/logging.js';
|
|
7
|
+
import { validateHost } from '../utils/validationCheck.js';
|
|
7
8
|
export const processAudit = async (contrastConf, argvMain) => {
|
|
8
9
|
if (argvMain.indexOf('--help') !== -1) {
|
|
9
10
|
printHelpMessage();
|
|
10
11
|
process.exit(0);
|
|
11
12
|
}
|
|
12
13
|
let config = await getAuditConfig(contrastConf, 'audit', argvMain);
|
|
14
|
+
validateHost(config);
|
|
13
15
|
await processSca(config);
|
|
14
16
|
if (!config.fingerprint) {
|
|
15
17
|
postRunMessage('audit');
|
package/dist/cliConstants.js
CHANGED
|
@@ -474,6 +474,14 @@ const auditOptionDefinitions = [
|
|
|
474
474
|
'}:' +
|
|
475
475
|
i18n.__('auditOptionsTrackSummary')
|
|
476
476
|
},
|
|
477
|
+
{
|
|
478
|
+
name: 'resource-group',
|
|
479
|
+
type: String,
|
|
480
|
+
description: '{bold ' +
|
|
481
|
+
i18n.__('constantsOptional') +
|
|
482
|
+
'}:' +
|
|
483
|
+
i18n.__('auditOptionsResourceGroupSummary')
|
|
484
|
+
},
|
|
477
485
|
{
|
|
478
486
|
name: 'branch',
|
|
479
487
|
description: '{bold ' +
|
|
@@ -561,7 +569,6 @@ const mainUsageGuide = commandLineUsage([
|
|
|
561
569
|
{ name: i18n.__('lambdaName'), summary: i18n.__('helpLambdaSummary') },
|
|
562
570
|
{ name: i18n.__('helpName'), summary: i18n.__('helpSummary') },
|
|
563
571
|
{ name: i18n.__('learnName'), summary: i18n.__('helpLearnSummary') },
|
|
564
|
-
{ name: i18n.__('sarifName'), summary: i18n.__('sarifSummary') },
|
|
565
572
|
{
|
|
566
573
|
name: i18n.__('configGenerate'),
|
|
567
574
|
summary: i18n.__('configGenerateSummary')
|
|
@@ -17,7 +17,7 @@ export const HIGH = 'HIGH';
|
|
|
17
17
|
export const CRITICAL = 'CRITICAL';
|
|
18
18
|
// App
|
|
19
19
|
export const APP_NAME = 'contrast';
|
|
20
|
-
const APP_VERSION = '2.
|
|
20
|
+
const APP_VERSION = '2.4.0';
|
|
21
21
|
export const TIMEOUT = 120000;
|
|
22
22
|
export const CRITICAL_PRIORITY = 1;
|
|
23
23
|
export const HIGH_PRIORITY = 2;
|
|
@@ -148,6 +148,7 @@ export const en_locales = () => {
|
|
|
148
148
|
scanOptionsFileNameSummary: 'Path of the file you want to scan. If no file is specified, Contrast searches for a .jar, .war, .exe or .zip file in the working directory.',
|
|
149
149
|
scanOptionsVerboseSummary: ' Returns extended information to the terminal.',
|
|
150
150
|
auditOptionsTrackSummary: ' Send your dependency audit to Contrast to see results in the UI and start automating security checks. For instance when running local SCA checks you may not need or want to track the results.',
|
|
151
|
+
auditOptionsResourceGroupSummary: ' Add permissions for a new project to selected resource group.',
|
|
151
152
|
auditOptionsBranchSummary: ' Set the branch name to associate the library results to.',
|
|
152
153
|
auditOptionsLegacySummary: ' Creates an application in Contrast (a legacy workflow) - displays a dependency tree for your piece of code, utilizes metadata.' +
|
|
153
154
|
'\n' +
|
|
@@ -27,6 +27,9 @@ export const buildNewProjectGroupBody = async (config) => {
|
|
|
27
27
|
body.type = 'CLI';
|
|
28
28
|
body.name = getProjectGroupNameCLI(config);
|
|
29
29
|
}
|
|
30
|
+
if (config.resourceGroup) {
|
|
31
|
+
body.resourceGroups = [config.resourceGroup];
|
|
32
|
+
}
|
|
30
33
|
return body;
|
|
31
34
|
};
|
|
32
35
|
const getProjectGroupNameRepo = config => {
|
package/dist/index.js
CHANGED
|
@@ -25,14 +25,19 @@ export const printFormattedOutputSca = (config, reportModelList, numberOfVulnera
|
|
|
25
25
|
const report = new ReportList();
|
|
26
26
|
for (const library of reportModelList) {
|
|
27
27
|
const { artifactName, version, vulnerabilities, remediationAdvice } = library;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
if (vulnerabilities.length === 0) {
|
|
29
|
+
logDebug(config, `Unable to find vulnerability for ${artifactName} version ${version}`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const highestSeverity = findHighestSeverityCVESca(vulnerabilities, config);
|
|
33
|
+
const severityCount = severityCountAllCVEsSca(vulnerabilities, new SeverityCountModel()).getTotal;
|
|
34
|
+
if (highestSeverity.priority === undefined) {
|
|
35
|
+
highestSeverity.priority = NOTE_PRIORITY;
|
|
36
|
+
logDebug(config, `Unknown severity for vulnerability ${artifactName}`);
|
|
37
|
+
}
|
|
38
|
+
const newOutputModel = new ReportModelStructure(new ReportCompositeKey(artifactName, version, highestSeverity, severityCount), vulnerabilities, remediationAdvice);
|
|
39
|
+
report.reportOutputList.push(newOutputModel);
|
|
33
40
|
}
|
|
34
|
-
const newOutputModel = new ReportModelStructure(new ReportCompositeKey(artifactName, version, highestSeverity, severityCount), vulnerabilities, remediationAdvice);
|
|
35
|
-
report.reportOutputList.push(newOutputModel);
|
|
36
41
|
}
|
|
37
42
|
const outputOrderedByLowestSeverityAndLowestNumOfCvesFirst = orderBy(report.reportOutputList, [
|
|
38
43
|
reportListItem => {
|
|
@@ -88,6 +88,12 @@ const trackProcess = async (analysis, config, reportSpinner) => {
|
|
|
88
88
|
if (projectId === '') {
|
|
89
89
|
return dealWithNoProjectId(analysis, config, reportSpinner);
|
|
90
90
|
}
|
|
91
|
+
else if (config.resourceGroup) {
|
|
92
|
+
console.log('\nProject ' +
|
|
93
|
+
projectId +
|
|
94
|
+
' already exists and will not be added to resource group ' +
|
|
95
|
+
config.resourceGroup);
|
|
96
|
+
}
|
|
91
97
|
config.projectId = projectId;
|
|
92
98
|
// we can always register just in case but normally we exit when
|
|
93
99
|
await registerProjectIdOnCliServices(config, projectId);
|
package/dist/scan/processScan.js
CHANGED
|
@@ -7,8 +7,10 @@ import { sendTelemetryConfigAsObject } from '../telemetry/telemetry.js';
|
|
|
7
7
|
import { processFail } from '../common/fail.js';
|
|
8
8
|
import { postRunMessage } from '../common/commonHelp.js';
|
|
9
9
|
import { logInfo } from '../common/logging.js';
|
|
10
|
+
import { validateHost } from '../utils/validationCheck.js';
|
|
10
11
|
export const processScan = async (contrastConf, argv) => {
|
|
11
12
|
let config = await scanConfig.getScanConfig(contrastConf, 'scan', argv);
|
|
13
|
+
validateHost(config);
|
|
12
14
|
let output = undefined;
|
|
13
15
|
const scanResults = new ScanResultsModel(await startScan(config));
|
|
14
16
|
await sendTelemetryConfigAsObject(config, 'scan', argv, 'SUCCESS', scanResults.scanDetail.language);
|
|
@@ -18,6 +18,11 @@ export const validateAuthParams = params => {
|
|
|
18
18
|
params.host &&
|
|
19
19
|
params.authorization);
|
|
20
20
|
};
|
|
21
|
+
export const validateHost = config => {
|
|
22
|
+
if (config.host.endsWith('/')) {
|
|
23
|
+
config.host = config.host.slice(0, -1);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
21
26
|
export const validateFingerprintParams = params => {
|
|
22
27
|
return !!(params.repositoryUrl && params.repositoryName);
|
|
23
28
|
};
|