@contrast/contrast 2.4.0 → 2.5.1

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/auth/auth.js CHANGED
@@ -23,7 +23,8 @@ export const processAuth = async (argv, config) => {
23
23
  processCustomCredentials(authParams, config);
24
24
  }
25
25
  else {
26
- await startAuthProcess(config);
26
+ logInfo(i18n.__('noParams'));
27
+ process.exit(0);
27
28
  }
28
29
  };
29
30
  const startAuthProcess = async (config) => {
@@ -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 = '2.4.0';
20
+ const APP_VERSION = '2.5.1';
21
21
  export const TIMEOUT = 120000;
22
22
  export const CRITICAL_PRIORITY = 1;
23
23
  export const HIGH_PRIORITY = 2;
@@ -206,7 +206,11 @@ export const en_locales = () => {
206
206
  lambdaJsonSummery: 'Return response in JSON (versus default human readable format).',
207
207
  lambdaVerbosSummery: 'Returns extended information to the terminal.',
208
208
  configNotFound: 'Configuration details not found. Try authenticating by using ‘contrast auth’.',
209
- redirectAuth: '\nOpening the authentication page in your web browser.\nSign in and complete the steps.\nReturn here to start using Contrast.\n\nIf your browser has trouble loading, try this:\n%s \n',
209
+ noParams: 'No parameters provided. \n' +
210
+ 'Please run `contrast auth --api-key <KEY> --authorization <TOKEN> --host <HOST> --organization-id <ORGID>`',
211
+ noHost: 'No host provided. \n' +
212
+ 'Please run `contrast auth --api-key <KEY> --authorization <TOKEN> --host <HOST> --organization-id <ORGID>`',
213
+ codeSecEoL: chalk.hex('#ef1414')('❗ WARNING: CodeSec / Community Edition is deprecated. Please configure the CLI with a valid Contrast host URL'),
210
214
  fileNotExist: 'File specified does not exist, please check and try again.',
211
215
  scanFileIsEmpty: 'File specified is empty. Please choose another.',
212
216
  fileHasWhiteSpacesError: 'File cannot have spaces, please rename or choose another file to Scan.',
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { localConfig } from './utils/getConfig.js';
3
- import { APP_NAME, getAppVersion } from './constants/constants.js';
3
+ import { APP_NAME, CE_URL, getAppVersion } from './constants/constants.js';
4
4
  import commandLineArgs from 'command-line-args';
5
5
  import { commandLineDefinitions } from './cliConstants.js';
6
6
  import { findLatestCLIVersion, isCorrectNodeVersion } from './common/versionChecker.js';
@@ -17,6 +17,7 @@ import { processAssess } from './assess/index.js';
17
17
  import { processSarif } from './sarif/generateSarif.js';
18
18
  import { logInfo } from './common/logging.js';
19
19
  import { generateYamlConfiguration } from './generateYaml/index.js';
20
+ import i18n from 'i18n';
20
21
  const config = localConfig(APP_NAME, getAppVersion());
21
22
  const getMainOption = () => {
22
23
  const mainOptions = commandLineArgs(commandLineDefinitions.mainDefinition, {
@@ -31,7 +32,6 @@ const getMainOption = () => {
31
32
  };
32
33
  };
33
34
  const start = async () => {
34
- // testing changes
35
35
  try {
36
36
  if (await isCorrectNodeVersion(process.version)) {
37
37
  const { mainOptions, argv: argvMain } = getMainOption();
@@ -55,11 +55,15 @@ const start = async () => {
55
55
  config.set('numOfRuns', 0);
56
56
  }
57
57
  if (command === 'config') {
58
+ console.log('config command');
58
59
  return processConfig(argvMain, config);
59
60
  }
60
61
  if (command === 'auth') {
61
62
  return await processAuth(argvMain, config);
62
63
  }
64
+ if (config.get('host') === CE_URL) {
65
+ logInfo(i18n.__('codeSecEoL'));
66
+ }
63
67
  if (command === 'lambda') {
64
68
  return await processLambda(argvMain);
65
69
  }
@@ -105,7 +109,7 @@ const start = async () => {
105
109
  process.exit(9);
106
110
  }
107
111
  else {
108
- logInfo('Contrast supports Node versions >=18.16.0 Node LTS. Please use one of those versions.');
112
+ logInfo('Contrast supports Node versions >=22.3.0 Node LTS. Please use one of those versions.');
109
113
  process.exit(9);
110
114
  }
111
115
  }
@@ -42,6 +42,9 @@ export const scaTreeUpload = async (analysis, config, reportSpinner) => {
42
42
  doPoll = false;
43
43
  const reportRes = await scaServiceReport(config, reportId);
44
44
  const reportBody = reportRes.body;
45
+ if (config.saveResults !== undefined) {
46
+ fs.writeFileSync('audit-results.json', JSON.stringify(reportBody));
47
+ }
45
48
  return { reportArray: reportBody, reportId: reportId };
46
49
  }
47
50
  handleTimeout(startTime, timeout, reportSpinner);
@@ -15,6 +15,6 @@ const setConfigValues = (config, values) => {
15
15
  config.set('apiKey', values.apiKey);
16
16
  config.set('organizationId', values.orgId);
17
17
  config.set('authorization', values.authHeader);
18
- values.host ? config.set('host', values.host) : config.set('host', CE_URL);
18
+ config.set('host', values.host);
19
19
  };
20
20
  export { localConfig, setConfigValues };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/contrast",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "Contrast Security's command line tool",
5
5
  "exports": "./dist/index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "scripts": {
27
27
  "build": "tsc",
28
28
  "build-binary": "esbuild src/index.ts --bundle --outdir=dist-binary --platform=node",
29
- "package-binary": "pkg dist-binary/index.js --out-path binaries --targets node18-macos,node18-linux,node18-win",
29
+ "package-binary": "pkg dist-binary/index.js --out-path binaries --targets node22-macos,node22-linux,node22-win",
30
30
  "build-package": "yarn build && yarn build-binary && yarn package-binary",
31
31
  "test": "export VITEST_MAX_THREADS=4 && export VITEST_MIN_THREADS=1 && vitest --dir ./tests/unit-tests/",
32
32
  "test-debug": "export VITEST_MAX_THREADS=4 && export VITEST_MIN_THREADS=1 && vitest --dir ./tests/unit-tests/ --inspect-brk",
@@ -50,7 +50,7 @@
50
50
  "proxy-tests": "vitest ./tests/integration-tests/proxy/proxy-coverage.spec.js --pool=forks"
51
51
  },
52
52
  "engines": {
53
- "node": ">=18.16.0"
53
+ "node": ">=22.3.0"
54
54
  },
55
55
  "dependencies": {
56
56
  "@aws-sdk/client-iam": "3.370.0",
@@ -84,6 +84,7 @@
84
84
  "semver": "7.5.4",
85
85
  "string-builder": "0.1.8",
86
86
  "string-multiple-replace": "1.0.5",
87
+ "tsx": "^4.19.2",
87
88
  "xml2js": "0.6.1",
88
89
  "yarn-lockfile": "1.1.1"
89
90
  },
@@ -100,9 +101,10 @@
100
101
  "@typescript-eslint/eslint-plugin": "5.62.0",
101
102
  "@typescript-eslint/parser": "5.62.0",
102
103
  "@vitest/coverage-v8": "0.34.3",
104
+ "@yao-pkg/pkg": "^6.1.0",
103
105
  "csv-writer": "1.6.0",
104
106
  "dotenv": "16.3.1",
105
- "esbuild": "0.18.16",
107
+ "esbuild": "0.25.1",
106
108
  "eslint": "8.45.0",
107
109
  "eslint-config-prettier": "8.8.0",
108
110
  "eslint-plugin-prettier": "4.2.1",
@@ -110,10 +112,8 @@
110
112
  "mocha": "10.2.0",
111
113
  "nock": "13.3.2",
112
114
  "npm-license-crawler": "0.2.1",
113
- "pkg": "5.8.1",
114
115
  "prettier": "2.8.8",
115
116
  "tmp": "0.2.1",
116
- "ts-node": "^10.9.2",
117
117
  "typescript": "5.1.6",
118
118
  "uuid": "9.0.0",
119
119
  "vitest": "1.4.0"