@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
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
const crypto = require('crypto')
|
|
3
|
-
|
|
4
|
-
module.exports = exports = ({ go }, next) => {
|
|
5
|
-
const { modGraphOutput } = go
|
|
6
|
-
try {
|
|
7
|
-
go.goDependencyTrees = parseGo(modGraphOutput)
|
|
8
|
-
} catch (err) {
|
|
9
|
-
next(new Error(i18n.__('goParseProjectFile') + `${err.message}`))
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
next()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const splitAllLinesIntoArray = modGraphOutput => {
|
|
16
|
-
return modGraphOutput.split(/\r\n|\r|\n/)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const parseGo = modGraphOutput => {
|
|
20
|
-
let splitLines = splitAllLinesIntoArray(modGraphOutput)
|
|
21
|
-
const directDepNames = getDirectDepNames(splitLines)
|
|
22
|
-
const uniqueTransitiveDepNames = getAllUniqueTransitiveDepNames(
|
|
23
|
-
splitLines,
|
|
24
|
-
directDepNames
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
let rootNodes = createRootNodes(splitLines)
|
|
28
|
-
|
|
29
|
-
createTransitiveDeps(uniqueTransitiveDepNames, splitLines, rootNodes)
|
|
30
|
-
|
|
31
|
-
//console.log(rootNodes)
|
|
32
|
-
|
|
33
|
-
return rootNodes
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const getAllDepsOfADepAsEdge = (dep, deps) => {
|
|
37
|
-
let edges = {}
|
|
38
|
-
|
|
39
|
-
const depRows = deps.filter(line => {
|
|
40
|
-
return line.startsWith(dep)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
depRows.forEach(dep => {
|
|
44
|
-
const edgeName = dep.split(' ')[1]
|
|
45
|
-
edges[edgeName] = edgeName
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
return edges
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const getAllDepsOfADepAsName = (dep, deps) => {
|
|
52
|
-
let edges = []
|
|
53
|
-
|
|
54
|
-
const depRows = deps.filter(line => {
|
|
55
|
-
return line.startsWith(dep)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
depRows.forEach(dep => {
|
|
59
|
-
const edgeName = dep.split(' ')[1]
|
|
60
|
-
edges.push(edgeName)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
return edges
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const createRootNodes = deps => {
|
|
67
|
-
let rootDep = {}
|
|
68
|
-
const rootDeps = getRootDeps(deps)
|
|
69
|
-
|
|
70
|
-
const edges = rootDeps.map(dep => {
|
|
71
|
-
return dep.split(' ')[1]
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
rootDep[rootDeps[0].split(' ')[0]] = {}
|
|
75
|
-
|
|
76
|
-
edges.forEach(edge => {
|
|
77
|
-
const splitEdge = edge.split('@')
|
|
78
|
-
const splitGroupName = splitEdge[0].split('/')
|
|
79
|
-
const name = splitGroupName.pop()
|
|
80
|
-
const lastSlash = splitEdge[0].lastIndexOf('/')
|
|
81
|
-
let group = splitEdge[0].substring(0, lastSlash)
|
|
82
|
-
const hash = getHash(splitEdge[0])
|
|
83
|
-
|
|
84
|
-
group = checkGroupExists(group, name)
|
|
85
|
-
|
|
86
|
-
//get the edges of the root dependency
|
|
87
|
-
const edgesOfDep = getAllDepsOfADepAsEdge(edge, deps)
|
|
88
|
-
|
|
89
|
-
rootDep[rootDeps[0].split(' ')[0]][edge] = {
|
|
90
|
-
artifactID: name,
|
|
91
|
-
group: group,
|
|
92
|
-
version: splitEdge[1],
|
|
93
|
-
scope: '"compile',
|
|
94
|
-
type: 'direct',
|
|
95
|
-
hash: hash,
|
|
96
|
-
edges: edgesOfDep
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
return rootDep
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const getRootDeps = deps => {
|
|
103
|
-
const rootDeps = deps.filter(dep => {
|
|
104
|
-
const parentDep = dep.split(' ')[0]
|
|
105
|
-
if (parentDep.split('@v').length === 1) {
|
|
106
|
-
return dep
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
return rootDeps
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const getHash = library => {
|
|
113
|
-
let shaSum = crypto.createHash('sha1')
|
|
114
|
-
shaSum.update(library)
|
|
115
|
-
return shaSum.digest('hex')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const getDirectDepNames = deps => {
|
|
119
|
-
const directDepNames = []
|
|
120
|
-
|
|
121
|
-
deps.forEach(dep => {
|
|
122
|
-
const parentDep = dep.split(' ')[0]
|
|
123
|
-
if (parentDep.split('@v').length === 1) {
|
|
124
|
-
dep.split(' ')[1] !== undefined
|
|
125
|
-
? directDepNames.push(dep.split(' ')[1])
|
|
126
|
-
: null
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
return directDepNames
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const getAllUniqueTransitiveDepNames = (deps, directDepNames) => {
|
|
133
|
-
let uniqueDeps = []
|
|
134
|
-
|
|
135
|
-
deps.forEach(dep => {
|
|
136
|
-
const parentDep = dep.split(' ')[0]
|
|
137
|
-
if (parentDep.split('@v').length !== 1) {
|
|
138
|
-
if (!directDepNames.includes(parentDep)) {
|
|
139
|
-
if (!uniqueDeps.includes(parentDep)) {
|
|
140
|
-
parentDep.length > 1 ? uniqueDeps.push(parentDep) : null
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
return uniqueDeps
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const checkGroupExists = (group, name) => {
|
|
149
|
-
if (group === null || group === '') {
|
|
150
|
-
return name
|
|
151
|
-
}
|
|
152
|
-
return group
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const createTransitiveDeps = (transitiveDeps, splitLines, rootNodes) => {
|
|
156
|
-
transitiveDeps.forEach(dep => {
|
|
157
|
-
//create transitive dep
|
|
158
|
-
const splitEdge = dep.split('@')
|
|
159
|
-
const splitGroupName = splitEdge[0].split('/')
|
|
160
|
-
const name = splitGroupName.pop()
|
|
161
|
-
const lastSlash = splitEdge[0].lastIndexOf('/')
|
|
162
|
-
let group = splitEdge[0].substring(0, lastSlash)
|
|
163
|
-
const hash = getHash(splitEdge[0])
|
|
164
|
-
|
|
165
|
-
group = checkGroupExists(group, name)
|
|
166
|
-
|
|
167
|
-
const transitiveDep = {
|
|
168
|
-
artifactID: name,
|
|
169
|
-
group: group,
|
|
170
|
-
version: splitEdge[1],
|
|
171
|
-
scope: 'compile',
|
|
172
|
-
type: 'transitive',
|
|
173
|
-
hash: hash,
|
|
174
|
-
edges: {}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//add edges to transitiveDep
|
|
178
|
-
const edges = getAllDepsOfADepAsEdge(dep, splitLines)
|
|
179
|
-
transitiveDep.edges = edges
|
|
180
|
-
|
|
181
|
-
//add all edges as a transitive dependency to rootNodes
|
|
182
|
-
const edgesAsName = getAllDepsOfADepAsName(dep, splitLines)
|
|
183
|
-
|
|
184
|
-
edgesAsName.forEach(dep => {
|
|
185
|
-
const splitEdge = dep.split('@')
|
|
186
|
-
const splitGroupName = splitEdge[0].split('/')
|
|
187
|
-
const name = splitGroupName.pop()
|
|
188
|
-
const lastSlash = splitEdge[0].lastIndexOf('/')
|
|
189
|
-
let group = splitEdge[0].substring(0, lastSlash)
|
|
190
|
-
const hash = getHash(splitEdge[0])
|
|
191
|
-
|
|
192
|
-
group = checkGroupExists(group, name)
|
|
193
|
-
|
|
194
|
-
const transitiveDep = {
|
|
195
|
-
artifactID: name,
|
|
196
|
-
group: group,
|
|
197
|
-
version: splitEdge[1],
|
|
198
|
-
scope: 'compile',
|
|
199
|
-
type: 'transitive',
|
|
200
|
-
hash: hash,
|
|
201
|
-
edges: {}
|
|
202
|
-
}
|
|
203
|
-
rootNodes[Object.keys(rootNodes)[0]][dep] = transitiveDep
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
//add transitive dependency to rootNodes
|
|
207
|
-
rootNodes[Object.keys(rootNodes)[0]][dep] = transitiveDep
|
|
208
|
-
})
|
|
209
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const child_process = require('child_process')
|
|
2
|
-
const i18n = require('i18n')
|
|
3
|
-
|
|
4
|
-
module.exports = exports = async (
|
|
5
|
-
{ language: { projectFilePath }, go },
|
|
6
|
-
next
|
|
7
|
-
) => {
|
|
8
|
-
let cmdStdout
|
|
9
|
-
let cwd
|
|
10
|
-
try {
|
|
11
|
-
cwd = projectFilePath.replace('go.mod', '')
|
|
12
|
-
// A sample of this output can be found
|
|
13
|
-
// in the go test folder data/goModGraphResults.text
|
|
14
|
-
cmdStdout = child_process.execSync('go mod graph', { cwd })
|
|
15
|
-
|
|
16
|
-
go.modGraphOutput = cmdStdout.toString()
|
|
17
|
-
|
|
18
|
-
next()
|
|
19
|
-
} catch (err) {
|
|
20
|
-
if (err.message === 'spawnSync /bin/sh ENOENT') {
|
|
21
|
-
err.message =
|
|
22
|
-
'\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.'
|
|
23
|
-
}
|
|
24
|
-
next(
|
|
25
|
-
new Error(
|
|
26
|
-
i18n.__('goReadProjectFile', cwd, `${err.message ? err.message : ''}`)
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const AnalysisEngine = require('../AnalysisEngine')
|
|
2
|
-
|
|
3
|
-
const readProjectFileContents = require('./readProjectFileContents')
|
|
4
|
-
const parseMavenProjectFileContents = require('./parseMavenProjectFileContents')
|
|
5
|
-
const parseProjectFileContents = require('./parseProjectFileContents')
|
|
6
|
-
const sanitizer = require('./sanitizer')
|
|
7
|
-
const i18n = require('i18n')
|
|
8
|
-
|
|
9
|
-
module.exports = exports = (language, config, callback) => {
|
|
10
|
-
const ae = new AnalysisEngine({ language, config, java: {} })
|
|
11
|
-
|
|
12
|
-
// Remove ".kts" from filename to look the same as a Gradle projectFileName so we can support Kotlin
|
|
13
|
-
language.projectFilePath = language.projectFilePath.replace(
|
|
14
|
-
'build.gradle.kts',
|
|
15
|
-
'build.gradle'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
if (config['beta_unified_java_parser']) {
|
|
19
|
-
console.log('Using new parser...')
|
|
20
|
-
ae.use([readProjectFileContents, parseProjectFileContents, sanitizer])
|
|
21
|
-
} else if (
|
|
22
|
-
language.projectFilePath.endsWith('pom.xml') &&
|
|
23
|
-
!config['beta_unified_java_parser']
|
|
24
|
-
) {
|
|
25
|
-
ae.use([readProjectFileContents, parseMavenProjectFileContents, sanitizer])
|
|
26
|
-
} else {
|
|
27
|
-
ae.use([
|
|
28
|
-
readProjectFileContents,
|
|
29
|
-
parseMavenProjectFileContents,
|
|
30
|
-
parseProjectFileContents,
|
|
31
|
-
sanitizer
|
|
32
|
-
])
|
|
33
|
-
}
|
|
34
|
-
ae.analyze((err, analysis) => {
|
|
35
|
-
if (err) {
|
|
36
|
-
console.log(i18n.__('javaAnalysisError'), err.message)
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
callback(null, analysis, config)
|
|
40
|
-
}, config)
|
|
41
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
const i18n = require('i18n')
|
|
2
|
-
|
|
3
|
-
module.exports = exports = ({ language: { projectFilePath }, java }, next) => {
|
|
4
|
-
const { mvnDependancyTreeOutput } = java
|
|
5
|
-
|
|
6
|
-
if (projectFilePath.endsWith('pom.xml')) {
|
|
7
|
-
try {
|
|
8
|
-
java.mavenDependencyTrees = parseMvn(mvnDependancyTreeOutput)
|
|
9
|
-
next()
|
|
10
|
-
} catch (err) {
|
|
11
|
-
next(new Error(i18n.__('javaParseProjectFile') + `${err.message}`))
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
// Go to gradle project
|
|
16
|
-
next()
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const hasVersion = key => {
|
|
21
|
-
var regex = RegExp('[0-9].[0-9]')
|
|
22
|
-
return regex.test(key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const formatKeyName = value => {
|
|
26
|
-
let tempArr = value.split(':')
|
|
27
|
-
let versionIndex = undefined
|
|
28
|
-
for (let i = 0; i < tempArr.length; i++) {
|
|
29
|
-
if (hasVersion(tempArr[i])) {
|
|
30
|
-
versionIndex = i
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return tempArr[0] + '/' + tempArr[1] + '@' + tempArr[versionIndex]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const shaveConsoleOutputUntilItFindsFirsDigraphMention =
|
|
38
|
-
mvnDependancyTreeOutput => {
|
|
39
|
-
//shaves of the console output until it reaches the first digraph
|
|
40
|
-
return mvnDependancyTreeOutput.substring(
|
|
41
|
-
mvnDependancyTreeOutput.indexOf('digraph')
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const getDigraphObjInfo = editedOutput => {
|
|
46
|
-
//turns the output into an array of digraph information
|
|
47
|
-
// which looks like
|
|
48
|
-
// ' "com.contrastsecurity:teamserver-model:jar:local" {\n
|
|
49
|
-
// \n [INFO] "com.contrastsecurity:teamserver-model:jar:local" -> "junit:junit:jar:4.12:test" ;\n
|
|
50
|
-
// \n [INFO] "junit:junit:jar:4.12:test" -> "org.hamcrest:hamcrest-core:jar:1.3:test" ;\n
|
|
51
|
-
// [INFO] }' ]
|
|
52
|
-
let digraphObj = editedOutput.split('digraph')
|
|
53
|
-
|
|
54
|
-
return digraphObj.filter(v => v != '')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const createDigraphObjKey = element => {
|
|
58
|
-
// parse the digraph to turn into an object key
|
|
59
|
-
let formatObjKey = element.substring(0, element.indexOf('{'))
|
|
60
|
-
formatObjKey = formatObjKey.replace(/"/g, '')
|
|
61
|
-
formatObjKey = formatObjKey.replace('{', '')
|
|
62
|
-
formatObjKey = formatObjKey.trim()
|
|
63
|
-
|
|
64
|
-
return formatObjKey
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const turnDigraphDependanciesIntoArrOfInnerDep = digraphObj => {
|
|
68
|
-
// takes:
|
|
69
|
-
// "com.contrastsecurity:teamserver-model:jar:local" {
|
|
70
|
-
// [INFO] "com.contrastsecurity:teamserver-model:jar:local" -> "org.springframework:spring-core:jar:5.1.9.RELEASE:compile" ;
|
|
71
|
-
// [INFO] "com.contrastsecurity:teamserver-model:jar:local" -> "junit:junit:jar:4.12:test" ;
|
|
72
|
-
// [INFO] "org.springframework:spring-core:jar:5.1.9.RELEASE:compile" -> "org.springframework:spring-jcl:jar:5.1.9.RELEASE:compile" ;
|
|
73
|
-
// [INFO] "junit:junit:jar:4.12:test" -> "org.hamcrest:hamcrest-core:jar:1.3:test" ;
|
|
74
|
-
// [INFO] }
|
|
75
|
-
|
|
76
|
-
// and turns it into
|
|
77
|
-
// [ '"com.contrastsecurity:teamserver-model:jar:local" -> "org.springframework:spring-core:jar:5.1.9.RELEASE:compile"',
|
|
78
|
-
// '"com.contrastsecurity:teamserver-model:jar:local" -> "junit:junit:jar:4.12:test"',
|
|
79
|
-
// '"org.springframework:spring-core:jar:5.1.9.RELEASE:compile" -> "org.springframework:spring-jcl:jar:5.1.9.RELEASE:compile"',
|
|
80
|
-
// '"junit:junit:jar:4.12:test" -> "org.hamcrest:hamcrest-core:jar:1.3:test"',
|
|
81
|
-
// '' ]
|
|
82
|
-
|
|
83
|
-
let depRow = digraphObj.substring(
|
|
84
|
-
digraphObj.indexOf('{'),
|
|
85
|
-
digraphObj.indexOf('}') + 1
|
|
86
|
-
)
|
|
87
|
-
depRow = depRow.replace(/\[INFO\]/g, '')
|
|
88
|
-
depRow = depRow.replace(/\n/g, '')
|
|
89
|
-
depRow = depRow.replace(/\{/g, '')
|
|
90
|
-
depRow = depRow.replace(/\}/g, '')
|
|
91
|
-
depRow = depRow.replace(/\"/g, '') // eslint-disable-line
|
|
92
|
-
|
|
93
|
-
return depRow.split(';').map(s => s.trim())
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const createOuterDependanciesAndType = (digraphObjKey, arrOfInnerDep) => {
|
|
97
|
-
let leftKey
|
|
98
|
-
let rightKey
|
|
99
|
-
let newDepNode
|
|
100
|
-
const list = []
|
|
101
|
-
|
|
102
|
-
arrOfInnerDep.forEach(element => {
|
|
103
|
-
leftKey = element.substring(0, element.indexOf(' -'))
|
|
104
|
-
rightKey = element.substring(element.indexOf('>') + 2)
|
|
105
|
-
|
|
106
|
-
// if the digraph and the leftKey are the same and the left has a version
|
|
107
|
-
// then “edgeType” is direct
|
|
108
|
-
if (leftKey === digraphObjKey) {
|
|
109
|
-
if (hasVersion(rightKey)) {
|
|
110
|
-
let rightKeyArr = rightKey.split(':')
|
|
111
|
-
newDepNode = {
|
|
112
|
-
[rightKey]: {
|
|
113
|
-
group: rightKeyArr[0],
|
|
114
|
-
artifactID: rightKeyArr[1],
|
|
115
|
-
packaging: rightKeyArr[2],
|
|
116
|
-
version: rightKeyArr[3],
|
|
117
|
-
scope: rightKeyArr[4],
|
|
118
|
-
type: 'direct',
|
|
119
|
-
parent: leftKey,
|
|
120
|
-
edges: {}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
list.push(newDepNode)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// if right and left both have versions and left doesn't match digraph name
|
|
127
|
-
// then “type” is transitive
|
|
128
|
-
if (
|
|
129
|
-
hasVersion(leftKey) &&
|
|
130
|
-
hasVersion(rightKey) &&
|
|
131
|
-
!(leftKey === digraphObjKey)
|
|
132
|
-
) {
|
|
133
|
-
let rightKeyArr = rightKey.split(':')
|
|
134
|
-
newDepNode = {
|
|
135
|
-
[rightKey]: {
|
|
136
|
-
group: rightKeyArr[0],
|
|
137
|
-
artifactID: rightKeyArr[1],
|
|
138
|
-
packaging: rightKeyArr[2],
|
|
139
|
-
version: rightKeyArr[3],
|
|
140
|
-
scope: rightKeyArr[4],
|
|
141
|
-
type: 'transitive',
|
|
142
|
-
parent: leftKey,
|
|
143
|
-
edges: {}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
list.push(newDepNode)
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
return list
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const createEdges = (digraphObjKey, listOuterDep) => {
|
|
154
|
-
listOuterDep.forEach(element => {
|
|
155
|
-
const key = Object.keys(element).toString()
|
|
156
|
-
|
|
157
|
-
const childParentRef = element[key].parent
|
|
158
|
-
|
|
159
|
-
if (childParentRef !== digraphObjKey) {
|
|
160
|
-
listOuterDep.forEach(i => {
|
|
161
|
-
let parentKey = Object.keys(i).toString()
|
|
162
|
-
if (childParentRef === parentKey) {
|
|
163
|
-
i[parentKey].edges[formatKeyName(key)] = formatKeyName(key)
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
return listOuterDep
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const extractFromArrAndFinalParse = listWithEdges => {
|
|
172
|
-
let finalObj = {}
|
|
173
|
-
listWithEdges.forEach(element => {
|
|
174
|
-
const key = Object.keys(element).toString()
|
|
175
|
-
|
|
176
|
-
const parsedKey = formatKeyName(key)
|
|
177
|
-
|
|
178
|
-
delete element[key].parent
|
|
179
|
-
|
|
180
|
-
finalObj[parsedKey] = element[key]
|
|
181
|
-
})
|
|
182
|
-
return finalObj
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const dependancyValueCreationOrganiser = (digraphObjKey, digraph) => {
|
|
186
|
-
const arrOfInnerDep = turnDigraphDependanciesIntoArrOfInnerDep(digraph)
|
|
187
|
-
const listOuterDep = createOuterDependanciesAndType(
|
|
188
|
-
digraphObjKey,
|
|
189
|
-
arrOfInnerDep
|
|
190
|
-
)
|
|
191
|
-
const listWithEdges = createEdges(digraphObjKey, listOuterDep)
|
|
192
|
-
const finishDepObj = extractFromArrAndFinalParse(listWithEdges)
|
|
193
|
-
|
|
194
|
-
return finishDepObj
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const parseMvn = mvnDependancyTreeOutput => {
|
|
198
|
-
let parsedDepObj = {}
|
|
199
|
-
let editedOutput = shaveConsoleOutputUntilItFindsFirsDigraphMention(
|
|
200
|
-
mvnDependancyTreeOutput
|
|
201
|
-
)
|
|
202
|
-
let digraphObjArray = getDigraphObjInfo(editedOutput)
|
|
203
|
-
|
|
204
|
-
digraphObjArray.forEach(digraph => {
|
|
205
|
-
const digraphObjKey = createDigraphObjKey(digraph)
|
|
206
|
-
parsedDepObj[digraphObjKey] = dependancyValueCreationOrganiser(
|
|
207
|
-
digraphObjKey,
|
|
208
|
-
digraph
|
|
209
|
-
)
|
|
210
|
-
})
|
|
211
|
-
return parsedDepObj
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// testing purposes
|
|
215
|
-
exports.shaveConsoleOutputUntilItFindsFirsDigraphMention =
|
|
216
|
-
shaveConsoleOutputUntilItFindsFirsDigraphMention
|
|
217
|
-
exports.getDigraphObjInfo = getDigraphObjInfo
|
|
218
|
-
exports.createDigraphObjKey = createDigraphObjKey
|
|
219
|
-
exports.turnDigraphDependanciesIntoArrOfInnerDep =
|
|
220
|
-
turnDigraphDependanciesIntoArrOfInnerDep
|
|
221
|
-
exports.hasVersion = hasVersion
|
|
222
|
-
exports.formatKeyName = formatKeyName
|
|
223
|
-
exports.createOuterDependanciesAndType = createOuterDependanciesAndType
|
|
224
|
-
exports.extractFromArrAndFinalParse = extractFromArrAndFinalParse
|
|
225
|
-
exports.createEdges = createEdges
|