@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
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ReportLibraryModel
|
|
4
4
|
} from '../models/reportLibraryModel'
|
|
5
5
|
import { ReportSeverityModel } from '../models/reportSeverityModel'
|
|
6
|
-
import languageAnalysisEngine from '
|
|
6
|
+
import languageAnalysisEngine from './../../../../constants/constants'
|
|
7
7
|
import {
|
|
8
8
|
CRITICAL_COLOUR,
|
|
9
9
|
CRITICAL_PRIORITY,
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
NOTE_PRIORITY
|
|
18
18
|
} from '../../../../constants/constants'
|
|
19
19
|
import { orderBy } from 'lodash'
|
|
20
|
-
import {SeverityCountModel} from
|
|
20
|
+
import { SeverityCountModel } from '../models/severityCountModel'
|
|
21
|
+
import { ReportModelStructure } from '../models/reportListModel'
|
|
21
22
|
const {
|
|
22
23
|
supportedLanguages: { GO }
|
|
23
24
|
} = languageAnalysisEngine
|
|
@@ -29,19 +30,37 @@ export function findHighestSeverityCVE(cveArray: ReportCVEModel[]) {
|
|
|
29
30
|
return orderBy(mappedToReportSeverityModels, cve => cve?.priority)[0]
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
export function findCVESeveritiesAndOrderByHighestPriority(
|
|
34
|
+
cves: ReportCVEModel[]
|
|
35
|
+
) {
|
|
36
|
+
return orderBy(
|
|
37
|
+
cves.map(cve => findCVESeverity(cve)),
|
|
38
|
+
['priority'],
|
|
39
|
+
['asc']
|
|
40
|
+
)
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export function findCVESeverity(cve: ReportCVEModel) {
|
|
38
44
|
const cveName = cve.name as string
|
|
39
45
|
if (cve.cvss3SeverityCode === 'CRITICAL' || cve.severityCode === 'CRITICAL') {
|
|
40
|
-
return new ReportSeverityModel(
|
|
46
|
+
return new ReportSeverityModel(
|
|
47
|
+
'CRITICAL',
|
|
48
|
+
CRITICAL_PRIORITY,
|
|
49
|
+
CRITICAL_COLOUR,
|
|
50
|
+
cveName
|
|
51
|
+
)
|
|
41
52
|
} else if (cve.cvss3SeverityCode === 'HIGH' || cve.severityCode === 'HIGH') {
|
|
42
53
|
return new ReportSeverityModel('HIGH', HIGH_PRIORITY, HIGH_COLOUR, cveName)
|
|
43
|
-
} else if (
|
|
44
|
-
|
|
54
|
+
} else if (
|
|
55
|
+
cve.cvss3SeverityCode === 'MEDIUM' ||
|
|
56
|
+
cve.severityCode === 'MEDIUM'
|
|
57
|
+
) {
|
|
58
|
+
return new ReportSeverityModel(
|
|
59
|
+
'MEDIUM',
|
|
60
|
+
MEDIUM_PRIORITY,
|
|
61
|
+
MEDIUM_COLOUR,
|
|
62
|
+
cveName
|
|
63
|
+
)
|
|
45
64
|
} else if (cve.cvss3SeverityCode === 'LOW' || cve.severityCode === 'LOW') {
|
|
46
65
|
return new ReportSeverityModel('LOW', LOW_PRIORITY, LOW_COLOUR, cveName)
|
|
47
66
|
} else if (cve.cvss3SeverityCode === 'NOTE' || cve.severityCode === 'NOTE') {
|
|
@@ -49,49 +68,47 @@ export function findCVESeverity(cve: ReportCVEModel) {
|
|
|
49
68
|
}
|
|
50
69
|
}
|
|
51
70
|
|
|
52
|
-
export function
|
|
71
|
+
export function convertGenericToTypedLibraryVulns(libraries: any) {
|
|
53
72
|
return Object.entries(libraries).map(([name, cveArray]) => {
|
|
54
73
|
return new ReportLibraryModel(name, cveArray as ReportCVEModel[])
|
|
55
74
|
})
|
|
56
75
|
}
|
|
57
76
|
|
|
58
|
-
export function severityCountAllLibraries(
|
|
77
|
+
export function severityCountAllLibraries(
|
|
78
|
+
vulnerableLibraries: ReportLibraryModel[]
|
|
79
|
+
) {
|
|
59
80
|
const severityCount = new SeverityCountModel()
|
|
60
|
-
vulnerableLibraries.forEach(lib =>
|
|
81
|
+
vulnerableLibraries.forEach(lib =>
|
|
82
|
+
severityCountAllCVEs(lib.cveArray, severityCount)
|
|
83
|
+
)
|
|
61
84
|
return severityCount
|
|
62
85
|
}
|
|
63
86
|
|
|
64
|
-
export function severityCountAllCVEs(
|
|
87
|
+
export function severityCountAllCVEs(
|
|
88
|
+
cveArray: ReportCVEModel[],
|
|
89
|
+
severityCount: SeverityCountModel
|
|
90
|
+
) {
|
|
65
91
|
const severityCountInner = severityCount
|
|
66
92
|
cveArray.forEach(cve => severityCountSingleCVE(cve, severityCountInner))
|
|
67
93
|
return severityCountInner
|
|
68
94
|
}
|
|
69
95
|
|
|
70
|
-
export function severityCountSingleCVE(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
) {
|
|
96
|
+
export function severityCountSingleCVE(
|
|
97
|
+
cve: ReportCVEModel,
|
|
98
|
+
severityCount: SeverityCountModel
|
|
99
|
+
) {
|
|
100
|
+
if (cve.cvss3SeverityCode === 'CRITICAL' || cve.severityCode === 'CRITICAL') {
|
|
75
101
|
severityCount.critical += 1
|
|
76
|
-
} else if (
|
|
77
|
-
cve.cvss3SeverityCode === 'HIGH' ||
|
|
78
|
-
cve.severityCode === 'HIGH'
|
|
79
|
-
) {
|
|
102
|
+
} else if (cve.cvss3SeverityCode === 'HIGH' || cve.severityCode === 'HIGH') {
|
|
80
103
|
severityCount.high += 1
|
|
81
104
|
} else if (
|
|
82
105
|
cve.cvss3SeverityCode === 'MEDIUM' ||
|
|
83
106
|
cve.severityCode === 'MEDIUM'
|
|
84
107
|
) {
|
|
85
108
|
severityCount.medium += 1
|
|
86
|
-
} else if (
|
|
87
|
-
cve.cvss3SeverityCode === 'LOW' ||
|
|
88
|
-
cve.severityCode === 'LOW'
|
|
89
|
-
) {
|
|
109
|
+
} else if (cve.cvss3SeverityCode === 'LOW' || cve.severityCode === 'LOW') {
|
|
90
110
|
severityCount.low += 1
|
|
91
|
-
} else if (
|
|
92
|
-
cve.cvss3SeverityCode === 'NOTE' ||
|
|
93
|
-
cve.severityCode === 'NOTE'
|
|
94
|
-
) {
|
|
111
|
+
} else if (cve.cvss3SeverityCode === 'NOTE' || cve.severityCode === 'NOTE') {
|
|
95
112
|
severityCount.note += 1
|
|
96
113
|
}
|
|
97
114
|
|
|
@@ -106,11 +123,49 @@ export function findNameAndVersion(library: ReportLibraryModel, config: any) {
|
|
|
106
123
|
|
|
107
124
|
return { name, version }
|
|
108
125
|
} else {
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
const
|
|
126
|
+
//spreads items from split into set so no duplicates appear
|
|
127
|
+
const uniqueSplitLibraryName = [...new Set(library.name.split('/'))]
|
|
128
|
+
const nameVersion = uniqueSplitLibraryName[1].split('@')
|
|
129
|
+
|
|
130
|
+
let parentLibrary
|
|
131
|
+
let name
|
|
132
|
+
if (
|
|
133
|
+
uniqueSplitLibraryName[0] !== 'null' &&
|
|
134
|
+
uniqueSplitLibraryName[0] !== '' &&
|
|
135
|
+
!uniqueSplitLibraryName[1].includes(uniqueSplitLibraryName[0])
|
|
136
|
+
) {
|
|
137
|
+
//if the parent lib (element 0) is not null, not blank and not already part of the library name
|
|
138
|
+
//e.g. shared-ini-file-loader-1.0.0-rc.3 is very generic - converts to @aws-sdk/shared-ini-file-loader-1.0.0-rc.3
|
|
139
|
+
parentLibrary = uniqueSplitLibraryName[0]
|
|
140
|
+
name = `${parentLibrary}/${nameVersion[0]}`
|
|
141
|
+
} else {
|
|
142
|
+
name = nameVersion[0]
|
|
143
|
+
}
|
|
144
|
+
|
|
112
145
|
const version = nameVersion[1]
|
|
113
146
|
|
|
114
147
|
return { name, version }
|
|
115
148
|
}
|
|
116
149
|
}
|
|
150
|
+
|
|
151
|
+
export function countVulnerableLibrariesBySeverity(
|
|
152
|
+
reportModelStructure: ReportModelStructure[]
|
|
153
|
+
) {
|
|
154
|
+
const severityCount = new SeverityCountModel()
|
|
155
|
+
reportModelStructure.forEach(vuln => {
|
|
156
|
+
const currentSeverity = vuln.compositeKey.highestSeverity.severity
|
|
157
|
+
if (currentSeverity === 'CRITICAL') {
|
|
158
|
+
severityCount.critical += 1
|
|
159
|
+
} else if (currentSeverity === 'HIGH') {
|
|
160
|
+
severityCount.high += 1
|
|
161
|
+
} else if (currentSeverity === 'MEDIUM') {
|
|
162
|
+
severityCount.medium += 1
|
|
163
|
+
} else if (currentSeverity === 'LOW') {
|
|
164
|
+
severityCount.low += 1
|
|
165
|
+
} else if (currentSeverity === 'NOTE') {
|
|
166
|
+
severityCount.note += 1
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
return severityCount
|
|
171
|
+
}
|
|
@@ -1,31 +1,80 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
appID: analysis.config.applicationId,
|
|
9
|
-
cliVersion: APP_VERSION,
|
|
10
|
-
snapshot: { [analysisLanguage]: analysis[analysisLanguage] }
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const client = getHttpClient(analysis.config)
|
|
1
|
+
const commonApi = require('../../utils/commonApi')
|
|
2
|
+
const _ = require('lodash')
|
|
3
|
+
const oraFunctions = require('../../utils/oraWrapper')
|
|
4
|
+
const i18n = require('i18n')
|
|
5
|
+
const oraWrapper = require('../../utils/oraWrapper')
|
|
6
|
+
const requestUtils = require('../../utils/requestUtils')
|
|
7
|
+
const { performance } = require('perf_hooks')
|
|
14
8
|
|
|
9
|
+
const pollSnapshotResults = async (config, snapshotId, client) => {
|
|
10
|
+
await requestUtils.sleep(5000)
|
|
15
11
|
return client
|
|
16
|
-
.
|
|
12
|
+
.getReportStatusById(config, snapshotId)
|
|
17
13
|
.then(res => {
|
|
18
|
-
|
|
19
|
-
return res.body
|
|
20
|
-
} else {
|
|
21
|
-
handleResponseErrors(res, 'snapshot')
|
|
22
|
-
}
|
|
14
|
+
return res
|
|
23
15
|
})
|
|
24
16
|
.catch(err => {
|
|
25
17
|
console.log(err)
|
|
26
18
|
})
|
|
27
19
|
}
|
|
28
20
|
|
|
21
|
+
const getTimeout = config => {
|
|
22
|
+
if (config.timeout) {
|
|
23
|
+
return config.timeout
|
|
24
|
+
} else {
|
|
25
|
+
if (config.verbose) {
|
|
26
|
+
console.log('Timeout set to 5 minutes')
|
|
27
|
+
}
|
|
28
|
+
return 300
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const pollForSnapshotCompletition = async (
|
|
33
|
+
config,
|
|
34
|
+
snapshotId,
|
|
35
|
+
reportSpinner
|
|
36
|
+
) => {
|
|
37
|
+
const client = commonApi.getHttpClient(config)
|
|
38
|
+
const startTime = performance.now()
|
|
39
|
+
const timeout = getTimeout(config)
|
|
40
|
+
|
|
41
|
+
let complete = false
|
|
42
|
+
if (!_.isNil(snapshotId)) {
|
|
43
|
+
while (!complete) {
|
|
44
|
+
let result = await pollSnapshotResults(config, snapshotId, client)
|
|
45
|
+
if (result.statusCode === 200) {
|
|
46
|
+
if (result.body.status === 'PROCESSED') {
|
|
47
|
+
complete = true
|
|
48
|
+
return result.body
|
|
49
|
+
}
|
|
50
|
+
if (result.body.status === 'FAILED') {
|
|
51
|
+
complete = true
|
|
52
|
+
if (config.debug) {
|
|
53
|
+
oraFunctions.failSpinner(
|
|
54
|
+
reportSpinner,
|
|
55
|
+
i18n.__('auditNotCompleted')
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
console.log(result.body.errorMessage)
|
|
59
|
+
oraWrapper.stopSpinner(reportSpinner)
|
|
60
|
+
console.log('Contrast audit finished')
|
|
61
|
+
process.exit(1)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const endTime = performance.now() - startTime
|
|
65
|
+
if (requestUtils.millisToSeconds(endTime) > timeout) {
|
|
66
|
+
oraFunctions.failSpinner(
|
|
67
|
+
reportSpinner,
|
|
68
|
+
'Contrast audit timed out at the specified timeout of ' +
|
|
69
|
+
timeout +
|
|
70
|
+
' seconds.'
|
|
71
|
+
)
|
|
72
|
+
throw new Error('You can update the timeout using --timeout')
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
29
78
|
module.exports = {
|
|
30
|
-
|
|
79
|
+
pollForSnapshotCompletition: pollForSnapshotCompletition
|
|
31
80
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const i18n = require('i18n')
|
|
3
|
+
const chalk = require('chalk')
|
|
4
|
+
const save = require('../commands/audit/saveFile')
|
|
5
|
+
const sbom = require('../sbom/generateSbom')
|
|
6
|
+
const {
|
|
7
|
+
SBOM_CYCLONE_DX_FILE,
|
|
8
|
+
SBOM_SPDX_FILE
|
|
9
|
+
} = require('../constants/constants')
|
|
10
|
+
|
|
11
|
+
async function auditSave(config) {
|
|
12
|
+
let fileFormat
|
|
13
|
+
switch (config.save) {
|
|
14
|
+
case null:
|
|
15
|
+
case SBOM_CYCLONE_DX_FILE:
|
|
16
|
+
fileFormat = SBOM_CYCLONE_DX_FILE
|
|
17
|
+
break
|
|
18
|
+
case SBOM_SPDX_FILE:
|
|
19
|
+
fileFormat = SBOM_SPDX_FILE
|
|
20
|
+
break
|
|
21
|
+
default:
|
|
22
|
+
break
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (fileFormat) {
|
|
26
|
+
save.saveFile(
|
|
27
|
+
config,
|
|
28
|
+
fileFormat,
|
|
29
|
+
await sbom.generateSbom(config, fileFormat)
|
|
30
|
+
)
|
|
31
|
+
const filename = `${config.applicationId}-sbom-${fileFormat}.json`
|
|
32
|
+
if (fs.existsSync(filename)) {
|
|
33
|
+
console.log(i18n.__('auditSBOMSaveSuccess') + ` - ${filename}`)
|
|
34
|
+
} else {
|
|
35
|
+
console.log(
|
|
36
|
+
chalk.yellow.bold(
|
|
37
|
+
`\n Unable to save ${filename} Software Bill of Materials (SBOM)`
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
console.log(i18n.__('auditBadFiletypeSpecifiedForSave'))
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
auditSave
|
|
48
|
+
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import paramHandler from '../../utils/paramsUtil/paramHandler'
|
|
2
2
|
import constants from '../../constants'
|
|
3
3
|
import cliOptions from '../../utils/parsedCLIOptions'
|
|
4
|
-
import languageAnalysisEngine from '../../audit/languageAnalysisEngine/constants'
|
|
5
|
-
import {
|
|
6
|
-
determineProjectLanguage,
|
|
7
|
-
identifyLanguages
|
|
8
|
-
} from '../../audit/autodetection/autoDetectLanguage'
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
supportedLanguages: { NODE, JAVASCRIPT }
|
|
12
|
-
} = languageAnalysisEngine
|
|
13
4
|
|
|
14
5
|
export const getAuditConfig = (argv: string[]): { [key: string]: string } => {
|
|
15
6
|
const auditParameters = cliOptions.getCommandLineArgsCustom(
|
|
@@ -18,22 +9,6 @@ export const getAuditConfig = (argv: string[]): { [key: string]: string } => {
|
|
|
18
9
|
)
|
|
19
10
|
const paramsAuth = paramHandler.getAuth(auditParameters)
|
|
20
11
|
|
|
21
|
-
if (
|
|
22
|
-
auditParameters.language === undefined ||
|
|
23
|
-
auditParameters.language === null
|
|
24
|
-
) {
|
|
25
|
-
try {
|
|
26
|
-
auditParameters.language = determineProjectLanguage(
|
|
27
|
-
identifyLanguages(auditParameters)
|
|
28
|
-
)
|
|
29
|
-
} catch (err: any) {
|
|
30
|
-
console.log(err.message)
|
|
31
|
-
process.exit(1)
|
|
32
|
-
}
|
|
33
|
-
} else if (auditParameters.language.toUpperCase() === JAVASCRIPT) {
|
|
34
|
-
auditParameters.language = NODE.toLowerCase()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
12
|
// @ts-ignore
|
|
38
13
|
return { ...paramsAuth, ...auditParameters }
|
|
39
14
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { catalogueApplication } from '../../audit/catalogueApplication/catalogueApplication'
|
|
2
2
|
import commonApi from '../../audit/languageAnalysisEngine/commonApi'
|
|
3
3
|
|
|
4
|
-
const identifyLanguageAE = require('./../../audit/languageAnalysisEngine')
|
|
5
|
-
const languageFactory = require('../../audit/languageAnalysisEngine/languageAnalysisFactory')
|
|
6
|
-
const { v4: uuidv4 } = require('uuid')
|
|
7
|
-
|
|
8
4
|
export const dealWithNoAppId = async (config: { [x: string]: string }) => {
|
|
9
5
|
let appID: string
|
|
10
6
|
try {
|
|
@@ -14,14 +10,15 @@ export const dealWithNoAppId = async (config: { [x: string]: string }) => {
|
|
|
14
10
|
return await catalogueApplication(config)
|
|
15
11
|
}
|
|
16
12
|
if (!appID && !config.applicationName) {
|
|
17
|
-
config.applicationName =
|
|
18
|
-
|
|
13
|
+
config.applicationName = getAppName(config.file) as string
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
appID = await commonApi.returnAppId(config)
|
|
16
|
+
if (!appID) {
|
|
17
|
+
return await catalogueApplication(config)
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
} catch (e) {
|
|
22
|
-
// @ts-ignore
|
|
20
|
+
} catch (e: any) {
|
|
23
21
|
if (e.toString().includes('tunneling socket could not be established')) {
|
|
24
|
-
// @ts-ignore
|
|
25
22
|
console.log(e.message.toString())
|
|
26
23
|
console.log(
|
|
27
24
|
'There seems to be an issue with your proxy, please check and try again'
|
|
@@ -32,15 +29,16 @@ export const dealWithNoAppId = async (config: { [x: string]: string }) => {
|
|
|
32
29
|
return appID
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
export const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
export const getAppName = (file: string) => {
|
|
33
|
+
const last = file.charAt(file.length - 1)
|
|
34
|
+
if (last !== '/') {
|
|
35
|
+
return file.split('/').pop()
|
|
36
|
+
} else {
|
|
37
|
+
const str = removeLastChar(file)
|
|
38
|
+
return str.split('/').pop()
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
config
|
|
45
|
-
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const removeLastChar = (str: string) => {
|
|
43
|
+
return str.substring(0, str.length - 1)
|
|
46
44
|
}
|
|
@@ -13,35 +13,41 @@ const auditUsageGuide = commandLineUsage([
|
|
|
13
13
|
'{bold ' +
|
|
14
14
|
i18n.__('constantsAuditPrerequisitesContentSupportedLanguages') +
|
|
15
15
|
'}',
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
'',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'',
|
|
24
|
-
'{bold ' +
|
|
25
|
-
i18n.__('constantsAuditPrerequisitesContentDotNet') +
|
|
26
|
-
'}' +
|
|
27
|
-
i18n.__('constantsAuditPrerequisitesContentDotNetMessage'),
|
|
28
|
-
'{bold ' +
|
|
29
|
-
i18n.__('constantsAuditPrerequisitesContentLanguageNode') +
|
|
30
|
-
'}' +
|
|
31
|
-
i18n.__('constantsAuditPrerequisitesContentLanguageNodeMessage'),
|
|
32
|
-
'{bold ' +
|
|
33
|
-
i18n.__('constantsAuditPrerequisitesContentLanguageRuby') +
|
|
34
|
-
'}' +
|
|
35
|
-
i18n.__('constantsAuditPrerequisitesContentLanguageRubyMessage'),
|
|
36
|
-
'{bold ' +
|
|
37
|
-
i18n.__('constantsAuditPrerequisitesContentLanguagePython') +
|
|
38
|
-
'}' +
|
|
39
|
-
i18n.__('constantsAuditPrerequisitesContentLanguagePythonMessage')
|
|
16
|
+
i18n.__('constantsAuditPrerequisitesJavaContentMessage'),
|
|
17
|
+
i18n.__('constantsAuditPrerequisitesContentDotNetMessage'),
|
|
18
|
+
i18n.__('constantsAuditPrerequisitesContentNodeMessage'),
|
|
19
|
+
i18n.__('constantsAuditPrerequisitesContentRubyMessage'),
|
|
20
|
+
i18n.__('constantsAuditPrerequisitesContentPythonMessage'),
|
|
21
|
+
i18n.__('constantsAuditPrerequisitesContentGoMessage'),
|
|
22
|
+
i18n.__('constantsAuditPrerequisitesContentPHPMessage')
|
|
40
23
|
]
|
|
41
24
|
},
|
|
42
25
|
{
|
|
43
26
|
header: i18n.__('constantsAuditOptions'),
|
|
44
|
-
optionList: constants.commandLineDefinitions.auditOptionDefinitions
|
|
27
|
+
optionList: constants.commandLineDefinitions.auditOptionDefinitions,
|
|
28
|
+
hide: [
|
|
29
|
+
'application-id',
|
|
30
|
+
'application-name',
|
|
31
|
+
'organization-id',
|
|
32
|
+
'api-key',
|
|
33
|
+
'authorization',
|
|
34
|
+
'host',
|
|
35
|
+
'proxy',
|
|
36
|
+
'help',
|
|
37
|
+
'ff',
|
|
38
|
+
'ignore-cert-errors',
|
|
39
|
+
'verbose',
|
|
40
|
+
'debug',
|
|
41
|
+
'experimental',
|
|
42
|
+
'tags',
|
|
43
|
+
'sub-project',
|
|
44
|
+
'code',
|
|
45
|
+
'maven-settings-path',
|
|
46
|
+
'language',
|
|
47
|
+
'experimental',
|
|
48
|
+
'app-groups',
|
|
49
|
+
'metadata'
|
|
50
|
+
]
|
|
45
51
|
}
|
|
46
52
|
])
|
|
47
53
|
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { startAudit } from './auditController'
|
|
2
1
|
import { getAuditConfig } from './auditConfig'
|
|
3
2
|
import { auditUsageGuide } from './help'
|
|
3
|
+
import { processSca } from '../scan/sca/scaAnalysis'
|
|
4
4
|
|
|
5
5
|
export type parameterInput = string[]
|
|
6
6
|
|
|
7
7
|
export const processAudit = async (argv: parameterInput) => {
|
|
8
8
|
if (argv.indexOf('--help') != -1) {
|
|
9
9
|
printHelpMessage()
|
|
10
|
-
process.exit(
|
|
10
|
+
process.exit(0)
|
|
11
11
|
}
|
|
12
12
|
const config = getAuditConfig(argv)
|
|
13
|
-
|
|
14
|
-
// console.log(config)
|
|
15
|
-
|
|
16
|
-
const auditResults = await startAudit(config)
|
|
13
|
+
await processSca(config)
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
const printHelpMessage = () => {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
const fileName = `${config.applicationId}-sbom
|
|
3
|
+
export const saveFile = (config: any, type: string, rawResults: any) => {
|
|
4
|
+
const fileName = `${config.applicationId}-sbom-${type}.json`
|
|
5
5
|
fs.writeFileSync(fileName, JSON.stringify(rawResults))
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
saveFile
|
|
10
|
+
}
|