@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.
Files changed (173) hide show
  1. package/dist/audit/languageAnalysisEngine/getProjectRootFilenames.js +3 -12
  2. package/dist/audit/languageAnalysisEngine/report/commonReportingFunctions.js +88 -53
  3. package/dist/audit/languageAnalysisEngine/report/models/reportOutputModel.js +4 -3
  4. package/dist/audit/languageAnalysisEngine/report/reportingFeature.js +58 -11
  5. package/dist/audit/languageAnalysisEngine/report/utils/reportUtils.js +38 -5
  6. package/dist/audit/languageAnalysisEngine/sendSnapshot.js +6 -30
  7. package/dist/audit/save.js +21 -13
  8. package/dist/commands/audit/auditConfig.js +0 -16
  9. package/dist/commands/audit/auditController.js +1 -10
  10. package/dist/commands/audit/help.js +7 -24
  11. package/dist/commands/audit/processAudit.js +1 -7
  12. package/dist/commands/audit/saveFile.js +2 -2
  13. package/dist/commands/scan/sca/scaAnalysis.js +22 -9
  14. package/dist/common/HTTPClient.js +8 -8
  15. package/dist/constants/constants.js +7 -2
  16. package/dist/constants/locales.js +24 -30
  17. package/dist/constants.js +11 -9
  18. package/dist/index.js +54 -45
  19. package/dist/lambda/lambda.js +5 -2
  20. package/dist/sbom/generateSbom.js +2 -2
  21. package/dist/scaAnalysis/common/formatMessage.js +7 -1
  22. package/dist/scaAnalysis/common/treeUpload.js +4 -5
  23. package/dist/scaAnalysis/dotnet/analysis.js +43 -0
  24. package/dist/scaAnalysis/dotnet/index.js +10 -0
  25. package/dist/scaAnalysis/javascript/analysis.js +4 -7
  26. package/dist/scaAnalysis/javascript/index.js +14 -5
  27. package/dist/scaAnalysis/php/analysis.js +14 -33
  28. package/dist/scaAnalysis/php/index.js +11 -4
  29. package/dist/scaAnalysis/ruby/analysis.js +2 -10
  30. package/dist/scan/autoDetection.js +18 -21
  31. package/dist/scan/fileUtils.js +31 -12
  32. package/dist/scan/formatScanOutput.js +3 -3
  33. package/dist/scan/scanConfig.js +2 -2
  34. package/dist/utils/getConfig.js +1 -6
  35. package/package.json +2 -3
  36. package/src/audit/languageAnalysisEngine/getProjectRootFilenames.js +3 -32
  37. package/src/audit/languageAnalysisEngine/report/commonReportingFunctions.ts +128 -68
  38. package/src/audit/languageAnalysisEngine/report/models/reportOutputModel.ts +11 -5
  39. package/src/audit/languageAnalysisEngine/report/reportingFeature.ts +41 -19
  40. package/src/audit/languageAnalysisEngine/report/utils/reportUtils.ts +43 -4
  41. package/src/audit/languageAnalysisEngine/sendSnapshot.js +6 -32
  42. package/src/audit/save.js +32 -16
  43. package/src/commands/audit/auditConfig.ts +0 -25
  44. package/src/commands/audit/auditController.ts +0 -11
  45. package/src/commands/audit/help.ts +7 -24
  46. package/src/commands/audit/processAudit.ts +1 -7
  47. package/src/commands/audit/saveFile.ts +2 -2
  48. package/src/commands/scan/processScan.js +0 -1
  49. package/src/commands/scan/sca/scaAnalysis.js +28 -13
  50. package/src/common/HTTPClient.js +9 -9
  51. package/src/constants/constants.js +9 -3
  52. package/src/constants/locales.js +47 -35
  53. package/src/constants.js +12 -10
  54. package/src/index.ts +76 -66
  55. package/src/lambda/lambda.ts +5 -2
  56. package/src/lambda/types.ts +1 -0
  57. package/src/sbom/generateSbom.ts +2 -2
  58. package/src/scaAnalysis/common/formatMessage.js +8 -1
  59. package/src/scaAnalysis/common/treeUpload.js +4 -5
  60. package/src/scaAnalysis/dotnet/analysis.js +54 -0
  61. package/src/scaAnalysis/dotnet/index.js +11 -0
  62. package/src/scaAnalysis/javascript/analysis.js +6 -7
  63. package/src/scaAnalysis/javascript/index.js +23 -7
  64. package/src/scaAnalysis/php/analysis.js +15 -35
  65. package/src/scaAnalysis/php/index.js +15 -4
  66. package/src/scaAnalysis/ruby/analysis.js +2 -11
  67. package/src/scan/autoDetection.js +18 -24
  68. package/src/scan/fileUtils.js +33 -12
  69. package/src/scan/formatScanOutput.ts +3 -3
  70. package/src/scan/scanConfig.js +2 -4
  71. package/src/utils/getConfig.ts +1 -12
  72. package/dist/audit/AnalysisEngine.js +0 -37
  73. package/dist/audit/autodetection/autoDetectLanguage.js +0 -32
  74. package/dist/audit/dotnetAnalysisEngine/index.js +0 -25
  75. package/dist/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -35
  76. package/dist/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -15
  77. package/dist/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -18
  78. package/dist/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -14
  79. package/dist/audit/dotnetAnalysisEngine/sanitizer.js +0 -9
  80. package/dist/audit/goAnalysisEngine/index.js +0 -17
  81. package/dist/audit/goAnalysisEngine/parseProjectFileContents.js +0 -164
  82. package/dist/audit/goAnalysisEngine/readProjectFileContents.js +0 -21
  83. package/dist/audit/goAnalysisEngine/sanitizer.js +0 -5
  84. package/dist/audit/javaAnalysisEngine/index.js +0 -34
  85. package/dist/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -155
  86. package/dist/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -353
  87. package/dist/audit/javaAnalysisEngine/readProjectFileContents.js +0 -98
  88. package/dist/audit/javaAnalysisEngine/sanitizer.js +0 -5
  89. package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -25
  90. package/dist/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -25
  91. package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -35
  92. package/dist/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -24
  93. package/dist/audit/languageAnalysisEngine/constants.js +0 -20
  94. package/dist/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -25
  95. package/dist/audit/languageAnalysisEngine/index.js +0 -39
  96. package/dist/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -66
  97. package/dist/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -166
  98. package/dist/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -40
  99. package/dist/audit/nodeAnalysisEngine/index.js +0 -31
  100. package/dist/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -18
  101. package/dist/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -18
  102. package/dist/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -17
  103. package/dist/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -14
  104. package/dist/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -24
  105. package/dist/audit/nodeAnalysisEngine/sanitizer.js +0 -9
  106. package/dist/audit/phpAnalysisEngine/index.js +0 -23
  107. package/dist/audit/phpAnalysisEngine/parseLockFileContents.js +0 -52
  108. package/dist/audit/phpAnalysisEngine/readLockFileContents.js +0 -13
  109. package/dist/audit/phpAnalysisEngine/readProjectFileContents.js +0 -16
  110. package/dist/audit/phpAnalysisEngine/sanitizer.js +0 -5
  111. package/dist/audit/pythonAnalysisEngine/index.js +0 -25
  112. package/dist/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -17
  113. package/dist/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -21
  114. package/dist/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -13
  115. package/dist/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -14
  116. package/dist/audit/pythonAnalysisEngine/sanitizer.js +0 -7
  117. package/dist/audit/rubyAnalysisEngine/index.js +0 -25
  118. package/dist/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -176
  119. package/dist/audit/rubyAnalysisEngine/parsedGemfile.js +0 -22
  120. package/dist/audit/rubyAnalysisEngine/readGemfileContents.js +0 -14
  121. package/dist/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -14
  122. package/dist/audit/rubyAnalysisEngine/sanitizer.js +0 -6
  123. package/src/audit/AnalysisEngine.js +0 -103
  124. package/src/audit/autodetection/autoDetectLanguage.ts +0 -40
  125. package/src/audit/dotnetAnalysisEngine/index.js +0 -26
  126. package/src/audit/dotnetAnalysisEngine/parseLockFileContents.js +0 -47
  127. package/src/audit/dotnetAnalysisEngine/parseProjectFileContents.js +0 -29
  128. package/src/audit/dotnetAnalysisEngine/readLockFileContents.js +0 -30
  129. package/src/audit/dotnetAnalysisEngine/readProjectFileContents.js +0 -26
  130. package/src/audit/dotnetAnalysisEngine/sanitizer.js +0 -11
  131. package/src/audit/goAnalysisEngine/index.js +0 -18
  132. package/src/audit/goAnalysisEngine/parseProjectFileContents.js +0 -209
  133. package/src/audit/goAnalysisEngine/readProjectFileContents.js +0 -31
  134. package/src/audit/goAnalysisEngine/sanitizer.js +0 -7
  135. package/src/audit/javaAnalysisEngine/index.js +0 -41
  136. package/src/audit/javaAnalysisEngine/parseMavenProjectFileContents.js +0 -225
  137. package/src/audit/javaAnalysisEngine/parseProjectFileContents.js +0 -420
  138. package/src/audit/javaAnalysisEngine/readProjectFileContents.js +0 -141
  139. package/src/audit/javaAnalysisEngine/sanitizer.js +0 -6
  140. package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedLanguages.js +0 -36
  141. package/src/audit/languageAnalysisEngine/checkForMultipleIdentifiedProjectFiles.js +0 -42
  142. package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasLockFile.js +0 -54
  143. package/src/audit/languageAnalysisEngine/checkIdentifiedLanguageHasProjectFile.js +0 -33
  144. package/src/audit/languageAnalysisEngine/constants.js +0 -23
  145. package/src/audit/languageAnalysisEngine/getIdentifiedLanguageInfo.js +0 -41
  146. package/src/audit/languageAnalysisEngine/index.js +0 -45
  147. package/src/audit/languageAnalysisEngine/languageAnalysisFactory.js +0 -96
  148. package/src/audit/languageAnalysisEngine/reduceIdentifiedLanguages.js +0 -251
  149. package/src/audit/nodeAnalysisEngine/handleNPMLockFileV2.js +0 -49
  150. package/src/audit/nodeAnalysisEngine/index.js +0 -35
  151. package/src/audit/nodeAnalysisEngine/parseNPMLockFileContents.js +0 -20
  152. package/src/audit/nodeAnalysisEngine/parseYarnLockFileContents.js +0 -26
  153. package/src/audit/nodeAnalysisEngine/readNPMLockFileContents.js +0 -23
  154. package/src/audit/nodeAnalysisEngine/readProjectFileContents.js +0 -27
  155. package/src/audit/nodeAnalysisEngine/readYarnLockFileContents.js +0 -36
  156. package/src/audit/nodeAnalysisEngine/sanitizer.js +0 -11
  157. package/src/audit/phpAnalysisEngine/index.js +0 -27
  158. package/src/audit/phpAnalysisEngine/parseLockFileContents.js +0 -60
  159. package/src/audit/phpAnalysisEngine/readLockFileContents.js +0 -14
  160. package/src/audit/phpAnalysisEngine/readProjectFileContents.js +0 -25
  161. package/src/audit/phpAnalysisEngine/sanitizer.js +0 -4
  162. package/src/audit/pythonAnalysisEngine/index.js +0 -55
  163. package/src/audit/pythonAnalysisEngine/parsePipfileLockContents.js +0 -23
  164. package/src/audit/pythonAnalysisEngine/parseProjectFileContents.js +0 -33
  165. package/src/audit/pythonAnalysisEngine/readPipfileLockFileContents.js +0 -16
  166. package/src/audit/pythonAnalysisEngine/readPythonProjectFileContents.js +0 -22
  167. package/src/audit/pythonAnalysisEngine/sanitizer.js +0 -9
  168. package/src/audit/rubyAnalysisEngine/index.js +0 -30
  169. package/src/audit/rubyAnalysisEngine/parseGemfileLockContents.js +0 -215
  170. package/src/audit/rubyAnalysisEngine/parsedGemfile.js +0 -39
  171. package/src/audit/rubyAnalysisEngine/readGemfileContents.js +0 -18
  172. package/src/audit/rubyAnalysisEngine/readGemfileLockContents.js +0 -17
  173. 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
