@contrast/contrast 3.0.0 → 3.1.0

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.
@@ -42,7 +42,7 @@ const retrieveProjectByOrganizationIdUrl = (config) => {
42
42
  ? baseUrl.concat(`?name=${config.name}`)
43
43
  : baseUrl.concat(`?name=${config.fileName}`);
44
44
  baseUrl = config.language
45
- ? baseUrl.concat(`&language=${config.language}`)
45
+ ? baseUrl.concat(`&language=${config.language === 'DOTNET' ? 'DOT_NET' : config.language}`)
46
46
  : baseUrl;
47
47
  baseUrl = config.language ? baseUrl.concat(`&source=SCA`) : baseUrl;
48
48
  baseUrl = config.repo
@@ -54,7 +54,7 @@ export async function registerProjectGroup(config, requestBody) {
54
54
  const options = buildBaseRequestOptions(config, ErrorType.GENERIC);
55
55
  options.url = registerProjectGroupUrl(config);
56
56
  options.json = requestBody;
57
- logDebug(config, 'registerProjectGroup');
57
+ logDebug(config, `registerProjectGroup ${options.json}`);
58
58
  logDebug(config, `url ${options.url}`);
59
59
  try {
60
60
  return await got.post(options);
package/dist/auth/auth.js CHANGED
@@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid';
2
2
  import i18n from 'i18n';
3
3
  import { failSpinner, returnOra, startSpinner, succeedSpinner } from '../utils/oraWrapper.js';
4
4
  import { en_locales } from '../constants/locales.js';
5
- import { AUTH_UI_URL, TIMEOUT } from '../constants/constants.js';
5
+ import { AUTH_UI_URL, CE_URL, TIMEOUT } from '../constants/constants.js';
6
6
  import { setConfigValues } from '../utils/getConfig.js';
7
7
  import commandLineUsage from 'command-line-usage';
8
8
  import { commonMessageFormatter } from '../common/errorHandling.js';
@@ -14,6 +14,10 @@ import { logDebug, logInfo } from '../common/logging.js';
14
14
  const messages = en_locales();
15
15
  export const processAuth = async (argv, config) => {
16
16
  const authParams = await getCommandLineArgsCustom(config, 'auth', argv, commandLineDefinitions.authOptionDefinitions);
17
+ if (authParams.host === CE_URL) {
18
+ logInfo(i18n.__('codeSecEoL'));
19
+ process.exit(0);
20
+ }
17
21
  if (authParams.help) {
18
22
  logInfo(authUsageGuide);
19
23
  process.exit(0);
@@ -76,9 +80,9 @@ const authUsageGuide = commandLineUsage([
76
80
  }
77
81
  ]);
78
82
  const checkForCustomCredentials = (authParams) => {
79
- const hasSomeKeys = authParams.apiKey ||
80
- authParams.organizationId ||
81
- authParams.host ||
83
+ const hasSomeKeys = authParams.apiKey ??
84
+ authParams.organizationId ??
85
+ authParams.host ??
82
86
  authParams.authorization;
83
87
  const hasAllKeys = authParams.apiKey &&
84
88
  authParams.organizationId &&
@@ -54,7 +54,7 @@ export const detectPackageManager = array => {
54
54
  i['language'] = PYTHON;
55
55
  i['packageManager'] = 'PYPI';
56
56
  }
57
- if (i.filePath && i.filePath.includes('csproj')) {
57
+ if (i.filePath && i.filePath.includes('packages-lock.json')) {
58
58
  i['language'] = DOTNET;
59
59
  i['packageManager'] = 'NUGET';
60
60
  }
@@ -17,7 +17,7 @@ export const HIGH = 'HIGH';
17
17
  export const CRITICAL = 'CRITICAL';
18
18
  // App
19
19
  export const APP_NAME = 'contrast';
20
- const APP_VERSION = '3.0.0';
20
+ const APP_VERSION = '3.1.0';
21
21
  export const TIMEOUT = 120000;
22
22
  export const CRITICAL_PRIORITY = 1;
23
23
  export const HIGH_PRIORITY = 2;
@@ -74,7 +74,7 @@ export const createProject = (param, shortenedProjectName) => {
74
74
  path: param.fileName,
75
75
  name: param.repo ? shortenedProjectName : getProjectName(param),
76
76
  source: 'SCA',
77
- language: param.language,
77
+ language: param.language === 'DOTNET' ? 'DOT_NET' : param.language,
78
78
  packageManager: param.packageManager,
79
79
  target: 'SCA',
80
80
  sourceId: ''
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ import { processSarif } from './sarif/generateSarif.js';
18
18
  import { logInfo } from './common/logging.js';
19
19
  import { generateYamlConfiguration } from './generateYaml/index.js';
20
20
  import i18n from 'i18n';
21
+ import { exit } from 'process';
21
22
  const config = localConfig(APP_NAME, getAppVersion());
22
23
  const getMainOption = () => {
23
24
  const mainOptions = commandLineArgs(commandLineDefinitions.mainDefinition, {
@@ -25,7 +26,7 @@ const getMainOption = () => {
25
26
  camelCase: true,
26
27
  caseInsensitive: true
27
28
  });
28
- const argv = mainOptions._unknown || [];
29
+ const argv = mainOptions._unknown ?? [];
29
30
  return {
30
31
  mainOptions,
31
32
  argv
@@ -62,6 +63,7 @@ const start = async () => {
62
63
  }
63
64
  if (config.get('host') === CE_URL) {
64
65
  logInfo(i18n.__('codeSecEoL'));
66
+ exit(0);
65
67
  }
66
68
  if (command === 'lambda') {
67
69
  return await processLambda(argvMain);
@@ -1,6 +1,10 @@
1
1
  import { getDotNetDeps } from './analysis.js';
2
2
  import { createDotNetTSMessage } from '../common/formatMessage.js';
3
+ import { parseDotNet } from './scaServiceParser.js';
3
4
  export const dotNetAnalysis = (config, languageFiles) => {
4
5
  const dotNetDeps = getDotNetDeps(config, languageFiles.DOTNET);
6
+ if (config.legacy === false) {
7
+ return parseDotNet(dotNetDeps);
8
+ }
5
9
  return createDotNetTSMessage(dotNetDeps);
6
10
  };
@@ -0,0 +1,17 @@
1
+ export const parseDotNet = rawNode => {
2
+ let dependencyTree = {};
3
+ const dependencies = rawNode?.lockFile?.dependencies || {};
4
+ for (const [framework, frameworkDeps] of Object.entries(dependencies)) {
5
+ for (const [depName, depDetails] of Object.entries(frameworkDeps)) {
6
+ dependencyTree[depName] = {
7
+ group: depName,
8
+ name: `${depName}.dll`,
9
+ directDependency: 'true',
10
+ version: depDetails.resolved,
11
+ dependencies: Object.keys(depDetails.dependencies || []).map(key => `"${key}"`),
12
+ productionDependency: depDetails.type === 'Direct' || depDetails.type === 'Transitive'
13
+ };
14
+ }
15
+ }
16
+ return dependencyTree;
17
+ };
@@ -71,15 +71,10 @@ export const processSca = async (config) => {
71
71
  messageToSend = await determineFlow(config, filesFound, goAnalysis);
72
72
  break;
73
73
  case DOTNET:
74
- if (config.legacy === false) {
75
- logInfo(`${chalk.bold('\n.NET project found\n')} Language type is unsupported.`);
76
- return;
77
- }
78
- else {
79
- messageToSend = dotNetAnalysis(config, filesFound[0]);
80
- config.language = DOTNET;
81
- break;
82
- }
74
+ config.language = DOTNET;
75
+ config.packageManager = 'NUGET';
76
+ messageToSend = dotNetAnalysis(config, filesFound[0]);
77
+ break;
83
78
  default:
84
79
  //something is wrong
85
80
  logInfo('No supported language detected in project path');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/contrast",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Contrast Security's command line tool",
5
5
  "exports": "./dist/index.js",
6
6
  "type": "module",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@aws-sdk/client-iam": "3.370.0",
57
- "@aws-sdk/client-lambda": "3.370.0",
57
+ "@aws-sdk/client-lambda": "3.782.0",
58
58
  "@aws-sdk/config-resolver": "^3.374.0",
59
59
  "@aws-sdk/credential-provider-ini": "3.370.0",
60
60
  "@aws-sdk/middleware-signing": "3.370.0",
@@ -64,13 +64,13 @@
64
64
  "cli-table3": "0.6.3",
65
65
  "command-line-args": "5.2.1",
66
66
  "command-line-usage": "6.1.3",
67
- "conf": "11.0.2",
68
- "cross-spawn": "7.0.3",
67
+ "conf": "13.1.0",
68
+ "cross-spawn": "7.0.6",
69
69
  "fast-glob": "3.3.1",
70
- "fast-xml-parser": "4.2.6",
70
+ "fast-xml-parser": "5.2.0",
71
71
  "form-data": "4.0.0",
72
72
  "g": "^2.0.1",
73
- "got": "13.0.0",
73
+ "got": "14.4.7",
74
74
  "gradle-to-js": "2.0.1",
75
75
  "hpagent": "1.2.0",
76
76
  "i18n": "0.15.1",
@@ -88,7 +88,7 @@
88
88
  "yarn-lockfile": "1.1.1"
89
89
  },
90
90
  "devDependencies": {
91
- "@babel/core": "7.21.8",
91
+ "@babel/core": "7.23.2",
92
92
  "@babel/preset-modules": "0.1.6",
93
93
  "@types/command-line-args": "5.2.0",
94
94
  "@types/command-line-usage": "5.0.2",
@@ -101,13 +101,13 @@
101
101
  "@typescript-eslint/parser": "5.62.0",
102
102
  "@vitest/coverage-v8": "0.34.3",
103
103
  "csv-writer": "1.6.0",
104
- "dotenv": "16.3.1",
105
- "esbuild": "0.18.16",
106
- "eslint": "8.45.0",
107
- "eslint-config-prettier": "8.8.0",
108
- "eslint-plugin-prettier": "4.2.1",
104
+ "dotenv": "16.4.7",
105
+ "esbuild": "0.25.2",
106
+ "eslint": "9.24.0",
107
+ "eslint-config-prettier": "10.1.1",
108
+ "eslint-plugin-prettier": "5.2.6",
109
109
  "husky": "3.1.0",
110
- "mocha": "10.2.0",
110
+ "mocha": "11.1.0",
111
111
  "nock": "13.3.2",
112
112
  "npm-license-crawler": "0.2.1",
113
113
  "prettier": "2.8.8",
@@ -116,7 +116,7 @@
116
116
  "ts-node": "^10.9.2",
117
117
  "typescript": "5.1.6",
118
118
  "uuid": "9.0.0",
119
- "vitest": "1.4.0"
119
+ "vitest": "1.6.1"
120
120
  },
121
121
  "resolutions": {
122
122
  "faker": "5.5.3",