@contrast/agent 5.0.0-beta.1 → 5.0.0-beta.11

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 (3) hide show
  1. package/LICENSE +12 -0
  2. package/lib/index.js +51 -21
  3. package/package.json +17 -15
package/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright: 2023 Contrast Security, Inc
2
+ Contact: support@contrastsecurity.com
3
+ License: Commercial
4
+
5
+ NOTICE: This Software and the patented inventions embodied within may only be
6
+ used as part of Contrast Security’s commercial offerings. Even though it is
7
+ made available through public repositories, use of this Software is subject to
8
+ the applicable End User Licensing Agreement found at
9
+ https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
10
+ between Contrast Security and the End User. The Software may not be reverse
11
+ engineered, modified, repackaged, sold, redistributed or otherwise used in a
12
+ way not consistent with the End User License Agreement.
package/lib/index.js CHANGED
@@ -16,20 +16,20 @@
16
16
  'use strict';
17
17
 
18
18
  const semver = require('semver');
19
- const assess = require('@contrast/assess');
20
- const archComponents = require('@contrast/architecture-components');
21
- const libraryUsage = require('@contrast/library-analysis');
22
- const protect = require('@contrast/protect');
23
- const routeCoverage = require('@contrast/route-coverage');
24
- const { name: agentName, version: agentVersion, engines: { node, npm } } = require('../package.json');
25
- const { agentify } = require('@contrast/core')({ agentName, agentVersion });
19
+ const {
20
+ name: agentName,
21
+ version: agentVersion,
22
+ engines: {
23
+ node: nodeEngine,
24
+ npm: npmEngine
25
+ }
26
+ } = require('../package.json');
27
+ const agentify = require('@contrast/agentify')({ agentName, agentVersion });
26
28
 
27
29
  agentify((core) => {
28
- core.npmVersionRange = npm;
29
-
30
- if (!semver.satisfies(process.version, node)) {
30
+ if (!semver.satisfies(process.version, nodeEngine)) {
31
31
  let validRanges = '';
32
- node.split('||').forEach((range) => {
32
+ nodeEngine.split('||').forEach((range) => {
33
33
  const minVersion = semver.minVersion(range).toString();
34
34
  const maxVersion = range.split('<').pop()
35
35
  .trim();
@@ -38,15 +38,45 @@ agentify((core) => {
38
38
  throw new Error(`Contrast only officially supports Node LTS versions between ${validRanges}but detected ${process.version}.`);
39
39
  }
40
40
 
41
- archComponents(core);
42
- libraryUsage(core);
43
- routeCoverage(core);
44
-
45
- if (!core.config.protect.enable && !core.config.assess.enable) {
46
- throw new Error('Protect or Assess must be enabled!');
47
- }
41
+ core.startupValidation = {
42
+ /**
43
+ * This will run after we onboard to the UI and pick up any remote settings.
44
+ */
45
+ install() {
46
+ if (
47
+ !core.config.getEffectiveValue('assess.enable') &&
48
+ !core.config.getEffectiveValue('protect.enable')
49
+ ) {
50
+ throw new Error('Neither Assess nor Protect are enabled. Check local configuration and UI settings');
51
+ }
52
+ }
53
+ };
48
54
 
49
- assess(core);
50
- // Protect and Assess are compatible. Protect loads lastly, being the only non-passive feature.
51
- protect(core);
55
+ core.npmVersionRange = npmEngine;
56
+ require('@contrast/telemetry')(core);
57
+ require('@contrast/assess')(core);
58
+ require('@contrast/architecture-components')(core);
59
+ require('@contrast/library-analysis')(core);
60
+ require('@contrast/route-coverage')(core);
61
+ require('@contrast/protect')(core); // protect loads lastly, being the only non-passive feature
62
+ }, {
63
+ installOrder: [
64
+ 'reporter',
65
+ 'startupValidation',
66
+ 'telemetry',
67
+ 'contrastMethods',
68
+ 'deadzones',
69
+ 'scopes',
70
+ 'sources',
71
+ 'architectureComponents',
72
+ 'assess',
73
+ 'protect',
74
+ 'depHooks',
75
+ 'routeCoverage',
76
+ 'libraryAnalysis',
77
+ 'heapSnapshots',
78
+ 'rewriteHooks',
79
+ 'functionHooks',
80
+ 'metrics',
81
+ ],
52
82
  });
package/package.json CHANGED
@@ -1,27 +1,29 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "5.0.0-beta.1",
3
+ "version": "5.0.0-beta.11",
4
4
  "description": "Assess and Protect agents for Node.js",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
7
+ "files": [
8
+ "lib/"
9
+ ],
5
10
  "main": "lib/index.js",
6
- "directories": {
7
- "lib": "lib"
8
- },
11
+ "types": "lib/index.d.ts",
9
12
  "engines": {
10
13
  "npm": ">=6.13.7 <7 || >= 8.3.1",
11
- "node": ">=14.15.0 <15 || >=16.9.1 <17 || >=18.7.0 <19"
14
+ "node": ">=14.15.0 <15 || >=16.9.1 <17 || >=18.7.0 <19 || >=20.5.0 <21"
12
15
  },
13
16
  "scripts": {
14
- "test": "echo \"Error: no test specified\" && exit 1"
17
+ "test": "../scripts/test.sh"
15
18
  },
16
- "author": "",
17
- "license": "ISC",
18
19
  "dependencies": {
19
- "@contrast/architecture-components": "1.12.0",
20
- "@contrast/assess": "1.11.0",
21
- "@contrast/core": "1.21.0",
22
- "@contrast/library-analysis": "1.10.0",
23
- "@contrast/route-coverage": "1.10.0",
24
- "@contrast/protect": "1.23.0",
20
+ "@contrast/agentify": "1.17.0",
21
+ "@contrast/architecture-components": "1.14.0",
22
+ "@contrast/assess": "1.19.0",
23
+ "@contrast/library-analysis": "1.15.0",
24
+ "@contrast/protect": "1.29.0",
25
+ "@contrast/route-coverage": "1.13.0",
26
+ "@contrast/telemetry": "1.1.0",
25
27
  "semver": "^7.3.7"
26
28
  }
27
- }
29
+ }