- if (languageFiles.JAVASCRIPT.includes('package-lock.json') &&
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
- let php = {};
6
- const readProjectFile = (projectPath, customFile) => {
7
- const filePath = filePathForWindows(projectPath + customFile);
8
- try {
9
- php.composerJSON = JSON.parse(fs.readFileSync(filePath, 'utf8'));
10
- php.composerJSON.dependencies = php.composerJSON.require;
11
- php.composerJSON.devDependencies = php.composerJSON['require-dev'];
12
- return php;
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 readAndParseLockFile = (projectPath, customFile) => {
19
- const filePath = filePathForWindows(projectPath + customFile);
16
+ const parseProjectFiles = php => {
20
17
  try {
21
- php.rawLockFileContents = JSON.parse(fs.readFileSync(filePath, 'utf8'));
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
- getPhpDeps,
87
- readAndParseLockFile,
88
- readProjectFile
68
+ parseProjectFiles,
69
+ readFile
89
70
  };
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
- const { getPhpDeps } = require('./analysis');
2
+ const { readFile, parseProjectFiles } = require('./analysis');
3
3
  const { createPhpTSMessage } = require('../common/formatMessage');
4
- const phpAnalysis = (config, languageFiles) => {
5
- const phpDeps = getPhpDeps(config, languageFiles.PHP);
6
- return createPhpTSMessage(phpDeps);
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 fileName = filePathForWindows(file + '/Gemfile');
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 fileName = filePathForWindows(file + '/Gemfile.lock');
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
- console.log(i18n.__('searchingAuditFileDirectory', process.cwd()));
30
- await fileFinder.findFilesJava(languagesFound);
31
- await fileFinder.findFilesJavascript(languagesFound);
32
- await fileFinder.findFilesPython(languagesFound);
33
- await fileFinder.findFilesGo(languagesFound);
34
- await fileFinder.findFilesPhp(languagesFound);
35
- await fileFinder.findFilesRuby(languagesFound);
36
- if (languagesFound.length === 1) {
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
  };
@@ -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 = defaultView.length;
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']).reverse();
152
+ return (0, lodash_1.sortBy)(groupTypeResults, ['priority']);
153
153
  }
154
154
  exports.getDefaultView = getDefaultView;
155
155
  function editVulName(message) {
@@ -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 { supportedLanguages } = require('../audit/languageAnalysisEngine/constants');
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(supportedLanguages).includes(scanParams.language)) {
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);
@@ -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.createConfigFromYaml = exports.localConfig = void 0;
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.8",
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 ./test-integration/audit/audit.spec.js",
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
- //For testing purposes
72
- exports.getProjectRootFilenames = getProjectRootFilenames
41
+ module.exports = {
42
+ getProjectRootFilenames
43
+ }