@contrast/contrast 1.0.5 → 1.0.8
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 -5
- package/dist/audit/autodetection/autoDetectLanguage.js +3 -3
- package/dist/audit/catalogueApplication/catalogueApplication.js +23 -5
- package/dist/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +4 -2
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +2 -1
- package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +2 -1
- package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +2 -1
- package/dist/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +5 -5
- package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +9 -9
- package/dist/audit/languageAnalysisEngine/index.js +2 -2
- package/dist/audit/languageAnalysisEngine/languageAnalysisFactory.js +6 -27
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +25 -5
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +99 -20
- package/dist/audit/languageAnalysisEngine/report/models/reportListModel.js +2 -1
- package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +24 -0
- package/dist/audit/languageAnalysisEngine/report/models/reportSeverityModel.js +3 -1
- package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +16 -0
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +35 -14
- package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +58 -47
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +65 -3
- package/dist/audit/save.js +29 -0
- package/dist/commands/audit/auditController.js +22 -6
- package/dist/commands/audit/help.js +24 -1
- package/dist/commands/audit/processAudit.js +8 -2
- package/dist/commands/audit/saveFile.js +7 -3
- package/dist/commands/scan/processScan.js +1 -1
- package/dist/commands/scan/sca/scaAnalysis.js +48 -11
- package/dist/common/HTTPClient.js +56 -15
- package/dist/common/errorHandling.js +6 -1
- package/dist/common/versionChecker.js +20 -5
- package/dist/constants/constants.js +13 -3
- package/dist/constants/locales.js +15 -12
- package/dist/constants.js +9 -4
- package/dist/index.js +4 -3
- package/dist/lambda/analytics.js +11 -0
- package/dist/lambda/lambda.js +35 -4
- package/dist/lambda/types.js +13 -0
- package/dist/sbom/generateSbom.js +4 -3
- package/dist/scaAnalysis/common/formatMessage.js +46 -1
- package/dist/scaAnalysis/common/treeUpload.js +1 -3
- package/dist/scaAnalysis/go/goAnalysis.js +17 -0
- package/dist/scaAnalysis/go/goParseDeps.js +158 -0
- package/dist/scaAnalysis/go/goReadDepFile.js +21 -0
- package/dist/scaAnalysis/java/analysis.js +11 -22
- package/dist/scaAnalysis/java/index.js +6 -6
- package/dist/scaAnalysis/java/javaBuildDepsParser.js +14 -1
- package/dist/scaAnalysis/javascript/analysis.js +110 -0
- package/dist/scaAnalysis/javascript/index.js +41 -0
- package/dist/scaAnalysis/php/analysis.js +89 -0
- package/dist/scaAnalysis/php/index.js +10 -0
- package/dist/scaAnalysis/python/analysis.js +42 -0
- package/dist/scaAnalysis/python/index.js +10 -0
- package/dist/scaAnalysis/ruby/analysis.js +226 -0
- package/dist/scaAnalysis/ruby/index.js +10 -0
- package/dist/scan/autoDetection.js +8 -4
- package/dist/scan/fileUtils.js +26 -8
- package/dist/scan/formatScanOutput.js +18 -17
- 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 +5 -3
- package/dist/scan/scanConfig.js +6 -1
- package/dist/scan/scanController.js +26 -6
- package/dist/scan/scanResults.js +20 -6
- package/dist/utils/commonApi.js +4 -1
- package/dist/utils/filterProjectPath.js +7 -2
- package/dist/utils/oraWrapper.js +5 -1
- package/package.json +13 -9
- package/src/audit/autodetection/autoDetectLanguage.ts +3 -3
- package/src/audit/catalogueApplication/catalogueApplication.js +28 -7
- package/src/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +11 -8
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +2 -1
- package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +2 -1
- package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +2 -1
- package/src/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +5 -5
- package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +11 -11
- package/src/audit/languageAnalysisEngine/index.js +2 -2
- package/src/audit/languageAnalysisEngine/languageAnalysisFactory.js +11 -31
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +35 -32
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +179 -25
- 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 +29 -0
- package/src/audit/languageAnalysisEngine/report/models/reportSeverityModel.ts +12 -3
- package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +20 -0
- package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +50 -18
- package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +88 -66
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +78 -3
- package/src/audit/save.js +32 -0
- package/src/commands/audit/auditController.ts +23 -15
- package/src/commands/audit/help.ts +24 -1
- package/src/commands/audit/processAudit.ts +7 -4
- package/src/commands/audit/saveFile.ts +5 -1
- package/src/commands/scan/processScan.js +2 -1
- package/src/commands/scan/sca/scaAnalysis.js +70 -29
- package/src/common/HTTPClient.js +72 -25
- package/src/common/errorHandling.ts +10 -1
- package/src/common/versionChecker.ts +24 -5
- package/src/constants/constants.js +13 -3
- package/src/constants/locales.js +15 -12
- package/src/constants.js +9 -4
- package/src/index.ts +5 -3
- package/src/lambda/analytics.ts +9 -0
- package/src/lambda/arn.ts +2 -1
- package/src/lambda/lambda.ts +37 -17
- package/src/lambda/types.ts +35 -0
- package/src/lambda/utils.ts +2 -7
- package/src/sbom/generateSbom.ts +1 -1
- package/src/scaAnalysis/common/formatMessage.js +51 -1
- package/src/scaAnalysis/common/treeUpload.js +1 -6
- package/src/scaAnalysis/go/goAnalysis.js +19 -0
- package/src/scaAnalysis/go/goParseDeps.js +203 -0
- package/src/scaAnalysis/go/goReadDepFile.js +30 -0
- package/src/scaAnalysis/java/analysis.js +15 -32
- package/src/scaAnalysis/java/index.js +6 -6
- package/src/scaAnalysis/java/javaBuildDepsParser.js +15 -2
- package/src/scaAnalysis/javascript/analysis.js +127 -0
- package/src/scaAnalysis/javascript/index.js +56 -0
- package/src/scaAnalysis/php/analysis.js +98 -0
- package/src/scaAnalysis/php/index.js +11 -0
- package/src/scaAnalysis/python/analysis.js +49 -0
- package/src/scaAnalysis/python/index.js +11 -0
- package/src/scaAnalysis/ruby/analysis.js +282 -0
- package/src/scaAnalysis/ruby/index.js +11 -0
- package/src/scan/autoDetection.js +11 -7
- package/src/scan/fileUtils.js +27 -8
- package/src/scan/formatScanOutput.ts +26 -18
- 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 +8 -6
- package/src/scan/scanConfig.js +5 -1
- package/src/scan/scanController.js +30 -9
- package/src/scan/scanResults.js +31 -10
- package/src/utils/commonApi.js +4 -1
- package/src/utils/filterProjectPath.js +6 -2
- package/src/utils/oraWrapper.js +6 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ScanResultsInstances,
|
|
3
|
+
ScanResultsModel
|
|
4
|
+
} from './models/scanResultsModel'
|
|
2
5
|
import i18n from 'i18n'
|
|
3
6
|
import chalk from 'chalk'
|
|
4
7
|
import { ResultContent } from './models/resultContentModel'
|
|
@@ -16,7 +19,7 @@ import {
|
|
|
16
19
|
export function formatScanOutput(scanResults: ScanResultsModel) {
|
|
17
20
|
const { scanResultsInstances } = scanResults
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
const projectOverview = getProjectOverview(scanResultsInstances)
|
|
20
23
|
if (scanResultsInstances.content.length === 0) {
|
|
21
24
|
console.log(i18n.__('scanNoVulnerabilitiesFound'))
|
|
22
25
|
console.log(i18n.__('scanNoVulnerabilitiesFoundSecureCode'))
|
|
@@ -58,7 +61,7 @@ export function formatScanOutput(scanResults: ScanResultsModel) {
|
|
|
58
61
|
})
|
|
59
62
|
let learnRow: string[] = []
|
|
60
63
|
let adviceRow = []
|
|
61
|
-
|
|
64
|
+
const headerRow = [
|
|
62
65
|
chalk
|
|
63
66
|
.hex(entry.colour)
|
|
64
67
|
.bold(`CONTRAST-${count.toString().padStart(3, '0')}`),
|
|
@@ -66,12 +69,15 @@ export function formatScanOutput(scanResults: ScanResultsModel) {
|
|
|
66
69
|
chalk.hex(entry.colour).bold(`[${entry.severity}] ${entry.ruleId}`) +
|
|
67
70
|
entry.message
|
|
68
71
|
]
|
|
69
|
-
|
|
72
|
+
|
|
73
|
+
const codePath = entry.codePath?.replace(/^@/, '')
|
|
74
|
+
|
|
75
|
+
const codeRow = [
|
|
70
76
|
chalk.hex('#F6F5F5').bold(`Code`),
|
|
71
77
|
chalk.hex('#F6F5F5').bold(`:`),
|
|
72
|
-
chalk.hex('#F6F5F5').bold(`${
|
|
78
|
+
chalk.hex('#F6F5F5').bold(`${codePath}`)
|
|
73
79
|
]
|
|
74
|
-
|
|
80
|
+
const issueRow = [chalk.bold(`Issue`), chalk.bold(`:`), `${entry.issue}`]
|
|
75
81
|
|
|
76
82
|
table.push(headerRow, codeRow, issueRow)
|
|
77
83
|
|
|
@@ -118,8 +124,8 @@ function printVulnInfo(projectOverview: any) {
|
|
|
118
124
|
)
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
export function getProjectOverview(
|
|
122
|
-
|
|
127
|
+
export function getProjectOverview(scanResultsInstances: ScanResultsInstances) {
|
|
128
|
+
const acc: any = {
|
|
123
129
|
critical: 0,
|
|
124
130
|
high: 0,
|
|
125
131
|
medium: 0,
|
|
@@ -127,17 +133,22 @@ export function getProjectOverview(content: ResultContent[]) {
|
|
|
127
133
|
note: 0,
|
|
128
134
|
total: 0
|
|
129
135
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
if (
|
|
137
|
+
scanResultsInstances?.content &&
|
|
138
|
+
scanResultsInstances.content.length > 0
|
|
139
|
+
) {
|
|
140
|
+
scanResultsInstances.content.forEach((i: ResultContent) => {
|
|
141
|
+
acc[i.severity.toLowerCase()] += 1
|
|
142
|
+
acc.total += 1
|
|
143
|
+
return acc
|
|
144
|
+
})
|
|
145
|
+
}
|
|
135
146
|
|
|
136
147
|
return acc
|
|
137
148
|
}
|
|
138
149
|
|
|
139
150
|
export function formatLinks(objName: string, entry: any[]) {
|
|
140
|
-
|
|
151
|
+
const line = chalk.bold(objName + ' : ')
|
|
141
152
|
if (entry.length === 1) {
|
|
142
153
|
console.log(line + chalk.hex('#97DCF7').bold.underline(entry[0]))
|
|
143
154
|
} else {
|
|
@@ -207,10 +218,7 @@ export function getCodeFlowInfo(resultEntry: ResultContent) {
|
|
|
207
218
|
}
|
|
208
219
|
|
|
209
220
|
export function stripTags(oldString: string) {
|
|
210
|
-
return oldString
|
|
211
|
-
.replace(/\n/g, ' ')
|
|
212
|
-
.replace(/\s+/g, ' ')
|
|
213
|
-
.trim()
|
|
221
|
+
return oldString.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim()
|
|
214
222
|
}
|
|
215
223
|
|
|
216
224
|
export function assignBySeverity(
|
|
@@ -9,12 +9,12 @@ export class GroupedResultsModel {
|
|
|
9
9
|
issue?: string
|
|
10
10
|
priority?: number
|
|
11
11
|
message?: string | undefined
|
|
12
|
-
colour: string
|
|
13
|
-
codePath?: string
|
|
12
|
+
colour: string
|
|
13
|
+
codePath?: string
|
|
14
14
|
|
|
15
15
|
constructor(ruleId: string) {
|
|
16
16
|
this.ruleId = ruleId
|
|
17
17
|
this.colour = '#999999'
|
|
18
|
-
this.codePathSet = new Set<string>
|
|
18
|
+
this.codePathSet = new Set<string>()
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -4,11 +4,14 @@ export class ScanResultsModel {
|
|
|
4
4
|
projectOverview: ProjectOverview
|
|
5
5
|
scanDetail: ScanDetail
|
|
6
6
|
scanResultsInstances: ScanResultsInstances
|
|
7
|
+
newProject: boolean
|
|
7
8
|
|
|
8
9
|
constructor(scan: any) {
|
|
9
10
|
this.projectOverview = scan.projectOverview as ProjectOverview
|
|
10
11
|
this.scanDetail = scan.scanDetail as ScanDetail
|
|
11
|
-
this.scanResultsInstances =
|
|
12
|
+
this.scanResultsInstances =
|
|
13
|
+
scan.scanResultsInstances as ScanResultsInstances
|
|
14
|
+
this.newProject = scan.newProject
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
17
|
|
|
@@ -49,4 +52,4 @@ export interface ScanDetail {
|
|
|
49
52
|
|
|
50
53
|
export interface ScanResultsInstances {
|
|
51
54
|
content: ResultContent[]
|
|
52
|
-
}
|
|
55
|
+
}
|
|
@@ -8,9 +8,11 @@ const populateProjectId = async config => {
|
|
|
8
8
|
proj = await getExistingProjectIdByName(config, client).then(res => {
|
|
9
9
|
return res
|
|
10
10
|
})
|
|
11
|
+
|
|
12
|
+
return { projectId: proj, isNewProject: false }
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
return proj
|
|
15
|
+
return { projectId: proj, isNewProject: true }
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const createProjectId = async (config, client) => {
|
package/src/scan/scan.ts
CHANGED
|
@@ -40,22 +40,24 @@ export const sendScan = async (config: any) => {
|
|
|
40
40
|
return res.body.id
|
|
41
41
|
} else {
|
|
42
42
|
if (config.debug) {
|
|
43
|
-
console.log(res.statusCode)
|
|
44
43
|
console.log(config)
|
|
44
|
+
oraWrapper.failSpinner(
|
|
45
|
+
startUploadSpinner,
|
|
46
|
+
i18n.__('uploadingScanFail')
|
|
47
|
+
)
|
|
48
|
+
console.log(i18n.__('genericServiceError', res.statusCode))
|
|
45
49
|
}
|
|
46
|
-
oraWrapper.failSpinner(
|
|
47
|
-
startUploadSpinner,
|
|
48
|
-
i18n.__('uploadingScanFail')
|
|
49
|
-
)
|
|
50
50
|
if (res.statusCode === 403) {
|
|
51
51
|
console.log(i18n.__('permissionsError'))
|
|
52
52
|
process.exit(1)
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
oraWrapper.stopSpinner(startUploadSpinner)
|
|
55
|
+
console.log('Contrast Scan Finished')
|
|
55
56
|
process.exit(1)
|
|
56
57
|
}
|
|
57
58
|
})
|
|
58
59
|
.catch(err => {
|
|
60
|
+
oraWrapper.stopSpinner(startUploadSpinner)
|
|
59
61
|
console.log(err)
|
|
60
62
|
})
|
|
61
63
|
}
|
package/src/scan/scanConfig.js
CHANGED
|
@@ -31,11 +31,15 @@ const getScanConfig = argv => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// if no name, take the full file path and use it as the project name
|
|
34
|
+
let projectNameSource
|
|
34
35
|
if (!scanParams.name && scanParams.file) {
|
|
35
36
|
scanParams.name = getFileName(scanParams.file)
|
|
37
|
+
projectNameSource = 'AUTO'
|
|
38
|
+
} else {
|
|
39
|
+
projectNameSource = 'USER'
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
return { ...paramsAuth, ...scanParams }
|
|
42
|
+
return { ...paramsAuth, ...scanParams, projectNameSource }
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
const getFileName = file => {
|
|
@@ -2,7 +2,8 @@ const i18n = require('i18n')
|
|
|
2
2
|
const {
|
|
3
3
|
returnOra,
|
|
4
4
|
startSpinner,
|
|
5
|
-
succeedSpinner
|
|
5
|
+
succeedSpinner,
|
|
6
|
+
stopSpinner
|
|
6
7
|
} = require('../utils/oraWrapper')
|
|
7
8
|
const populateProjectIdAndProjectName = require('./populateProjectIdAndProjectName')
|
|
8
9
|
const scan = require('./scan')
|
|
@@ -28,6 +29,11 @@ const fileAndLanguageLogic = async configToUse => {
|
|
|
28
29
|
console.log(i18n.__('fileNotExist'))
|
|
29
30
|
process.exit(1)
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
if (fileFunctions.fileIsEmpty(configToUse.file)) {
|
|
34
|
+
console.log(i18n.__('scanFileIsEmpty'))
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
31
37
|
return configToUse
|
|
32
38
|
} else {
|
|
33
39
|
if (configToUse.file === undefined || configToUse.file === null) {
|
|
@@ -40,10 +46,15 @@ const startScan = async configToUse => {
|
|
|
40
46
|
const startTime = performance.now()
|
|
41
47
|
await fileAndLanguageLogic(configToUse)
|
|
42
48
|
|
|
49
|
+
let newProject
|
|
50
|
+
|
|
43
51
|
if (!configToUse.projectId) {
|
|
44
|
-
|
|
45
|
-
configToUse
|
|
46
|
-
|
|
52
|
+
const { projectId, isNewProject } =
|
|
53
|
+
await populateProjectIdAndProjectName.populateProjectId(configToUse)
|
|
54
|
+
configToUse.projectId = projectId
|
|
55
|
+
newProject = isNewProject
|
|
56
|
+
} else {
|
|
57
|
+
newProject = false
|
|
47
58
|
}
|
|
48
59
|
const codeArtifactId = await scan.sendScan(configToUse)
|
|
49
60
|
|
|
@@ -53,6 +64,7 @@ const startScan = async configToUse => {
|
|
|
53
64
|
const scanDetail = await scanResults.returnScanResults(
|
|
54
65
|
configToUse,
|
|
55
66
|
codeArtifactId,
|
|
67
|
+
newProject,
|
|
56
68
|
getTimeout(configToUse),
|
|
57
69
|
startScanSpinner
|
|
58
70
|
)
|
|
@@ -64,11 +76,20 @@ const startScan = async configToUse => {
|
|
|
64
76
|
|
|
65
77
|
const endTime = performance.now()
|
|
66
78
|
const scanDurationMs = endTime - startTime
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
if (scanResultsInstances.statusCode !== 200) {
|
|
80
|
+
stopSpinner(startScanSpinner)
|
|
81
|
+
console.log('Result Service is unavailable, please try again later')
|
|
82
|
+
process.exit(1)
|
|
83
|
+
} else {
|
|
84
|
+
succeedSpinner(startScanSpinner, 'Contrast Scan complete')
|
|
85
|
+
console.log(
|
|
86
|
+
`----- Scan completed in ${(scanDurationMs / 1000).toFixed(2)}s -----`
|
|
87
|
+
)
|
|
88
|
+
return {
|
|
89
|
+
scanDetail,
|
|
90
|
+
scanResultsInstances: scanResultsInstances.body
|
|
91
|
+
}
|
|
92
|
+
}
|
|
72
93
|
}
|
|
73
94
|
}
|
|
74
95
|
|
package/src/scan/scanResults.js
CHANGED
|
@@ -3,6 +3,7 @@ const requestUtils = require('../../src/utils/requestUtils')
|
|
|
3
3
|
const oraFunctions = require('../utils/oraWrapper')
|
|
4
4
|
const _ = require('lodash')
|
|
5
5
|
const i18n = require('i18n')
|
|
6
|
+
const oraWrapper = require('../utils/oraWrapper')
|
|
6
7
|
|
|
7
8
|
const getScanId = async (config, codeArtifactId, client) => {
|
|
8
9
|
return client
|
|
@@ -30,11 +31,21 @@ const pollScanResults = async (config, scanId, client) => {
|
|
|
30
31
|
const returnScanResults = async (
|
|
31
32
|
config,
|
|
32
33
|
codeArtifactId,
|
|
34
|
+
newProject,
|
|
33
35
|
timeout,
|
|
34
36
|
startScanSpinner
|
|
35
37
|
) => {
|
|
36
38
|
const client = commonApi.getHttpClient(config)
|
|
37
39
|
let scanId = await getScanId(config, codeArtifactId, client)
|
|
40
|
+
|
|
41
|
+
// send metrics event to sast-event-collector
|
|
42
|
+
if (
|
|
43
|
+
process.env.CODESEC_INVOCATION_ENVIRONMENT &&
|
|
44
|
+
process.env.CODESEC_INVOCATION_ENVIRONMENT.toUpperCase() === 'GITHUB'
|
|
45
|
+
) {
|
|
46
|
+
await client.createNewEvent(config, scanId, newProject)
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
let startTime = new Date()
|
|
39
50
|
let complete = false
|
|
40
51
|
if (!_.isNil(scanId)) {
|
|
@@ -47,23 +58,27 @@ const returnScanResults = async (
|
|
|
47
58
|
}
|
|
48
59
|
if (result.body.status === 'FAILED') {
|
|
49
60
|
complete = true
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
if (config.debug) {
|
|
62
|
+
oraFunctions.failSpinner(
|
|
63
|
+
startScanSpinner,
|
|
64
|
+
i18n.__(
|
|
65
|
+
'scanNotCompleted',
|
|
66
|
+
'https://docs.contrastsecurity.com/en/binary-package-preparation.html'
|
|
67
|
+
)
|
|
55
68
|
)
|
|
56
|
-
|
|
57
|
-
result.body.errorMessage ? console.log(result.body.errorMessage) : ''
|
|
69
|
+
}
|
|
58
70
|
if (
|
|
59
|
-
result
|
|
71
|
+
result?.body?.errorMessage ===
|
|
60
72
|
'Unable to determine language for code artifact'
|
|
61
73
|
) {
|
|
74
|
+
console.log(result.body.errorMessage)
|
|
62
75
|
console.log(
|
|
63
76
|
'Try scanning again using --language param. ',
|
|
64
77
|
i18n.__('scanOptionsLanguageSummary')
|
|
65
78
|
)
|
|
66
79
|
}
|
|
80
|
+
oraWrapper.stopSpinner(startScanSpinner)
|
|
81
|
+
console.log('Contrast Scan Finished')
|
|
67
82
|
process.exit(1)
|
|
68
83
|
}
|
|
69
84
|
}
|
|
@@ -86,10 +101,16 @@ const returnScanResultsInstances = async (config, scanId) => {
|
|
|
86
101
|
try {
|
|
87
102
|
result = await client.getScanResultsInstances(config, scanId)
|
|
88
103
|
if (JSON.stringify(result.statusCode) == 200) {
|
|
89
|
-
return result.body
|
|
104
|
+
return { body: result.body, statusCode: result.statusCode }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (JSON.stringify(result.statusCode) == 503) {
|
|
108
|
+
return { statusCode: result.statusCode }
|
|
90
109
|
}
|
|
91
110
|
} catch (e) {
|
|
92
|
-
|
|
111
|
+
if (config.debug) {
|
|
112
|
+
console.log(e.message.toString())
|
|
113
|
+
}
|
|
93
114
|
}
|
|
94
115
|
}
|
|
95
116
|
|
package/src/utils/commonApi.js
CHANGED
|
@@ -4,7 +4,8 @@ const {
|
|
|
4
4
|
unauthenticatedError,
|
|
5
5
|
forbiddenError,
|
|
6
6
|
proxyError,
|
|
7
|
-
genericError
|
|
7
|
+
genericError,
|
|
8
|
+
maxAppError
|
|
8
9
|
} = require('../common/errorHandling')
|
|
9
10
|
|
|
10
11
|
const handleResponseErrors = (res, api) => {
|
|
@@ -16,6 +17,8 @@ const handleResponseErrors = (res, api) => {
|
|
|
16
17
|
forbiddenError()
|
|
17
18
|
} else if (res.statusCode === 407) {
|
|
18
19
|
proxyError()
|
|
20
|
+
} else if (res.statusCode === 412) {
|
|
21
|
+
maxAppError()
|
|
19
22
|
} else {
|
|
20
23
|
genericError()
|
|
21
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
+
const child_process = require('child_process')
|
|
2
3
|
|
|
3
4
|
function resolveFilePath(filepath) {
|
|
4
5
|
if (filepath[0] === '~') {
|
|
@@ -8,10 +9,13 @@ function resolveFilePath(filepath) {
|
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
const returnProjectPath = () => {
|
|
11
|
-
if (process.
|
|
12
|
+
if (process.platform == 'win32') {
|
|
13
|
+
let winPath = child_process.execSync('cd').toString()
|
|
14
|
+
return winPath.replace(/\//g, '\\').trim()
|
|
15
|
+
} else if (process.env.PWD !== (undefined || null || 'undefined')) {
|
|
12
16
|
return process.env.PWD
|
|
13
17
|
} else {
|
|
14
|
-
return process.argv[process.argv.indexOf('--
|
|
18
|
+
return process.argv[process.argv.indexOf('--file') + 1]
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
|
package/src/utils/oraWrapper.js
CHANGED
|
@@ -8,6 +8,10 @@ const startSpinner = spinner => {
|
|
|
8
8
|
spinner.start()
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
const stopSpinner = spinner => {
|
|
12
|
+
spinner.stop()
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
const succeedSpinner = (spinner, text) => {
|
|
12
16
|
spinner.succeed(text)
|
|
13
17
|
}
|
|
@@ -20,5 +24,6 @@ module.exports = {
|
|
|
20
24
|
returnOra,
|
|
21
25
|
startSpinner,
|
|
22
26
|
succeedSpinner,
|
|
23
|
-
failSpinner
|
|
27
|
+
failSpinner,
|
|
28
|
+
stopSpinner
|
|
24
29
|
}
|