@contrast/agent 5.65.0 → 5.66.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.
- package/README.md +38 -29
- package/lib/start-agent.js +2 -0
- package/package.json +17 -16
package/README.md
CHANGED
|
@@ -20,13 +20,12 @@ easiest and cheapest to remediate.
|
|
|
20
20
|
|
|
21
21
|
- The agent no longer ships or operates with the `contrast-service` "sidecar" executables. This allows for a drastically smaller download size and simplified deployments.
|
|
22
22
|
|
|
23
|
-
- Framework support includes `express`, `koa`, `fastify`, `hapi`, and `restify`.
|
|
24
23
|
|
|
25
24
|
- The agent does not respond to any command-line configuration flags. Configuration options can be set using environment variables and/or `contrast_security.yaml` file. If you were previously using the agent's `-c` CLI option to set the location of your configuration file, you can use `CONTRAST_CONFIG_PATH` environment variable instead. See more about configuration [below](#configuration).
|
|
26
25
|
|
|
27
26
|
- Structured logging.
|
|
28
27
|
|
|
29
|
-
-
|
|
28
|
+
- Ability to run Assess, Protect, Observability, and CVE Shield modes concurrently.
|
|
30
29
|
|
|
31
30
|
- Full support for ESM modules
|
|
32
31
|
|
|
@@ -38,7 +37,7 @@ versioning (`major.minor.patch`).
|
|
|
38
37
|
|
|
39
38
|
An API key or token, provided by Contrast Security, is required for the agent to function.
|
|
40
39
|
|
|
41
|
-
Ensure you
|
|
40
|
+
Ensure you are running a supported LTS (Long Term Support) version of [Node.js](https://nodejs.org/). See [Usage](#usage) for the supported ranges.
|
|
42
41
|
|
|
43
42
|
To install from npm using the command line (run from the app root directory):
|
|
44
43
|
|
|
@@ -51,8 +50,8 @@ $ npm install @contrast/agent
|
|
|
51
50
|
### With LTS (Long Term Support) Node.js Versions
|
|
52
51
|
|
|
53
52
|
[Node.js policy](https://nodejs.org/en/about/previous-releases/) is that production applications
|
|
54
|
-
should use only Active LTS or Maintenance LTS releases.
|
|
55
|
-
ECMAScript modules (ESM) and CommonJS modules (CJS) with the `--import` flag. To ensure that the
|
|
53
|
+
should use only Active LTS or Maintenance LTS releases. On supported Node.js versions from 18.19.0, the
|
|
54
|
+
agent instruments ECMAScript modules (ESM) and CommonJS modules (CJS) with the `--import` flag. To ensure that the
|
|
56
55
|
agent can instrument your application, use:
|
|
57
56
|
|
|
58
57
|
```sh
|
|
@@ -60,19 +59,27 @@ node --import @contrast/agent app-main [app arguments]
|
|
|
60
59
|
```
|
|
61
60
|
|
|
62
61
|
Notes:
|
|
63
|
-
- `--import` should be used for Node.js LTS (Active and Maintenance) versions `>=18.19.0`
|
|
64
|
-
- Node.js versions `>=20.0.0 <20.9.0` are not supported
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
- Supported Node.js versions are `>=18.7.0 <19`, `>=20.9.0 <21`, `>=22.5.1 <23`, and `>=24.0.1 <25`. Other versions, including odd-numbered releases and the early releases of each LTS line, are not supported.
|
|
64
|
+
- Use `--import` on supported versions `>=18.19.0`, and `--loader` on 18.7 to 18.18 (below).
|
|
67
65
|
|
|
68
|
-
|
|
66
|
+
### With Node.js 18.7 to 18.18
|
|
67
|
+
|
|
68
|
+
Use the `--loader` flag for Node.js versions `>=18.7.0 <18.19.0`.
|
|
69
69
|
|
|
70
70
|
```sh
|
|
71
71
|
node --loader @contrast/agent app-main.mjs [app arguments]
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
### With applications that use no ES modules
|
|
75
|
+
|
|
76
|
+
If neither your application nor any of its dependencies uses ES modules, you can also start the agent with `--require` (or `-r`):
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
node -r @contrast/agent app-main.js [app arguments]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
ES modules loaded by an application started this way are not instrumented.
|
|
76
83
|
|
|
77
84
|
### Configuration
|
|
78
85
|
|
|
@@ -83,26 +90,23 @@ The agent will look for the `contrast_security.yaml` configuration file in the f
|
|
|
83
90
|
1. Within the processes current working directory, that is `${process.cwd()}/contrast_security.yaml`.
|
|
84
91
|
|
|
85
92
|
1. OS-specific configuration directories.
|
|
93
|
+
- Unix and MacOS systems:
|
|
94
|
+
- `/etc/contrast/node/contrast_security.yaml`, _then_
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
- `/etc/contrast/contrast_security.yaml`
|
|
88
97
|
|
|
89
|
-
|
|
98
|
+
- Win32 systems:
|
|
99
|
+
- `${process.env.ProgramData}\contrast\node\contrast_security.yaml`, _then_
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
- Win32 systems:
|
|
94
|
-
|
|
95
|
-
- `${process.env.ProgramData}\contrast\node\contrast_security.yaml`, _then_
|
|
96
|
-
|
|
97
|
-
- `${process.env.ProgramData}\contrast\contrast_security.yaml`
|
|
101
|
+
- `${process.env.ProgramData}\contrast\contrast_security.yaml`
|
|
98
102
|
|
|
99
103
|
1. Unix home directory.
|
|
104
|
+
- `~/.config/contrast/node/contrast_security.yaml`, _then_
|
|
100
105
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- `~/.config/contrast/contrast_security.yaml`
|
|
106
|
+
- `~/.config/contrast/contrast_security.yaml`
|
|
104
107
|
|
|
105
108
|
> Note: The optional `/node/` path segment is useful in cases where you want to organize configuration files by agent language:
|
|
109
|
+
>
|
|
106
110
|
> ```
|
|
107
111
|
> /etc
|
|
108
112
|
> /contrast
|
|
@@ -111,16 +115,21 @@ The agent will look for the `contrast_security.yaml` configuration file in the f
|
|
|
111
115
|
> /python/contrast_security.yaml
|
|
112
116
|
> ```
|
|
113
117
|
|
|
118
|
+
The search stops at the first of these steps that finds a file. If a step finds both the `/node/` file and its parent's file, they are merged, and the `/node/` file's values win. A file that contains `root: true` is used on its own.
|
|
119
|
+
|
|
114
120
|
You can also specify the location of the configuration file with the `CONTRAST_CONFIG_PATH` environment variable:
|
|
115
121
|
|
|
116
122
|
```sh
|
|
117
123
|
CONTRAST_CONFIG_PATH=/path/to/config.yaml node --import @contrast/agent app-main
|
|
118
124
|
```
|
|
119
125
|
|
|
120
|
-
> Note:
|
|
126
|
+
> Note: If `process.env.CONTRAST_CONFIG_PATH` set, the agent will look at that location _only_. If there is an issue reading the configuration file from this location the agent will not look in the standard locations described above, but instead do the following:
|
|
127
|
+
>
|
|
121
128
|
> 1. Halt instrumentation
|
|
122
129
|
> 2. Communicate an error
|
|
123
130
|
> 3. Run the application as if without Contrast
|
|
131
|
+
>
|
|
132
|
+
> Set `CONTRAST_CONFIG_PATH` to the null device (`/dev/null`, or `\\.\nul` on Windows) to use no configuration file at all.
|
|
124
133
|
|
|
125
134
|
#### Minimum Configuration Option Requirements
|
|
126
135
|
|
|
@@ -129,13 +138,13 @@ The agent requires a minimum set of configuration options be set. They are descr
|
|
|
129
138
|
```yaml
|
|
130
139
|
api:
|
|
131
140
|
# Organization's API key
|
|
132
|
-
api_key:
|
|
141
|
+
api_key: <api_key>
|
|
133
142
|
# Contrast user account service key
|
|
134
|
-
service_key:
|
|
143
|
+
service_key: <service_key>
|
|
135
144
|
# Contrast user account ID (In most cases, this is your login ID)
|
|
136
|
-
user_name:
|
|
145
|
+
user_name: <user_name>
|
|
137
146
|
# Address to the Contrast backend. This will vary.
|
|
138
|
-
url: https://app.contrastsecurity.com
|
|
147
|
+
url: https://app.contrastsecurity.com/Contrast
|
|
139
148
|
```
|
|
140
149
|
|
|
141
150
|
OR
|
|
@@ -143,7 +152,7 @@ OR
|
|
|
143
152
|
```yaml
|
|
144
153
|
api:
|
|
145
154
|
# base64 encoded JSON object containing the url, api_key, service_key, and user_name
|
|
146
|
-
token:
|
|
155
|
+
token: <token>
|
|
147
156
|
```
|
|
148
157
|
|
|
149
158
|
Visit https://agent.config.contrastsecurity.com/ to use our online tool for building your YAML file interactively.
|
package/lib/start-agent.js
CHANGED
|
@@ -66,6 +66,7 @@ function loadFeatures(core) {
|
|
|
66
66
|
require('@contrast/library-analysis')(core);
|
|
67
67
|
require('@contrast/route-coverage')(core);
|
|
68
68
|
require('@contrast/assess')(core);
|
|
69
|
+
core.initComponentSync(require('@contrast/blocking'));
|
|
69
70
|
core.initComponentSync(require('@contrast/cve-shield'));
|
|
70
71
|
require('@contrast/protect')(core);
|
|
71
72
|
require('@contrast/sec-obs')(core);
|
|
@@ -101,6 +102,7 @@ function startAgent({ type = 'cjs' } = {}) {
|
|
|
101
102
|
'sources',
|
|
102
103
|
'routeCoverage',
|
|
103
104
|
'assess',
|
|
105
|
+
'blocking',
|
|
104
106
|
'cveShield',
|
|
105
107
|
'protect',
|
|
106
108
|
'depHooks',
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/agent",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.66.0",
|
|
4
|
+
"description": "Contrast Security agent for Node.js",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib/",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"!**/*.test.*",
|
|
10
|
+
"!**/tsconfig.*",
|
|
11
|
+
"!**/*.map"
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
@@ -28,16 +28,17 @@
|
|
|
28
28
|
"test": "bash ../scripts/test.sh"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@contrast/agentify": "1.
|
|
32
|
-
"@contrast/assess": "1.
|
|
33
|
-
"@contrast/
|
|
34
|
-
"@contrast/
|
|
35
|
-
"@contrast/
|
|
36
|
-
"@contrast/
|
|
37
|
-
"@contrast/
|
|
38
|
-
"@contrast/
|
|
39
|
-
"@contrast/
|
|
40
|
-
"@contrast/
|
|
41
|
-
"@contrast/
|
|
31
|
+
"@contrast/agentify": "1.74.0",
|
|
32
|
+
"@contrast/assess": "1.82.0",
|
|
33
|
+
"@contrast/blocking": "1.1.0",
|
|
34
|
+
"@contrast/cli": "1.70.0",
|
|
35
|
+
"@contrast/common": "1.43.0",
|
|
36
|
+
"@contrast/core": "1.69.0",
|
|
37
|
+
"@contrast/cve-shield": "1.5.0",
|
|
38
|
+
"@contrast/library-analysis": "1.59.0",
|
|
39
|
+
"@contrast/protect": "1.84.0",
|
|
40
|
+
"@contrast/route-coverage": "1.64.0",
|
|
41
|
+
"@contrast/sec-obs": "1.15.0",
|
|
42
|
+
"@contrast/telemetry": "1.44.0"
|
|
42
43
|
}
|
|
43
44
|
}
|