@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
|
@@ -3,11 +3,7 @@ const analysis = require('./analysis');
|
|
|
3
3
|
const i18n = require('i18n');
|
|
4
4
|
const formatMessage = require('../common/formatMessage');
|
|
5
5
|
const jsAnalysis = async (config, languageFiles) => {
|
|
6
|
-
|
|
7
|
-
languageFiles.JAVASCRIPT.includes('yarn.lock')) {
|
|
8
|
-
console.log(i18n.__('languageAnalysisMultipleLanguages1'));
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
6
|
+
checkForCorrectFiles(languageFiles);
|
|
11
7
|
return buildNodeTree(config, languageFiles.JAVASCRIPT);
|
|
12
8
|
};
|
|
13
9
|
const buildNodeTree = async (config, files) => {
|
|
@@ -36,6 +32,19 @@ const parseFiles = async (config, files, js) => {
|
|
|
36
32
|
}
|
|
37
33
|
return js;
|
|
38
34
|
};
|
|
35
|
+
const checkForCorrectFiles = languageFiles => {
|
|
36
|
+
if (languageFiles.JAVASCRIPT.includes('package-lock.json') &&
|
|
37
|
+
languageFiles.JAVASCRIPT.includes('yarn.lock')) {
|
|
38
|
+
throw new Error(i18n.__('languageAnalysisHasMultipleLockFiles', 'javascript'));
|
|
39
|
+
}
|
|
40
|
+
if (!languageFiles.JAVASCRIPT.includes('package-lock.json') &&
|
|
41
|
+
!languageFiles.JAVASCRIPT.includes('yarn.lock')) {
|
|
42
|
+
throw new Error(i18n.__('languageAnalysisHasNoLockFile', 'javascript'));
|
|
43
|
+
}
|
|
44
|
+
if (!languageFiles.JAVASCRIPT.includes('package.json')) {
|
|
45
|
+
throw new Error(i18n.__('languageAnalysisHasNoPackageJsonFile'));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
39
48
|
module.exports = {
|
|
40
49
|
jsAnalysis
|
|
41
50
|
};
|
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const i18n = require('i18n');
|
|
4
4
|
const _ = require('lodash');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
catch (err) {
|
|
15
|
-
console.log(err.message.toString());
|
|
5
|
+
const readFile = (config, nameOfFile) => {
|
|
6
|
+
if (config.file) {
|
|
7
|
+
try {
|
|
8
|
+
return fs.readFileSync(config.file + '/' + nameOfFile);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.log('Unable to find file');
|
|
12
|
+
console.log(error);
|
|
13
|
+
}
|
|
16
14
|
}
|
|
17
15
|
};
|
|
18
|
-
const
|
|
19
|
-
const filePath = filePathForWindows(projectPath + customFile);
|
|
16
|
+
const parseProjectFiles = php => {
|
|
20
17
|
try {
|
|
21
|
-
php.
|
|
18
|
+
php.composerJSON.dependencies = php.composerJSON.require;
|
|
19
|
+
php.composerJSON.devDependencies = php.composerJSON['require-dev'];
|
|
22
20
|
php.lockFile = php.rawLockFileContents;
|
|
23
21
|
let packages = _.keyBy(php.lockFile.packages, 'name');
|
|
24
22
|
let packagesDev = _.keyBy(php.lockFile['packages-dev'], 'name');
|
|
@@ -50,22 +48,6 @@ const readAndParseLockFile = (projectPath, customFile) => {
|
|
|
50
48
|
return console.log(i18n.__('phpParseComposerLock', php) + `${err.message}`);
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
|
-
const getPhpDeps = (config, files) => {
|
|
54
|
-
try {
|
|
55
|
-
return (readProjectFile(config.file, files[0].projectFilename),
|
|
56
|
-
readAndParseLockFile(config.file, files[1].lockFilename));
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
console.log(err.message.toString());
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const filePathForWindows = path => {
|
|
64
|
-
if (process.platform === 'win32') {
|
|
65
|
-
path = path.replace(/\//g, '\\');
|
|
66
|
-
}
|
|
67
|
-
return path;
|
|
68
|
-
};
|
|
69
51
|
function addChildDepToLockFileAsOwnObj(php, depObj, key) {
|
|
70
52
|
php.lockFile.dependencies[key] = { version: depObj[key] };
|
|
71
53
|
}
|
|
@@ -83,7 +65,6 @@ function formatParentDepToLockFile(php) {
|
|
|
83
65
|
}
|
|
84
66
|
}
|
|
85
67
|
module.exports = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
readProjectFile
|
|
68
|
+
parseProjectFiles,
|
|
69
|
+
readFile
|
|
89
70
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const {
|
|
2
|
+
const { readFile, parseProjectFiles } = require('./analysis');
|
|
3
3
|
const { createPhpTSMessage } = require('../common/formatMessage');
|
|
4
|
-
const phpAnalysis = (config,
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const phpAnalysis = (config, files) => {
|
|
5
|
+
let analysis = readFiles(config, files.PHP);
|
|
6
|
+
const phpDep = parseProjectFiles(analysis);
|
|
7
|
+
return createPhpTSMessage(phpDep);
|
|
8
|
+
};
|
|
9
|
+
const readFiles = (config, files) => {
|
|
10
|
+
let php = {};
|
|
11
|
+
php.composerJSON = JSON.parse(readFile(config, 'composer.json'));
|
|
12
|
+
php.rawLockFileContents = JSON.parse(readFile(config, 'composer.lock'));
|
|
13
|
+
return php;
|
|
7
14
|
};
|
|
8
15
|
module.exports = {
|
|
9
16
|
phpAnalysis
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const readAndParseGemfile = file => {
|
|
4
|
-
const
|
|
5
|
-
const gemFile = fs.readFileSync(fileName, 'utf8');
|
|
4
|
+
const gemFile = fs.readFileSync(file + '/Gemfile', 'utf8');
|
|
6
5
|
const rubyArray = gemFile.split('\n');
|
|
7
6
|
let filteredRubyDep = rubyArray.filter(element => {
|
|
8
7
|
return (!element.includes('#') &&
|
|
@@ -15,8 +14,7 @@ const readAndParseGemfile = file => {
|
|
|
15
14
|
return filteredRubyDep;
|
|
16
15
|
};
|
|
17
16
|
const readAndParseGemLockFile = file => {
|
|
18
|
-
const
|
|
19
|
-
const lockFile = fs.readFileSync(fileName, 'utf8');
|
|
17
|
+
const lockFile = fs.readFileSync(file + '/Gemfile.lock', 'utf8');
|
|
20
18
|
const dependencyRegEx = /^\s*([A-Za-z0-9.!@#$%\-^&*_+]*)\s*(\((.*?)\))/;
|
|
21
19
|
const lines = lockFile.split('\n');
|
|
22
20
|
return {
|
|
@@ -204,12 +202,6 @@ const getRubyDeps = config => {
|
|
|
204
202
|
const trimWhiteSpace = string => {
|
|
205
203
|
return string.replace(/\s+/g, '');
|
|
206
204
|
};
|
|
207
|
-
const filePathForWindows = path => {
|
|
208
|
-
if (process.platform === 'win32') {
|
|
209
|
-
path = path.replace(/\//g, '\\');
|
|
210
|
-
}
|
|
211
|
-
return path;
|
|
212
|
-
};
|
|
213
205
|
module.exports = {
|
|
214
206
|
getRubyDeps,
|
|
215
207
|
readAndParseGemfile,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const i18n = require('i18n');
|
|
3
3
|
const fileFinder = require('./fileUtils');
|
|
4
|
-
const languageResolver = require('../audit/languageAnalysisEngine/reduceIdentifiedLanguages');
|
|
5
4
|
const rootFile = require('../audit/languageAnalysisEngine/getProjectRootFilenames');
|
|
6
5
|
const autoDetectFileAndLanguage = async (configToUse) => {
|
|
7
6
|
const entries = await fileFinder.findFile();
|
|
@@ -24,31 +23,30 @@ const autoDetectFileAndLanguage = async (configToUse) => {
|
|
|
24
23
|
errorOnFileDetection(entries);
|
|
25
24
|
}
|
|
26
25
|
};
|
|
27
|
-
const autoDetectAuditFilesAndLanguages = async () => {
|
|
26
|
+
const autoDetectAuditFilesAndLanguages = async (file) => {
|
|
27
|
+
const filePath = file;
|
|
28
28
|
let languagesFound = [];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
if (filePath) {
|
|
30
|
+
rootFile.getProjectRootFilenames(filePath);
|
|
31
|
+
console.log(i18n.__('searchingAuditFileDirectory', filePath));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(i18n.__('searchingAuditFileDirectory', process.cwd()));
|
|
35
|
+
}
|
|
36
|
+
await fileFinder.findFilesJava(languagesFound, filePath);
|
|
37
|
+
await fileFinder.findFilesJavascript(languagesFound, filePath);
|
|
38
|
+
await fileFinder.findFilesPython(languagesFound, filePath);
|
|
39
|
+
await fileFinder.findFilesGo(languagesFound, filePath);
|
|
40
|
+
await fileFinder.findFilesPhp(languagesFound, filePath);
|
|
41
|
+
await fileFinder.findFilesRuby(languagesFound, filePath);
|
|
42
|
+
await fileFinder.findFilesDotNet(languagesFound, filePath);
|
|
43
|
+
if (languagesFound.length <= 1) {
|
|
37
44
|
return languagesFound;
|
|
38
45
|
}
|
|
39
46
|
else {
|
|
40
47
|
console.log('found multiple languages, please specify one using --file to run SCA audit');
|
|
41
48
|
}
|
|
42
49
|
};
|
|
43
|
-
const manualDetectAuditFilesAndLanguages = file => {
|
|
44
|
-
let projectRootFilenames = rootFile.getProjectRootFilenames(file);
|
|
45
|
-
let identifiedLanguages = languageResolver.deduceLanguageScaAnalysis(projectRootFilenames);
|
|
46
|
-
if (Object.keys(identifiedLanguages).length === 0) {
|
|
47
|
-
console.log(i18n.__('languageAnalysisNoLanguage', file));
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
return [identifiedLanguages];
|
|
51
|
-
};
|
|
52
50
|
const hasWhiteSpace = s => {
|
|
53
51
|
const filename = s.split('/').pop();
|
|
54
52
|
return filename.indexOf(' ') >= 0;
|
|
@@ -88,6 +86,5 @@ module.exports = {
|
|
|
88
86
|
autoDetectFileAndLanguage,
|
|
89
87
|
errorOnFileDetection,
|
|
90
88
|
autoDetectAuditFilesAndLanguages,
|
|
91
|
-
errorOnAuditFileDetection
|
|
92
|
-
manualDetectAuditFilesAndLanguages
|
|
89
|
+
errorOnAuditFileDetection
|
|
93
90
|
};
|
package/dist/scan/fileUtils.js
CHANGED
|
@@ -10,72 +10,90 @@ const findFile = async () => {
|
|
|
10
10
|
onlyFiles: true
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
const findFilesJava = async (languagesFound) => {
|
|
13
|
+
const findFilesJava = async (languagesFound, filePath) => {
|
|
14
14
|
const result = await fg(['**/pom.xml', '**/build.gradle', '**/build.gradle.kts'], {
|
|
15
15
|
dot: false,
|
|
16
16
|
deep: 1,
|
|
17
|
-
onlyFiles: true
|
|
17
|
+
onlyFiles: true,
|
|
18
|
+
cwd: filePath ? filePath : process.cwd()
|
|
18
19
|
});
|
|
19
20
|
if (result.length > 0) {
|
|
20
21
|
return languagesFound.push({ JAVA: result });
|
|
21
22
|
}
|
|
22
23
|
return languagesFound;
|
|
23
24
|
};
|
|
24
|
-
const findFilesJavascript = async (languagesFound) => {
|
|
25
|
+
const findFilesJavascript = async (languagesFound, filePath) => {
|
|
25
26
|
const result = await fg(['**/package.json', '**/yarn.lock', '**/package-lock.json'], {
|
|
26
27
|
dot: false,
|
|
27
28
|
deep: 1,
|
|
28
|
-
onlyFiles: true
|
|
29
|
+
onlyFiles: true,
|
|
30
|
+
cwd: filePath ? filePath : process.cwd()
|
|
29
31
|
});
|
|
30
32
|
if (result.length > 0) {
|
|
31
33
|
return languagesFound.push({ JAVASCRIPT: result });
|
|
32
34
|
}
|
|
33
35
|
return languagesFound;
|
|
34
36
|
};
|
|
35
|
-
const findFilesPython = async (languagesFound) => {
|
|
37
|
+
const findFilesPython = async (languagesFound, filePath) => {
|
|
36
38
|
const result = await fg(['**/Pipfile.lock', '**/Pipfile'], {
|
|
37
39
|
dot: false,
|
|
38
40
|
deep: 3,
|
|
39
|
-
onlyFiles: true
|
|
41
|
+
onlyFiles: true,
|
|
42
|
+
cwd: filePath ? filePath : process.cwd()
|
|
40
43
|
});
|
|
41
44
|
if (result.length > 0) {
|
|
42
45
|
return languagesFound.push({ PYTHON: result });
|
|
43
46
|
}
|
|
44
47
|
return languagesFound;
|
|
45
48
|
};
|
|
46
|
-
const findFilesGo = async (languagesFound) => {
|
|
49
|
+
const findFilesGo = async (languagesFound, filePath) => {
|
|
47
50
|
const result = await fg(['**/go.mod'], {
|
|
48
51
|
dot: false,
|
|
49
52
|
deep: 3,
|
|
50
|
-
onlyFiles: true
|
|
53
|
+
onlyFiles: true,
|
|
54
|
+
cwd: filePath ? filePath : process.cwd()
|
|
51
55
|
});
|
|
52
56
|
if (result.length > 0) {
|
|
53
57
|
return languagesFound.push({ GO: result });
|
|
54
58
|
}
|
|
55
59
|
return languagesFound;
|
|
56
60
|
};
|
|
57
|
-
const findFilesRuby = async (languagesFound) => {
|
|
61
|
+
const findFilesRuby = async (languagesFound, filePath) => {
|
|
58
62
|
const result = await fg(['**/Gemfile', '**/Gemfile.lock'], {
|
|
59
63
|
dot: false,
|
|
60
64
|
deep: 3,
|
|
61
|
-
onlyFiles: true
|
|
65
|
+
onlyFiles: true,
|
|
66
|
+
cwd: filePath ? filePath : process.cwd()
|
|
62
67
|
});
|
|
63
68
|
if (result.length > 0) {
|
|
64
69
|
return languagesFound.push({ RUBY: result });
|
|
65
70
|
}
|
|
66
71
|
return languagesFound;
|
|
67
72
|
};
|
|
68
|
-
const findFilesPhp = async (languagesFound) => {
|
|
73
|
+
const findFilesPhp = async (languagesFound, filePath) => {
|
|
69
74
|
const result = await fg(['**/composer.json', '**/composer.lock'], {
|
|
70
75
|
dot: false,
|
|
71
76
|
deep: 3,
|
|
72
|
-
onlyFiles: true
|
|
77
|
+
onlyFiles: true,
|
|
78
|
+
cwd: filePath ? filePath : process.cwd()
|
|
73
79
|
});
|
|
74
80
|
if (result.length > 0) {
|
|
75
81
|
return languagesFound.push({ PHP: result });
|
|
76
82
|
}
|
|
77
83
|
return languagesFound;
|
|
78
84
|
};
|
|
85
|
+
const findFilesDotNet = async (languagesFound, filePath) => {
|
|
86
|
+
const result = await fg(['**/*.csproj', '**/packages.lock.json'], {
|
|
87
|
+
dot: false,
|
|
88
|
+
deep: 3,
|
|
89
|
+
onlyFiles: true,
|
|
90
|
+
cwd: filePath ? filePath : process.cwd()
|
|
91
|
+
});
|
|
92
|
+
if (result.length > 0) {
|
|
93
|
+
return languagesFound.push({ DOTNET: result });
|
|
94
|
+
}
|
|
95
|
+
return languagesFound;
|
|
96
|
+
};
|
|
79
97
|
const checkFilePermissions = file => {
|
|
80
98
|
let readableFile = false;
|
|
81
99
|
try {
|
|
@@ -117,5 +135,6 @@ module.exports = {
|
|
|
117
135
|
findFilesGo,
|
|
118
136
|
findFilesPhp,
|
|
119
137
|
findFilesRuby,
|
|
138
|
+
findFilesDotNet,
|
|
120
139
|
fileIsEmpty
|
|
121
140
|
};
|
|
@@ -25,8 +25,9 @@ function formatScanOutput(scanResults) {
|
|
|
25
25
|
console.log(chalk_1.default.bold(message));
|
|
26
26
|
console.log();
|
|
27
27
|
let defaultView = getDefaultView(scanResultsInstances.content);
|
|
28
|
-
let count =
|
|
28
|
+
let count = 0;
|
|
29
29
|
defaultView.forEach(entry => {
|
|
30
|
+
count++;
|
|
30
31
|
let table = new cli_table3_1.default({
|
|
31
32
|
chars: {
|
|
32
33
|
top: '',
|
|
@@ -84,7 +85,6 @@ function formatScanOutput(scanResults) {
|
|
|
84
85
|
];
|
|
85
86
|
table.push(learnRow);
|
|
86
87
|
}
|
|
87
|
-
count--;
|
|
88
88
|
console.log(table.toString());
|
|
89
89
|
console.log();
|
|
90
90
|
});
|
|
@@ -149,7 +149,7 @@ function getDefaultView(content) {
|
|
|
149
149
|
groupTypeResults.push(groupResultsObj);
|
|
150
150
|
assignBySeverity(resultEntry, groupResultsObj);
|
|
151
151
|
});
|
|
152
|
-
return (0, lodash_1.sortBy)(groupTypeResults, ['priority'])
|
|
152
|
+
return (0, lodash_1.sortBy)(groupTypeResults, ['priority']);
|
|
153
153
|
}
|
|
154
154
|
exports.getDefaultView = getDefaultView;
|
|
155
155
|
function editVulName(message) {
|
package/dist/scan/scanConfig.js
CHANGED
|
@@ -3,7 +3,7 @@ const paramHandler = require('../utils/paramsUtil/paramHandler');
|
|
|
3
3
|
const constants = require('../../src/constants.js');
|
|
4
4
|
const parsedCLIOptions = require('../../src/utils/parsedCLIOptions');
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const {
|
|
6
|
+
const { supportedLanguagesScan } = require('../constants/constants');
|
|
7
7
|
const i18n = require('i18n');
|
|
8
8
|
const { scanUsageGuide } = require('./help');
|
|
9
9
|
const getScanConfig = argv => {
|
|
@@ -15,7 +15,7 @@ const getScanConfig = argv => {
|
|
|
15
15
|
const paramsAuth = paramHandler.getAuth(scanParams);
|
|
16
16
|
if (scanParams.language) {
|
|
17
17
|
scanParams.language = scanParams.language.toUpperCase();
|
|
18
|
-
if (!Object.values(
|
|
18
|
+
if (!Object.values(supportedLanguagesScan).includes(scanParams.language)) {
|
|
19
19
|
console.log(`Did not recognise --language ${scanParams.language}`);
|
|
20
20
|
console.log(i18n.__('constantsHowToRunDev3'));
|
|
21
21
|
process.exit(1);
|
package/dist/utils/getConfig.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setConfigValues = exports.
|
|
6
|
+
exports.setConfigValues = exports.localConfig = void 0;
|
|
7
7
|
const conf_1 = __importDefault(require("conf"));
|
|
8
8
|
const localConfig = (name, version) => {
|
|
9
9
|
const config = new conf_1.default({
|
|
@@ -19,11 +19,6 @@ const localConfig = (name, version) => {
|
|
|
19
19
|
return config;
|
|
20
20
|
};
|
|
21
21
|
exports.localConfig = localConfig;
|
|
22
|
-
const createConfigFromYaml = (yamlPath) => {
|
|
23
|
-
const yamlConfig = {};
|
|
24
|
-
return yamlConfig;
|
|
25
|
-
};
|
|
26
|
-
exports.createConfigFromYaml = createConfigFromYaml;
|
|
27
22
|
const setConfigValues = (config, values) => {
|
|
28
23
|
config.set('apiKey', values.apiKey);
|
|
29
24
|
config.set('organizationId', values.orgId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/contrast",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Contrast Security's command line tool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
"test": "jest --testPathIgnorePatterns=./test-integration/",
|
|
24
24
|
"test-int": "jest ./test-integration/",
|
|
25
25
|
"test-int-scan": "jest ./test-integration/scan",
|
|
26
|
-
"test-int-audit": "jest
|
|
27
|
-
"test-int-audit-experimental": "jest ./test-integration/audit/audit-experimental.spec.js",
|
|
26
|
+
"test-int-audit": "jest test-integration/audit/audit-int.spec.js",
|
|
28
27
|
"format": "prettier --write \"**/*.{ts,tsx,js,json,md,yml}\" .eslintrc.*",
|
|
29
28
|
"check-format": "prettier --check \"**/*.{ts,tsx,js,json,md,yml}\" .eslintrc.*",
|
|
30
29
|
"coverage-local": "nyc --reporter=text mocha './test/**/*.spec.js'",
|
|
@@ -1,35 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const i18n = require('i18n')
|
|
4
|
-
/**
|
|
5
|
-
* Will get the filenames from the project path provided to the SCA CLI tool. If
|
|
6
|
-
* the project path points to a file and not a directory will return the
|
|
7
|
-
* filename in the same fashion as if a directory had been read.
|
|
8
|
-
*
|
|
9
|
-
* Will fail and throw for a manner of reasons when doing file/directory
|
|
10
|
-
* inspection.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} file - The path to a projects root directory or a
|
|
13
|
-
* specific project file
|
|
14
|
-
*
|
|
15
|
-
* @return {string[]} List of filenames associated with a projects root
|
|
16
|
-
* directory or the name of the specific project file if that was provided to
|
|
17
|
-
* the 'file' parameter
|
|
18
|
-
*
|
|
19
|
-
* @throws {Error} If the project path doesn't exist
|
|
20
|
-
* @throws {Error} If the project path information can't be collected
|
|
21
|
-
* @throws {Error} If a non-file or non-directory inspected
|
|
22
|
-
*/
|
|
23
|
-
module.exports = exports = (analysis, next) => {
|
|
24
|
-
const { file, languageAnalysis } = analysis
|
|
25
|
-
try {
|
|
26
|
-
languageAnalysis.projectRootFilenames = getProjectRootFilenames(file)
|
|
27
|
-
} catch (err) {
|
|
28
|
-
next(err)
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
next()
|
|
32
|
-
}
|
|
33
4
|
|
|
34
5
|
const getProjectRootFilenames = file => {
|
|
35
6
|
let projectStats = null
|
|
@@ -67,6 +38,6 @@ const getProjectRootFilenames = file => {
|
|
|
67
38
|
file
|
|
68
39
|
)
|
|
69
40
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
41
|
+
module.exports = {
|
|
42
|
+
getProjectRootFilenames
|
|
43
|
+
}
|