@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,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const AnalysisEngine = require('../AnalysisEngine');
|
|
3
|
-
const readProjectFileContents = require('./readProjectFileContents');
|
|
4
|
-
const parseProjectFileContents = require('./parseProjectFileContents');
|
|
5
|
-
const readLockFileContents = require('./readLockFileContents');
|
|
6
|
-
const parseLockFileContents = require('./parseLockFileContents');
|
|
7
|
-
const sanitizer = require('./sanitizer');
|
|
8
|
-
const i18n = require('i18n');
|
|
9
|
-
module.exports = exports = (language, config, callback) => {
|
|
10
|
-
const ae = new AnalysisEngine({ language, config, dotnet: {} });
|
|
11
|
-
ae.use([
|
|
12
|
-
readProjectFileContents,
|
|
13
|
-
parseProjectFileContents,
|
|
14
|
-
readLockFileContents,
|
|
15
|
-
parseLockFileContents,
|
|
16
|
-
sanitizer
|
|
17
|
-
]);
|
|
18
|
-
ae.analyze((err, analysis) => {
|
|
19
|
-
if (err) {
|
|
20
|
-
callback(new Error(i18n.__('dotnetAnalysisFailure') + err.message));
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
callback(null, analysis);
|
|
24
|
-
});
|
|
25
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const i18n = require('i18n');
|
|
3
|
-
module.exports = exports = ({ language: { lockFilePath }, dotnet }, next) => {
|
|
4
|
-
const { rawLockFileContents } = dotnet;
|
|
5
|
-
if (!rawLockFileContents) {
|
|
6
|
-
next();
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
let count = 0;
|
|
11
|
-
dotnet.lockFile = JSON.parse(rawLockFileContents);
|
|
12
|
-
for (const dependenciesNode in dotnet.lockFile.dependencies) {
|
|
13
|
-
for (const innerNode in dotnet.lockFile.dependencies[dependenciesNode]) {
|
|
14
|
-
const nodeValidation = JSON.stringify(dotnet.lockFile.dependencies[dependenciesNode][innerNode]);
|
|
15
|
-
if (nodeValidation.includes('"type":"Project"')) {
|
|
16
|
-
count += 1;
|
|
17
|
-
delete dotnet.lockFile.dependencies[dependenciesNode][innerNode];
|
|
18
|
-
dotnet.additionalInfo = 'dependenciesNote';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (count > 0) {
|
|
23
|
-
const multiLevelProjectWarning = () => {
|
|
24
|
-
console.log('');
|
|
25
|
-
console.log(i18n.__('dependenciesNote'));
|
|
26
|
-
};
|
|
27
|
-
setTimeout(multiLevelProjectWarning, 7000);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
next(new Error(i18n.__('dotnetParseLockfile', lockFilePath) + `${err.message}`));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
next();
|
|
35
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const xml2js = require('xml2js');
|
|
3
|
-
const i18n = require('i18n');
|
|
4
|
-
module.exports = exports = ({ language: { projectFilePath }, dotnet }, next) => {
|
|
5
|
-
const { rawProjectFileContents } = dotnet;
|
|
6
|
-
const parser = new xml2js.Parser({ explicitArray: false, mergeAttrs: true });
|
|
7
|
-
parser.parseString(rawProjectFileContents, (err, projectFileXML) => {
|
|
8
|
-
if (err) {
|
|
9
|
-
next(new Error(i18n.__('dotnetParseProjectFile', projectFilePath) + `${err}`));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
dotnet.projectFile = projectFileXML;
|
|
13
|
-
next();
|
|
14
|
-
});
|
|
15
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const i18n = require('i18n');
|
|
4
|
-
module.exports = exports = (analysis, next) => {
|
|
5
|
-
const { language: { lockFilePath }, dotnet } = analysis;
|
|
6
|
-
if (!lockFilePath) {
|
|
7
|
-
next();
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
dotnet.rawLockFileContents = fs.readFileSync(lockFilePath);
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
next(new Error(i18n.__('dotnetReadLockfile', lockFilePath) + `${err.message}`));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
next();
|
|
18
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const i18n = require('i18n');
|
|
4
|
-
module.exports = exports = (analysis, next) => {
|
|
5
|
-
const { language: { projectFilePath }, dotnet } = analysis;
|
|
6
|
-
try {
|
|
7
|
-
dotnet.rawProjectFileContents = fs.readFileSync(projectFilePath);
|
|
8
|
-
}
|
|
9
|
-
catch (err) {
|
|
10
|
-
next(new Error(i18n.__('dotnetReadProjectFile', projectFilePath) + `${err.message}`));
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
next();
|
|
14
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = exports = ({ dotnet }, next) => {
|
|
3
|
-
delete dotnet.rawProjectFileContents;
|
|
4
|
-
delete dotnet.parsedProjectFileContents;
|
|
5
|
-
delete dotnet.projectFileXML;
|
|
6
|
-
delete dotnet.packageReferences;
|
|
7
|
-
delete dotnet.rawLockFileContents;
|
|
8
|
-
next();
|
|
9
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const AnalysisEngine = require('../AnalysisEngine');
|
|
3
|
-
const readProjectFileContents = require('./readProjectFileContents');
|
|
4
|
-
const parseProjectFileContents = require('./parseProjectFileContents');
|
|
5
|
-
const sanitizer = require('./sanitizer');
|
|
6
|
-
const i18n = require('i18n');
|
|
7
|
-
module.exports = exports = (language, config, callback) => {
|
|
8
|
-
const ae = new AnalysisEngine({ language, config, go: {} });
|
|
9
|
-
ae.use([readProjectFileContents, parseProjectFileContents, sanitizer]);
|
|
10
|
-
ae.analyze((err, analysis) => {
|
|
11
|
-
if (err) {
|
|
12
|
-
callback(new Error(i18n.__('goAnalysisError') + `${err.message}`));
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
callback(null, analysis);
|
|
16
|
-
});
|
|
17
|
-
};
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const i18n = require('i18n');
|
|
3
|
-
const crypto = require('crypto');
|
|
4
|
-
module.exports = exports = ({ go }, next) => {
|
|
5
|
-
const { modGraphOutput } = go;
|
|
6
|
-
try {
|
|
7
|
-
go.goDependencyTrees = parseGo(modGraphOutput);
|
|
8
|
-
}
|
|
9
|
-
catch (err) {
|
|
10
|
-
next(new Error(i18n.__('goParseProjectFile') + `${err.message}`));
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
next();
|
|
14
|
-
};
|
|
15
|
-
const splitAllLinesIntoArray = modGraphOutput => {
|
|
16
|
-
return modGraphOutput.split(/\r\n|\r|\n/);
|
|
17
|
-
};
|
|
18
|
-
const parseGo = modGraphOutput => {
|
|
19
|
-
let splitLines = splitAllLinesIntoArray(modGraphOutput);
|
|
20
|
-
const directDepNames = getDirectDepNames(splitLines);
|
|
21
|
-
const uniqueTransitiveDepNames = getAllUniqueTransitiveDepNames(splitLines, directDepNames);
|
|
22
|
-
let rootNodes = createRootNodes(splitLines);
|
|
23
|
-
createTransitiveDeps(uniqueTransitiveDepNames, splitLines, rootNodes);
|
|
24
|
-
return rootNodes;
|
|
25
|
-
};
|
|
26
|
-
const getAllDepsOfADepAsEdge = (dep, deps) => {
|
|
27
|
-
let edges = {};
|
|
28
|
-
const depRows = deps.filter(line => {
|
|
29
|
-
return line.startsWith(dep);
|
|
30
|
-
});
|
|
31
|
-
depRows.forEach(dep => {
|
|
32
|
-
const edgeName = dep.split(' ')[1];
|
|
33
|
-
edges[edgeName] = edgeName;
|
|
34
|
-
});
|
|
35
|
-
return edges;
|
|
36
|
-
};
|
|
37
|
-
const getAllDepsOfADepAsName = (dep, deps) => {
|
|
38
|
-
let edges = [];
|
|
39
|
-
const depRows = deps.filter(line => {
|
|
40
|
-
return line.startsWith(dep);
|
|
41
|
-
});
|
|
42
|
-
depRows.forEach(dep => {
|
|
43
|
-
const edgeName = dep.split(' ')[1];
|
|
44
|
-
edges.push(edgeName);
|
|
45
|
-
});
|
|
46
|
-
return edges;
|
|
47
|
-
};
|
|
48
|
-
const createRootNodes = deps => {
|
|
49
|
-
let rootDep = {};
|
|
50
|
-
const rootDeps = getRootDeps(deps);
|
|
51
|
-
const edges = rootDeps.map(dep => {
|
|
52
|
-
return dep.split(' ')[1];
|
|
53
|
-
});
|
|
54
|
-
rootDep[rootDeps[0].split(' ')[0]] = {};
|
|
55
|
-
edges.forEach(edge => {
|
|
56
|
-
const splitEdge = edge.split('@');
|
|
57
|
-
const splitGroupName = splitEdge[0].split('/');
|
|
58
|
-
const name = splitGroupName.pop();
|
|
59
|
-
const lastSlash = splitEdge[0].lastIndexOf('/');
|
|
60
|
-
let group = splitEdge[0].substring(0, lastSlash);
|
|
61
|
-
const hash = getHash(splitEdge[0]);
|
|
62
|
-
group = checkGroupExists(group, name);
|
|
63
|
-
const edgesOfDep = getAllDepsOfADepAsEdge(edge, deps);
|
|
64
|
-
rootDep[rootDeps[0].split(' ')[0]][edge] = {
|
|
65
|
-
artifactID: name,
|
|
66
|
-
group: group,
|
|
67
|
-
version: splitEdge[1],
|
|
68
|
-
scope: '"compile',
|
|
69
|
-
type: 'direct',
|
|
70
|
-
hash: hash,
|
|
71
|
-
edges: edgesOfDep
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
return rootDep;
|
|
75
|
-
};
|
|
76
|
-
const getRootDeps = deps => {
|
|
77
|
-
const rootDeps = deps.filter(dep => {
|
|
78
|
-
const parentDep = dep.split(' ')[0];
|
|
79
|
-
if (parentDep.split('@v').length === 1) {
|
|
80
|
-
return dep;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return rootDeps;
|
|
84
|
-
};
|
|
85
|
-
const getHash = library => {
|
|
86
|
-
let shaSum = crypto.createHash('sha1');
|
|
87
|
-
shaSum.update(library);
|
|
88
|
-
return shaSum.digest('hex');
|
|
89
|
-
};
|
|
90
|
-
const getDirectDepNames = deps => {
|
|
91
|
-
const directDepNames = [];
|
|
92
|
-
deps.forEach(dep => {
|
|
93
|
-
const parentDep = dep.split(' ')[0];
|
|
94
|
-
if (parentDep.split('@v').length === 1) {
|
|
95
|
-
dep.split(' ')[1] !== undefined
|
|
96
|
-
? directDepNames.push(dep.split(' ')[1])
|
|
97
|
-
: null;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return directDepNames;
|
|
101
|
-
};
|
|
102
|
-
const getAllUniqueTransitiveDepNames = (deps, directDepNames) => {
|
|
103
|
-
let uniqueDeps = [];
|
|
104
|
-
deps.forEach(dep => {
|
|
105
|
-
const parentDep = dep.split(' ')[0];
|
|
106
|
-
if (parentDep.split('@v').length !== 1) {
|
|
107
|
-
if (!directDepNames.includes(parentDep)) {
|
|
108
|
-
if (!uniqueDeps.includes(parentDep)) {
|
|
109
|
-
parentDep.length > 1 ? uniqueDeps.push(parentDep) : null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return uniqueDeps;
|
|
115
|
-
};
|
|
116
|
-
const checkGroupExists = (group, name) => {
|
|
117
|
-
if (group === null || group === '') {
|
|
118
|
-
return name;
|
|
119
|
-
}
|
|
120
|
-
return group;
|
|
121
|
-
};
|
|
122
|
-
const createTransitiveDeps = (transitiveDeps, splitLines, rootNodes) => {
|
|
123
|
-
transitiveDeps.forEach(dep => {
|
|
124
|
-
const splitEdge = dep.split('@');
|
|
125
|
-
const splitGroupName = splitEdge[0].split('/');
|
|
126
|
-
const name = splitGroupName.pop();
|
|
127
|
-
const lastSlash = splitEdge[0].lastIndexOf('/');
|
|
128
|
-
let group = splitEdge[0].substring(0, lastSlash);
|
|
129
|
-
const hash = getHash(splitEdge[0]);
|
|
130
|
-
group = checkGroupExists(group, name);
|
|
131
|
-
const transitiveDep = {
|
|
132
|
-
artifactID: name,
|
|
133
|
-
group: group,
|
|
134
|
-
version: splitEdge[1],
|
|
135
|
-
scope: 'compile',
|
|
136
|
-
type: 'transitive',
|
|
137
|
-
hash: hash,
|
|
138
|
-
edges: {}
|
|
139
|
-
};
|
|
140
|
-
const edges = getAllDepsOfADepAsEdge(dep, splitLines);
|
|
141
|
-
transitiveDep.edges = edges;
|
|
142
|
-
const edgesAsName = getAllDepsOfADepAsName(dep, splitLines);
|
|
143
|
-
edgesAsName.forEach(dep => {
|
|
144
|
-
const splitEdge = dep.split('@');
|
|
145
|
-
const splitGroupName = splitEdge[0].split('/');
|
|
146
|
-
const name = splitGroupName.pop();
|
|
147
|
-
const lastSlash = splitEdge[0].lastIndexOf('/');
|
|
148
|
-
let group = splitEdge[0].substring(0, lastSlash);
|
|
149
|
-
const hash = getHash(splitEdge[0]);
|
|
150
|
-
group = checkGroupExists(group, name);
|
|
151
|
-
const transitiveDep = {
|
|
152
|
-
artifactID: name,
|
|
153
|
-
group: group,
|
|
154
|
-
version: splitEdge[1],
|
|
155
|
-
scope: 'compile',
|
|
156
|
-
type: 'transitive',
|
|
157
|
-
hash: hash,
|
|
158
|
-
edges: {}
|
|
159
|
-
};
|
|
160
|
-
rootNodes[Object.keys(rootNodes)[0]][dep] = transitiveDep;
|
|
161
|
-
});
|
|
162
|
-
rootNodes[Object.keys(rootNodes)[0]][dep] = transitiveDep;
|
|
163
|
-
});
|
|
164
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const child_process = require('child_process');
|
|
3
|
-
const i18n = require('i18n');
|
|
4
|
-
module.exports = exports = async ({ language: { projectFilePath }, go }, next) => {
|
|
5
|
-
let cmdStdout;
|
|
6
|
-
let cwd;
|
|
7
|
-
try {
|
|
8
|
-
cwd = projectFilePath.replace('go.mod', '');
|
|
9
|
-
cmdStdout = child_process.execSync('go mod graph', { cwd });
|
|
10
|
-
go.modGraphOutput = cmdStdout.toString();
|
|
11
|
-
next();
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
if (err.message === 'spawnSync /bin/sh ENOENT') {
|
|
15
|
-
err.message =
|
|
16
|
-
'\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.';
|
|
17
|
-
}
|
|
18
|
-
next(new Error(i18n.__('goReadProjectFile', cwd, `${err.message ? err.message : ''}`)));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const AnalysisEngine = require('../AnalysisEngine');
|
|
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
|
-
module.exports = exports = (language, config, callback) => {
|
|
9
|
-
const ae = new AnalysisEngine({ language, config, java: {} });
|
|
10
|
-
language.projectFilePath = language.projectFilePath.replace('build.gradle.kts', 'build.gradle');
|
|
11
|
-
if (config['beta_unified_java_parser']) {
|
|
12
|
-
console.log('Using new parser...');
|
|
13
|
-
ae.use([readProjectFileContents, parseProjectFileContents, sanitizer]);
|
|
14
|
-
}
|
|
15
|
-
else if (language.projectFilePath.endsWith('pom.xml') &&
|
|
16
|
-
!config['beta_unified_java_parser']) {
|
|
17
|
-
ae.use([readProjectFileContents, parseMavenProjectFileContents, sanitizer]);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
ae.use([
|
|
21
|
-
readProjectFileContents,
|
|
22
|
-
parseMavenProjectFileContents,
|
|
23
|
-
parseProjectFileContents,
|
|
24
|
-
sanitizer
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
27
|
-
ae.analyze((err, analysis) => {
|
|
28
|
-
if (err) {
|
|
29
|
-
console.log(i18n.__('javaAnalysisError'), err.message);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
callback(null, analysis, config);
|
|
33
|
-
}, config);
|
|
34
|
-
};
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const i18n = require('i18n');
|
|
3
|
-
module.exports = exports = ({ language: { projectFilePath }, java }, next) => {
|
|
4
|
-
const { mvnDependancyTreeOutput } = java;
|
|
5
|
-
if (projectFilePath.endsWith('pom.xml')) {
|
|
6
|
-
try {
|
|
7
|
-
java.mavenDependencyTrees = parseMvn(mvnDependancyTreeOutput);
|
|
8
|
-
next();
|
|
9
|
-
}
|
|
10
|
-
catch (err) {
|
|
11
|
-
next(new Error(i18n.__('javaParseProjectFile') + `${err.message}`));
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
next();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const hasVersion = key => {
|
|
20
|
-
var regex = RegExp('[0-9].[0-9]');
|
|
21
|
-
return regex.test(key);
|
|
22
|
-
};
|
|
23
|
-
const formatKeyName = value => {
|
|
24
|
-
let tempArr = value.split(':');
|
|
25
|
-
let versionIndex = undefined;
|
|
26
|
-
for (let i = 0; i < tempArr.length; i++) {
|
|
27
|
-
if (hasVersion(tempArr[i])) {
|
|
28
|
-
versionIndex = i;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return tempArr[0] + '/' + tempArr[1] + '@' + tempArr[versionIndex];
|
|
32
|
-
};
|
|
33
|
-
const shaveConsoleOutputUntilItFindsFirsDigraphMention = mvnDependancyTreeOutput => {
|
|
34
|
-
return mvnDependancyTreeOutput.substring(mvnDependancyTreeOutput.indexOf('digraph'));
|
|
35
|
-
};
|
|
36
|
-
const getDigraphObjInfo = editedOutput => {
|
|
37
|
-
let digraphObj = editedOutput.split('digraph');
|
|
38
|
-
return digraphObj.filter(v => v != '');
|
|
39
|
-
};
|
|
40
|
-
const createDigraphObjKey = element => {
|
|
41
|
-
let formatObjKey = element.substring(0, element.indexOf('{'));
|
|
42
|
-
formatObjKey = formatObjKey.replace(/"/g, '');
|
|
43
|
-
formatObjKey = formatObjKey.replace('{', '');
|
|
44
|
-
formatObjKey = formatObjKey.trim();
|
|
45
|
-
return formatObjKey;
|
|
46
|
-
};
|
|
47
|
-
const turnDigraphDependanciesIntoArrOfInnerDep = digraphObj => {
|
|
48
|
-
let depRow = digraphObj.substring(digraphObj.indexOf('{'), digraphObj.indexOf('}') + 1);
|
|
49
|
-
depRow = depRow.replace(/\[INFO\]/g, '');
|
|
50
|
-
depRow = depRow.replace(/\n/g, '');
|
|
51
|
-
depRow = depRow.replace(/\{/g, '');
|
|
52
|
-
depRow = depRow.replace(/\}/g, '');
|
|
53
|
-
depRow = depRow.replace(/\"/g, '');
|
|
54
|
-
return depRow.split(';').map(s => s.trim());
|
|
55
|
-
};
|
|
56
|
-
const createOuterDependanciesAndType = (digraphObjKey, arrOfInnerDep) => {
|
|
57
|
-
let leftKey;
|
|
58
|
-
let rightKey;
|
|
59
|
-
let newDepNode;
|
|
60
|
-
const list = [];
|
|
61
|
-
arrOfInnerDep.forEach(element => {
|
|
62
|
-
leftKey = element.substring(0, element.indexOf(' -'));
|
|
63
|
-
rightKey = element.substring(element.indexOf('>') + 2);
|
|
64
|
-
if (leftKey === digraphObjKey) {
|
|
65
|
-
if (hasVersion(rightKey)) {
|
|
66
|
-
let rightKeyArr = rightKey.split(':');
|
|
67
|
-
newDepNode = {
|
|
68
|
-
[rightKey]: {
|
|
69
|
-
group: rightKeyArr[0],
|
|
70
|
-
artifactID: rightKeyArr[1],
|
|
71
|
-
packaging: rightKeyArr[2],
|
|
72
|
-
version: rightKeyArr[3],
|
|
73
|
-
scope: rightKeyArr[4],
|
|
74
|
-
type: 'direct',
|
|
75
|
-
parent: leftKey,
|
|
76
|
-
edges: {}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
list.push(newDepNode);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (hasVersion(leftKey) &&
|
|
83
|
-
hasVersion(rightKey) &&
|
|
84
|
-
!(leftKey === digraphObjKey)) {
|
|
85
|
-
let rightKeyArr = rightKey.split(':');
|
|
86
|
-
newDepNode = {
|
|
87
|
-
[rightKey]: {
|
|
88
|
-
group: rightKeyArr[0],
|
|
89
|
-
artifactID: rightKeyArr[1],
|
|
90
|
-
packaging: rightKeyArr[2],
|
|
91
|
-
version: rightKeyArr[3],
|
|
92
|
-
scope: rightKeyArr[4],
|
|
93
|
-
type: 'transitive',
|
|
94
|
-
parent: leftKey,
|
|
95
|
-
edges: {}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
list.push(newDepNode);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return list;
|
|
102
|
-
};
|
|
103
|
-
const createEdges = (digraphObjKey, listOuterDep) => {
|
|
104
|
-
listOuterDep.forEach(element => {
|
|
105
|
-
const key = Object.keys(element).toString();
|
|
106
|
-
const childParentRef = element[key].parent;
|
|
107
|
-
if (childParentRef !== digraphObjKey) {
|
|
108
|
-
listOuterDep.forEach(i => {
|
|
109
|
-
let parentKey = Object.keys(i).toString();
|
|
110
|
-
if (childParentRef === parentKey) {
|
|
111
|
-
i[parentKey].edges[formatKeyName(key)] = formatKeyName(key);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return listOuterDep;
|
|
117
|
-
};
|
|
118
|
-
const extractFromArrAndFinalParse = listWithEdges => {
|
|
119
|
-
let finalObj = {};
|
|
120
|
-
listWithEdges.forEach(element => {
|
|
121
|
-
const key = Object.keys(element).toString();
|
|
122
|
-
const parsedKey = formatKeyName(key);
|
|
123
|
-
delete element[key].parent;
|
|
124
|
-
finalObj[parsedKey] = element[key];
|
|
125
|
-
});
|
|
126
|
-
return finalObj;
|
|
127
|
-
};
|
|
128
|
-
const dependancyValueCreationOrganiser = (digraphObjKey, digraph) => {
|
|
129
|
-
const arrOfInnerDep = turnDigraphDependanciesIntoArrOfInnerDep(digraph);
|
|
130
|
-
const listOuterDep = createOuterDependanciesAndType(digraphObjKey, arrOfInnerDep);
|
|
131
|
-
const listWithEdges = createEdges(digraphObjKey, listOuterDep);
|
|
132
|
-
const finishDepObj = extractFromArrAndFinalParse(listWithEdges);
|
|
133
|
-
return finishDepObj;
|
|
134
|
-
};
|
|
135
|
-
const parseMvn = mvnDependancyTreeOutput => {
|
|
136
|
-
let parsedDepObj = {};
|
|
137
|
-
let editedOutput = shaveConsoleOutputUntilItFindsFirsDigraphMention(mvnDependancyTreeOutput);
|
|
138
|
-
let digraphObjArray = getDigraphObjInfo(editedOutput);
|
|
139
|
-
digraphObjArray.forEach(digraph => {
|
|
140
|
-
const digraphObjKey = createDigraphObjKey(digraph);
|
|
141
|
-
parsedDepObj[digraphObjKey] = dependancyValueCreationOrganiser(digraphObjKey, digraph);
|
|
142
|
-
});
|
|
143
|
-
return parsedDepObj;
|
|
144
|
-
};
|
|
145
|
-
exports.shaveConsoleOutputUntilItFindsFirsDigraphMention =
|
|
146
|
-
shaveConsoleOutputUntilItFindsFirsDigraphMention;
|
|
147
|
-
exports.getDigraphObjInfo = getDigraphObjInfo;
|
|
148
|
-
exports.createDigraphObjKey = createDigraphObjKey;
|
|
149
|
-
exports.turnDigraphDependanciesIntoArrOfInnerDep =
|
|
150
|
-
turnDigraphDependanciesIntoArrOfInnerDep;
|
|
151
|
-
exports.hasVersion = hasVersion;
|
|
152
|
-
exports.formatKeyName = formatKeyName;
|
|
153
|
-
exports.createOuterDependanciesAndType = createOuterDependanciesAndType;
|
|
154
|
-
exports.extractFromArrAndFinalParse = extractFromArrAndFinalParse;
|
|
155
|
-
exports.createEdges = createEdges;
|