@contrast/contrast 1.0.3 → 1.0.6
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 +4 -0
- package/README.md +20 -14
- package/dist/audit/autodetection/autoDetectLanguage.js +32 -0
- package/dist/audit/catalogueApplication/catalogueApplication.js +2 -11
- package/dist/audit/languageAnalysisEngine/{langugageAnalysisFactory.js → languageAnalysisFactory.js} +6 -14
- package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +29 -0
- package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +101 -234
- package/dist/audit/languageAnalysisEngine/report/models/reportLibraryModel.js +19 -0
- package/dist/audit/languageAnalysisEngine/report/models/reportListModel.js +24 -0
- package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +24 -0
- package/dist/audit/languageAnalysisEngine/report/models/reportSeverityModel.js +12 -0
- package/dist/audit/languageAnalysisEngine/report/models/severityCountModel.js +13 -0
- package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +24 -129
- package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +99 -0
- package/dist/audit/languageAnalysisEngine/sendSnapshot.js +2 -14
- package/dist/commands/audit/auditConfig.js +8 -2
- package/dist/commands/audit/auditController.js +14 -5
- package/dist/commands/scan/processScan.js +10 -6
- package/dist/commands/scan/sca/scaAnalysis.js +49 -0
- package/dist/common/HTTPClient.js +18 -26
- package/dist/common/errorHandling.js +7 -17
- package/dist/common/versionChecker.js +14 -12
- package/dist/constants/constants.js +24 -2
- package/dist/constants/lambda.js +3 -1
- package/dist/constants/locales.js +42 -42
- package/dist/constants.js +25 -1
- package/dist/index.js +2 -2
- package/dist/lambda/help.js +22 -14
- package/dist/lambda/lambda.js +6 -0
- package/dist/scaAnalysis/common/formatMessage.js +19 -0
- package/dist/scaAnalysis/common/treeUpload.js +29 -0
- package/dist/scaAnalysis/go/goAnalysis.js +17 -0
- package/dist/scaAnalysis/go/goParseDeps.js +158 -0
- package/dist/scaAnalysis/go/goReadDepFile.js +23 -0
- package/dist/scaAnalysis/java/analysis.js +108 -0
- package/dist/scaAnalysis/java/index.js +18 -0
- package/dist/scaAnalysis/java/javaBuildDepsParser.js +339 -0
- package/dist/scan/autoDetection.js +46 -1
- package/dist/scan/fileUtils.js +73 -1
- package/dist/scan/formatScanOutput.js +215 -0
- package/dist/scan/help.js +3 -1
- package/dist/scan/models/groupedResultsModel.js +11 -0
- package/dist/scan/models/resultContentModel.js +2 -0
- package/dist/scan/models/scanResultsModel.js +11 -0
- package/dist/scan/scan.js +27 -126
- package/dist/scan/scanConfig.js +1 -1
- package/dist/scan/scanController.js +11 -5
- package/dist/scan/scanResults.js +15 -19
- package/dist/utils/getConfig.js +3 -0
- package/dist/utils/oraWrapper.js +5 -1
- package/package.json +3 -2
- package/src/audit/autodetection/autoDetectLanguage.ts +40 -0
- package/src/audit/catalogueApplication/catalogueApplication.js +4 -16
- package/src/audit/languageAnalysisEngine/{langugageAnalysisFactory.js → languageAnalysisFactory.js} +11 -21
- package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +72 -0
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +204 -0
- package/src/audit/languageAnalysisEngine/report/models/reportLibraryModel.ts +30 -0
- package/src/audit/languageAnalysisEngine/report/models/reportListModel.ts +32 -0
- package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +29 -0
- package/src/audit/languageAnalysisEngine/report/models/reportSeverityModel.ts +13 -0
- package/src/audit/languageAnalysisEngine/report/models/severityCountModel.ts +16 -0
- package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +56 -0
- package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +116 -0
- package/src/audit/languageAnalysisEngine/sendSnapshot.js +2 -22
- package/src/commands/audit/auditConfig.ts +12 -3
- package/src/commands/audit/auditController.ts +20 -5
- package/src/commands/audit/processAudit.ts +3 -0
- package/src/commands/scan/processScan.js +13 -9
- package/src/commands/scan/sca/scaAnalysis.js +75 -0
- package/src/common/HTTPClient.js +31 -38
- package/src/common/errorHandling.ts +7 -25
- package/src/common/versionChecker.ts +24 -22
- package/src/constants/constants.js +24 -2
- package/src/constants/lambda.js +3 -1
- package/src/constants/locales.js +47 -56
- package/src/constants.js +29 -1
- package/src/index.ts +2 -3
- package/src/lambda/help.ts +22 -14
- package/src/lambda/lambda.ts +8 -0
- package/src/scaAnalysis/common/formatMessage.js +20 -0
- package/src/scaAnalysis/common/treeUpload.js +30 -0
- package/src/scaAnalysis/go/goAnalysis.js +20 -0
- package/src/scaAnalysis/go/goParseDeps.js +203 -0
- package/src/scaAnalysis/go/goReadDepFile.js +32 -0
- package/src/scaAnalysis/java/analysis.js +143 -0
- package/src/scaAnalysis/java/index.js +21 -0
- package/src/scaAnalysis/java/javaBuildDepsParser.js +404 -0
- package/src/scan/autoDetection.js +54 -1
- package/src/scan/fileUtils.js +91 -1
- package/src/scan/formatScanOutput.ts +250 -0
- package/src/scan/help.js +3 -1
- package/src/scan/models/groupedResultsModel.ts +20 -0
- package/src/scan/models/resultContentModel.ts +86 -0
- package/src/scan/models/scanResultsModel.ts +52 -0
- package/src/scan/scan.ts +63 -0
- package/src/scan/scanConfig.js +1 -1
- package/src/scan/scanController.js +15 -7
- package/src/scan/scanResults.js +21 -18
- package/src/utils/getConfig.ts +10 -0
- package/src/utils/oraWrapper.js +6 -1
- package/dist/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +0 -17
- package/dist/audit/languageAnalysisEngine/report/newReportingFeature.js +0 -81
- package/src/audit/languageAnalysisEngine/report/checkIgnoreDevDep.js +0 -27
- package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.js +0 -303
- package/src/audit/languageAnalysisEngine/report/newReportingFeature.js +0 -124
- package/src/audit/languageAnalysisEngine/report/reportingFeature.js +0 -190
- package/src/scan/scan.js +0 -195
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
const crypto = require('crypto')
|
|
2
|
+
|
|
3
|
+
const parseGoDependencies = goDeps => {
|
|
4
|
+
return parseGo(goDeps)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const parseGo = modGraphOutput => {
|
|
8
|
+
let splitLines = splitAllLinesIntoArray(modGraphOutput)
|
|
9
|
+
const directDepNames = getDirectDepNames(splitLines)
|
|
10
|
+
const uniqueTransitiveDepNames = getAllUniqueTransitiveDepNames(
|
|
11
|
+
splitLines,
|
|
12
|
+
directDepNames
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
let rootNodes = createRootNodes(splitLines)
|
|
16
|
+
|
|
17
|
+
createTransitiveDeps(uniqueTransitiveDepNames, splitLines, rootNodes)
|
|
18
|
+
|
|
19
|
+
return rootNodes
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const splitAllLinesIntoArray = modGraphOutput => {
|
|
23
|
+
return modGraphOutput.split(/\r\n|\r|\n/)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const getAllDepsOfADepAsEdge = (dep, deps) => {
|
|
27
|
+
let edges = {}
|
|
28
|
+
|
|
29
|
+
const depRows = deps.filter(line => {
|
|
30
|
+
return line.startsWith(dep)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
depRows.forEach(dep => {
|
|
34
|
+
const edgeName = dep.split(' ')[1]
|
|
35
|
+
edges[edgeName] = edgeName
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return edges
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const getAllDepsOfADepAsName = (dep, deps) => {
|
|
42
|
+
let edges = []
|
|
43
|
+
|
|
44
|
+
const depRows = deps.filter(line => {
|
|
45
|
+
return line.startsWith(dep)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
depRows.forEach(dep => {
|
|
49
|
+
const edgeName = dep.split(' ')[1]
|
|
50
|
+
edges.push(edgeName)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return edges
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const createRootNodes = deps => {
|
|
57
|
+
let rootDep = {}
|
|
58
|
+
const rootDeps = getRootDeps(deps)
|
|
59
|
+
|
|
60
|
+
const edges = rootDeps.map(dep => {
|
|
61
|
+
return dep.split(' ')[1]
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
rootDep[rootDeps[0].split(' ')[0]] = {}
|
|
65
|
+
|
|
66
|
+
edges.forEach(edge => {
|
|
67
|
+
const splitEdge = edge.split('@')
|
|
68
|
+
const splitGroupName = splitEdge[0].split('/')
|
|
69
|
+
const name = splitGroupName.pop()
|
|
70
|
+
const lastSlash = splitEdge[0].lastIndexOf('/')
|
|
71
|
+
let group = splitEdge[0].substring(0, lastSlash)
|
|
72
|
+
const hash = getHash(splitEdge[0])
|
|
73
|
+
|
|
74
|
+
group = checkGroupExists(group, name)
|
|
75
|
+
|
|
76
|
+
//get the edges of the root dependency
|
|
77
|
+
const edgesOfDep = getAllDepsOfADepAsEdge(edge, deps)
|
|
78
|
+
|
|
79
|
+
rootDep[rootDeps[0].split(' ')[0]][edge] = {
|
|
80
|
+
artifactID: name,
|
|
81
|
+
group: group,
|
|
82
|
+
version: splitEdge[1],
|
|
83
|
+
scope: '"compile',
|
|
84
|
+
type: 'direct',
|
|
85
|
+
hash: hash,
|
|
86
|
+
edges: edgesOfDep
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
return rootDep
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const getRootDeps = deps => {
|
|
93
|
+
const rootDeps = deps.filter(dep => {
|
|
94
|
+
const parentDep = dep.split(' ')[0]
|
|
95
|
+
if (parentDep.split('@v').length === 1) {
|
|
96
|
+
return dep
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
return rootDeps
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const getHash = library => {
|
|
103
|
+
let shaSum = crypto.createHash('sha1')
|
|
104
|
+
shaSum.update(library)
|
|
105
|
+
return shaSum.digest('hex')
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const getDirectDepNames = deps => {
|
|
109
|
+
const directDepNames = []
|
|
110
|
+
|
|
111
|
+
deps.forEach(dep => {
|
|
112
|
+
const parentDep = dep.split(' ')[0]
|
|
113
|
+
if (parentDep.split('@v').length === 1) {
|
|
114
|
+
dep.split(' ')[1] !== undefined
|
|
115
|
+
? directDepNames.push(dep.split(' ')[1])
|
|
116
|
+
: null
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
return directDepNames
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const getAllUniqueTransitiveDepNames = (deps, directDepNames) => {
|
|
123
|
+
let uniqueDeps = []
|
|
124
|
+
|
|
125
|
+
deps.forEach(dep => {
|
|
126
|
+
const parentDep = dep.split(' ')[0]
|
|
127
|
+
if (parentDep.split('@v').length !== 1) {
|
|
128
|
+
if (!directDepNames.includes(parentDep)) {
|
|
129
|
+
if (!uniqueDeps.includes(parentDep)) {
|
|
130
|
+
parentDep.length > 1 ? uniqueDeps.push(parentDep) : null
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
return uniqueDeps
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const checkGroupExists = (group, name) => {
|
|
139
|
+
if (group === null || group === '') {
|
|
140
|
+
return name
|
|
141
|
+
}
|
|
142
|
+
return group
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const createTransitiveDeps = (transitiveDeps, splitLines, rootNodes) => {
|
|
146
|
+
transitiveDeps.forEach(dep => {
|
|
147
|
+
//create transitive dep
|
|
148
|
+
const splitEdge = dep.split('@')
|
|
149
|
+
const splitGroupName = splitEdge[0].split('/')
|
|
150
|
+
const name = splitGroupName.pop()
|
|
151
|
+
const lastSlash = splitEdge[0].lastIndexOf('/')
|
|
152
|
+
let group = splitEdge[0].substring(0, lastSlash)
|
|
153
|
+
const hash = getHash(splitEdge[0])
|
|
154
|
+
|
|
155
|
+
group = checkGroupExists(group, name)
|
|
156
|
+
|
|
157
|
+
const transitiveDep = {
|
|
158
|
+
artifactID: name,
|
|
159
|
+
group: group,
|
|
160
|
+
version: splitEdge[1],
|
|
161
|
+
scope: 'compile',
|
|
162
|
+
type: 'transitive',
|
|
163
|
+
hash: hash,
|
|
164
|
+
edges: {}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
//add edges to transitiveDep
|
|
168
|
+
const edges = getAllDepsOfADepAsEdge(dep, splitLines)
|
|
169
|
+
transitiveDep.edges = edges
|
|
170
|
+
|
|
171
|
+
//add all edges as a transitive dependency to rootNodes
|
|
172
|
+
const edgesAsName = getAllDepsOfADepAsName(dep, splitLines)
|
|
173
|
+
|
|
174
|
+
edgesAsName.forEach(dep => {
|
|
175
|
+
const splitEdge = dep.split('@')
|
|
176
|
+
const splitGroupName = splitEdge[0].split('/')
|
|
177
|
+
const name = splitGroupName.pop()
|
|
178
|
+
const lastSlash = splitEdge[0].lastIndexOf('/')
|
|
179
|
+
let group = splitEdge[0].substring(0, lastSlash)
|
|
180
|
+
const hash = getHash(splitEdge[0])
|
|
181
|
+
|
|
182
|
+
group = checkGroupExists(group, name)
|
|
183
|
+
|
|
184
|
+
const transitiveDep = {
|
|
185
|
+
artifactID: name,
|
|
186
|
+
group: group,
|
|
187
|
+
version: splitEdge[1],
|
|
188
|
+
scope: 'compile',
|
|
189
|
+
type: 'transitive',
|
|
190
|
+
hash: hash,
|
|
191
|
+
edges: {}
|
|
192
|
+
}
|
|
193
|
+
rootNodes[Object.keys(rootNodes)[0]][dep] = transitiveDep
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
//add transitive dependency to rootNodes
|
|
197
|
+
rootNodes[Object.keys(rootNodes)[0]][dep] = transitiveDep
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = {
|
|
202
|
+
parseGoDependencies
|
|
203
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const child_process = require('child_process')
|
|
2
|
+
const i18n = require('i18n')
|
|
3
|
+
|
|
4
|
+
const getGoDependencies = config => {
|
|
5
|
+
let cmdStdout
|
|
6
|
+
let cwd = config.projectPath
|
|
7
|
+
? config.projectPath.replace('go.mod', '')
|
|
8
|
+
: process.cwd()
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// A sample of this output can be found
|
|
12
|
+
// in the go test folder data/goModGraphResults.text
|
|
13
|
+
cmdStdout = child_process.execSync('go mod graph', { cwd })
|
|
14
|
+
|
|
15
|
+
return cmdStdout.toString()
|
|
16
|
+
} catch (err) {
|
|
17
|
+
if (err.message === 'spawnSync /bin/sh ENOENT') {
|
|
18
|
+
err.message =
|
|
19
|
+
'\n\n*************** No transitive dependencies ***************\n\nWe are unable to build a dependency tree view from your repository as there were no transitive dependencies found.'
|
|
20
|
+
}
|
|
21
|
+
console.log(
|
|
22
|
+
i18n.__('goReadProjectFile', cwd, `${err.message ? err.message : ''}`)
|
|
23
|
+
)
|
|
24
|
+
// throw new Error(
|
|
25
|
+
// i18n.__('goReadProjectFile', cwd, `${err.message ? err.message : ''}`)
|
|
26
|
+
// )
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
getGoDependencies
|
|
32
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const child_process = require('child_process')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const i18n = require('i18n')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
|
|
6
|
+
const MAVEN = 'maven'
|
|
7
|
+
const GRADLE = 'gradle'
|
|
8
|
+
|
|
9
|
+
const determineProjectTypeAndCwd = (files, projectPath) => {
|
|
10
|
+
const projectData = {}
|
|
11
|
+
|
|
12
|
+
if (files[0].includes('pom.xml')) {
|
|
13
|
+
projectData.projectType = MAVEN
|
|
14
|
+
projectData.cwd = projectPath
|
|
15
|
+
? projectPath
|
|
16
|
+
: files[0].replace('pom.xml', '')
|
|
17
|
+
} else if (files[0].includes('build.gradle')) {
|
|
18
|
+
projectData.projectType = GRADLE
|
|
19
|
+
projectData.cwd = projectPath
|
|
20
|
+
? projectPath
|
|
21
|
+
: files[0].replace('pom.xml', '')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return projectData
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const buildMaven = (config, projectData, timeout) => {
|
|
28
|
+
let cmdStdout
|
|
29
|
+
let mvn_settings = ''
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
// Allow users to provide a custom location for their settings.xml
|
|
33
|
+
if (config.mavenSettingsPath) {
|
|
34
|
+
mvn_settings = ' -s ' + config.mavenSettingsPath
|
|
35
|
+
}
|
|
36
|
+
cmdStdout = child_process.execSync(
|
|
37
|
+
'mvn dependency:tree -B' + mvn_settings,
|
|
38
|
+
{
|
|
39
|
+
cwd: projectData.cwd,
|
|
40
|
+
timeout
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
return cmdStdout.toString()
|
|
44
|
+
} catch (err) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
i18n.__('mavenDependencyTreeNonZero', projectData.cwd, `${err.message}`)
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const buildGradle = (config, projectData, timeout) => {
|
|
52
|
+
let cmdStdout
|
|
53
|
+
let output = {}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// path.sep is user here to either execute as "./gradlew" for UNIX/Linux/MacOS
|
|
57
|
+
// & ".\gradlew" for Windows
|
|
58
|
+
// Check if the user has specified a sub-project
|
|
59
|
+
if (config.subProject) {
|
|
60
|
+
cmdStdout = child_process.execSync(
|
|
61
|
+
'.' +
|
|
62
|
+
path.sep +
|
|
63
|
+
'gradlew :' +
|
|
64
|
+
config.subProject +
|
|
65
|
+
':dependencies --configuration runtimeClasspath',
|
|
66
|
+
{
|
|
67
|
+
cwd: projectData.cwd,
|
|
68
|
+
timeout
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
} else {
|
|
72
|
+
cmdStdout = child_process.execSync(
|
|
73
|
+
'.' +
|
|
74
|
+
path.sep +
|
|
75
|
+
'gradlew dependencies --configuration runtimeClasspath',
|
|
76
|
+
{
|
|
77
|
+
cwd: projectData.cwd,
|
|
78
|
+
timeout
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
if (
|
|
83
|
+
cmdStdout
|
|
84
|
+
.toString()
|
|
85
|
+
.includes(
|
|
86
|
+
"runtimeClasspath - Runtime classpath of source set 'main'.\n" +
|
|
87
|
+
'No dependencies'
|
|
88
|
+
)
|
|
89
|
+
) {
|
|
90
|
+
cmdStdout = child_process.execSync(
|
|
91
|
+
'.' + path.sep + 'gradlew dependencies',
|
|
92
|
+
{
|
|
93
|
+
cwd: projectData.cwd,
|
|
94
|
+
timeout
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
output = cmdStdout.toString()
|
|
99
|
+
return output
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (
|
|
102
|
+
fs.existsSync(projectData.cwd + 'gradlew') ||
|
|
103
|
+
fs.existsSync(projectData.cwd + 'gradlew.bat')
|
|
104
|
+
) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
i18n.__(
|
|
107
|
+
'gradleDependencyTreeNonZero',
|
|
108
|
+
projectData.cwd,
|
|
109
|
+
`${err.message}`
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error(
|
|
114
|
+
i18n.__('gradleWrapperUnavailable', projectData.cwd, `${err.message}`)
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const getJavaBuildDeps = (config, files) => {
|
|
121
|
+
const timeout = 960000
|
|
122
|
+
let output = {
|
|
123
|
+
mvnDependancyTreeOutput: undefined,
|
|
124
|
+
projectType: undefined
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
const projectData = determineProjectTypeAndCwd(files, config.projectPath)
|
|
129
|
+
if (projectData.projectType === MAVEN) {
|
|
130
|
+
output.mvnDependancyTreeOutput = buildMaven(config, projectData, timeout)
|
|
131
|
+
} else if (projectData.projectType === GRADLE) {
|
|
132
|
+
output.mvnDependancyTreeOutput = buildGradle(config, projectData, timeout)
|
|
133
|
+
}
|
|
134
|
+
output.projectType = projectData.projectType
|
|
135
|
+
return output
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.log(err.message.toString())
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = {
|
|
142
|
+
getJavaBuildDeps
|
|
143
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const analysis = require('./analysis')
|
|
2
|
+
const { parseBuildDeps } = require('./javaBuildDepsParser')
|
|
3
|
+
const { createJavaTSMessage } = require('../common/formatMessage')
|
|
4
|
+
|
|
5
|
+
const javaAnalysis = (config, languageFiles) => {
|
|
6
|
+
languageFiles.java.forEach(file => {
|
|
7
|
+
file.replace('build.gradle.kts', 'build.gradle')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const javaDeps = buildJavaTree(config, languageFiles.java)
|
|
11
|
+
return createJavaTSMessage(javaDeps)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const buildJavaTree = (config, files) => {
|
|
15
|
+
const javaBuildDeps = analysis.getJavaBuildDeps(config, files)
|
|
16
|
+
return parseBuildDeps(config, javaBuildDeps)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
javaAnalysis
|
|
21
|
+
}
|