@newrelic/security-agent 2.4.4 → 3.0.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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
### v3.0.1 (2026-01-29)
|
|
2
|
+
#### Miscellaneous chores
|
|
3
|
+
* (deps): Updated lodash to v4.17.23 and undici to v7.19.0
|
|
4
|
+
|
|
5
|
+
### v3.0.0 (2026-01-06)
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
* Dropped support for Node.js v18
|
|
8
|
+
|
|
9
|
+
#### Features
|
|
10
|
+
* Dropped support of Node 18.x and added Node 24.x
|
|
11
|
+
|
|
12
|
+
#### Bug fixes
|
|
13
|
+
* Updated rest-client to use undici.request instead of axios to avoid future CVEs
|
|
14
|
+
|
|
15
|
+
#### Miscellaneous chores
|
|
16
|
+
* Updated workflow to support OIDC publish
|
|
17
|
+
* Updated js-yaml to v4.1.1
|
|
18
|
+
* (deps-dev): bump tar-fs from 2.1.2 to 2.1.4
|
|
19
|
+
* (deps-dev): bump koa from 3.0.1 to 3.0.3
|
|
20
|
+
|
|
21
|
+
|
|
1
22
|
### v2.4.4 (2025-09-12)
|
|
2
23
|
#### Miscellaneous chores
|
|
3
24
|
* (deps): Bump axios to v1.12.0
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
**Note**: The IAST capability should only be used in pre-production environments as the application is tested for real exploitable vulnerabilities.
|
|
5
5
|
|
|
6
|
-
The New Relic security agent enables instrumentation of a Node.js application for Interactive Application Security Testing(IAST) and exposes exploitable vulnerabilities.
|
|
6
|
+
The New Relic security agent enables instrumentation of a Node.js application for Interactive Application Security Testing(IAST) and exposes exploitable vulnerabilities.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -42,12 +42,12 @@ The `@newrelic/security-agent` must be explicitly enabled in order to perform IA
|
|
|
42
42
|
The [Developer docs](http://newrelic.github.io/node-newrelic/) for writing instrumentation will be of help. We particularly recommend the [tutorials](https://newrelic.github.io/node-newrelic/tutorial-Instrumentation-Basics.html) and the [shim API](https://newrelic.github.io/node-newrelic/Shim.html) documentation.
|
|
43
43
|
|
|
44
44
|
### Supported Node.js Versions
|
|
45
|
-
- Node version
|
|
45
|
+
- Node version 20.x, 22.x and 24.x
|
|
46
46
|
|
|
47
47
|
### Supported Modules
|
|
48
48
|
|
|
49
49
|
- Node.js core modules
|
|
50
|
-
- `http`
|
|
50
|
+
- `http`
|
|
51
51
|
- `https`
|
|
52
52
|
- `fs`
|
|
53
53
|
- `child_process`
|
|
@@ -67,9 +67,9 @@ The [Developer docs](http://newrelic.github.io/node-newrelic/) for writing instr
|
|
|
67
67
|
- [ldapjs](https://www.npmjs.com/package/ldapjs)(2.x and above)
|
|
68
68
|
- [ldapts](https://www.npmjs.com/package/ldapts)(2.x and above)
|
|
69
69
|
- [xpath](https://www.npmjs.com/package/xpath)(0.0.20 and above)
|
|
70
|
-
- [xpath.js](https://www.npmjs.com/package/xpath.js)(0.0.1 and above)
|
|
71
|
-
- [undici](https://www.npmjs.com/package/undici)(4.7.0 and above)
|
|
72
|
-
- [next](https://www.npmjs.com/package/next)(13.4.19 and above)
|
|
70
|
+
- [xpath.js](https://www.npmjs.com/package/xpath.js)(0.0.1 and above)
|
|
71
|
+
- [undici](https://www.npmjs.com/package/undici)(4.7.0 and above)
|
|
72
|
+
- [next](https://www.npmjs.com/package/next)(13.4.19 and above)
|
|
73
73
|
|
|
74
74
|
For more information, please see New Relic Node.js agent [compatibility and requirements](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent/).
|
|
75
75
|
|
|
@@ -117,7 +117,7 @@ If you would like to contribute to this project, review [these guidelines](https
|
|
|
117
117
|
The New Relic security agent is licensed under the New Relic Software License v1.0.
|
|
118
118
|
The `@newrelic/security-agent` also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in the third-party notices document.
|
|
119
119
|
|
|
120
|
-
[1]: https://img.shields.io/npm/v/@newrelic/security-agent.svg
|
|
121
|
-
[2]: https://www.npmjs.com/package/@newrelic/security-agent
|
|
120
|
+
[1]: https://img.shields.io/npm/v/@newrelic/security-agent.svg
|
|
121
|
+
[2]: https://www.npmjs.com/package/@newrelic/security-agent
|
|
122
122
|
[3]: https://github.com/newrelic/csec-node-agent/workflows/CSEC%20Node%20Agent%20CI/badge.svg
|
|
123
123
|
[4]: https://github.com/newrelic/csec-node-agent/actions?query=workflow%3A%22CSEC+Node+Agent+CI%22
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -14,7 +14,6 @@ code, the source code can be found at [https://github.com/newrelic/csec-node-age
|
|
|
14
14
|
|
|
15
15
|
**[dependencies](#dependencies)**
|
|
16
16
|
|
|
17
|
-
* [axios](#axios)
|
|
18
17
|
* [check-disk-space](#check-disk-space)
|
|
19
18
|
* [content-type](#content-type)
|
|
20
19
|
* [cron](#cron)
|
|
@@ -32,6 +31,7 @@ code, the source code can be found at [https://github.com/newrelic/csec-node-age
|
|
|
32
31
|
* [request-ip](#request-ip)
|
|
33
32
|
* [ringbufferjs](#ringbufferjs)
|
|
34
33
|
* [semver](#semver)
|
|
34
|
+
* [undici](#undici)
|
|
35
35
|
* [unescape-js](#unescape-js)
|
|
36
36
|
* [unescape](#unescape)
|
|
37
37
|
* [uuid](#uuid)
|
|
@@ -63,11 +63,9 @@ code, the source code can be found at [https://github.com/newrelic/csec-node-age
|
|
|
63
63
|
* [mongodb](#mongodb)
|
|
64
64
|
* [newrelic](#newrelic)
|
|
65
65
|
* [request](#request)
|
|
66
|
-
* [restify](#restify)
|
|
67
66
|
* [sinon](#sinon)
|
|
68
67
|
* [stream](#stream)
|
|
69
68
|
* [tap](#tap)
|
|
70
|
-
* [undici](#undici)
|
|
71
69
|
* [xmldom](#xmldom)
|
|
72
70
|
* [xpath.js](#xpathjs)
|
|
73
71
|
* [xpath](#xpath)
|
|
@@ -75,21 +73,6 @@ code, the source code can be found at [https://github.com/newrelic/csec-node-age
|
|
|
75
73
|
|
|
76
74
|
## dependencies
|
|
77
75
|
|
|
78
|
-
### axios
|
|
79
|
-
|
|
80
|
-
This product includes source derived from [axios](https://github.com/axios/axios) ([v1.12.0](https://github.com/axios/axios/tree/v1.12.0)), distributed under the [MIT License](https://github.com/axios/axios/blob/v1.12.0/LICENSE):
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
# Copyright (c) 2014-present Matt Zabriskie & Collaborators
|
|
84
|
-
|
|
85
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
86
|
-
|
|
87
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
88
|
-
|
|
89
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
|
|
93
76
|
### check-disk-space
|
|
94
77
|
|
|
95
78
|
This product includes source derived from [check-disk-space](https://github.com/Alex-D/check-disk-space) ([v3.4.0](https://github.com/Alex-D/check-disk-space/tree/v3.4.0)), distributed under the [MIT License](https://github.com/Alex-D/check-disk-space/blob/v3.4.0/LICENSE):
|
|
@@ -315,7 +298,7 @@ THE SOFTWARE.
|
|
|
315
298
|
|
|
316
299
|
### js-yaml
|
|
317
300
|
|
|
318
|
-
This product includes source derived from [js-yaml](https://github.com/nodeca/js-yaml) ([v4.1.
|
|
301
|
+
This product includes source derived from [js-yaml](https://github.com/nodeca/js-yaml) ([v4.1.1](https://github.com/nodeca/js-yaml/tree/v4.1.1)), distributed under the [MIT License](https://github.com/nodeca/js-yaml/blob/v4.1.1/LICENSE):
|
|
319
302
|
|
|
320
303
|
```
|
|
321
304
|
(The MIT License)
|
|
@@ -373,7 +356,7 @@ SOFTWARE.
|
|
|
373
356
|
|
|
374
357
|
### lodash
|
|
375
358
|
|
|
376
|
-
This product includes source derived from [lodash](https://github.com/lodash/lodash) ([v4.17.
|
|
359
|
+
This product includes source derived from [lodash](https://github.com/lodash/lodash) ([v4.17.23](https://github.com/lodash/lodash/tree/v4.17.23)), distributed under the [MIT License](https://github.com/lodash/lodash/blob/v4.17.23/LICENSE):
|
|
377
360
|
|
|
378
361
|
```
|
|
379
362
|
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
@@ -531,6 +514,35 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
531
514
|
|
|
532
515
|
```
|
|
533
516
|
|
|
517
|
+
### undici
|
|
518
|
+
|
|
519
|
+
This product includes source derived from [undici](https://github.com/nodejs/undici) ([v7.19.0](https://github.com/nodejs/undici/tree/v7.19.0)), distributed under the [MIT License](https://github.com/nodejs/undici/blob/v7.19.0/LICENSE):
|
|
520
|
+
|
|
521
|
+
```
|
|
522
|
+
MIT License
|
|
523
|
+
|
|
524
|
+
Copyright (c) Matteo Collina and Undici contributors
|
|
525
|
+
|
|
526
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
527
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
528
|
+
in the Software without restriction, including without limitation the rights
|
|
529
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
530
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
531
|
+
furnished to do so, subject to the following conditions:
|
|
532
|
+
|
|
533
|
+
The above copyright notice and this permission notice shall be included in all
|
|
534
|
+
copies or substantial portions of the Software.
|
|
535
|
+
|
|
536
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
537
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
538
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
539
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
540
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
541
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
542
|
+
SOFTWARE.
|
|
543
|
+
|
|
544
|
+
```
|
|
545
|
+
|
|
534
546
|
### unescape-js
|
|
535
547
|
|
|
536
548
|
This product includes source derived from [unescape-js](https://github.com/iamakulov/unescape-js) ([v1.1.4](https://github.com/iamakulov/unescape-js/tree/v1.1.4)), distributed under the [MIT License](https://github.com/iamakulov/unescape-js/blob/v1.1.4/LICENSE):
|
|
@@ -1818,7 +1830,7 @@ Library.
|
|
|
1818
1830
|
|
|
1819
1831
|
### koa
|
|
1820
1832
|
|
|
1821
|
-
This product includes source derived from [koa](https://github.com/koajs/koa) ([v3.0.
|
|
1833
|
+
This product includes source derived from [koa](https://github.com/koajs/koa) ([v3.0.3](https://github.com/koajs/koa/tree/v3.0.3)), distributed under the [MIT License](https://github.com/koajs/koa/blob/v3.0.3/LICENSE):
|
|
1822
1834
|
|
|
1823
1835
|
```
|
|
1824
1836
|
(The MIT License)
|
|
@@ -2740,33 +2752,6 @@ If the Work includes a "NOTICE" text file as part of its distribution, then any
|
|
|
2740
2752
|
END OF TERMS AND CONDITIONS
|
|
2741
2753
|
```
|
|
2742
2754
|
|
|
2743
|
-
### restify
|
|
2744
|
-
|
|
2745
|
-
This product includes source derived from [restify](https://github.com/restify/node-restify) ([v11.1.0](https://github.com/restify/node-restify/tree/v11.1.0)), distributed under the [MIT License](https://github.com/restify/node-restify/blob/v11.1.0/LICENSE):
|
|
2746
|
-
|
|
2747
|
-
```
|
|
2748
|
-
Copyright (c) 2011 Mark Cavage, All rights reserved.
|
|
2749
|
-
|
|
2750
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2751
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
2752
|
-
in the Software without restriction, including without limitation the rights
|
|
2753
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2754
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
2755
|
-
furnished to do so, subject to the following conditions:
|
|
2756
|
-
|
|
2757
|
-
The above copyright notice and this permission notice shall be included in
|
|
2758
|
-
all copies or substantial portions of the Software.
|
|
2759
|
-
|
|
2760
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2761
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2762
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2763
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2764
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2765
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
2766
|
-
THE SOFTWARE
|
|
2767
|
-
|
|
2768
|
-
```
|
|
2769
|
-
|
|
2770
2755
|
### sinon
|
|
2771
2756
|
|
|
2772
2757
|
This product includes source derived from [sinon](https://github.com/sinonjs/sinon) ([v15.2.0](https://github.com/sinonjs/sinon/tree/v15.2.0)), distributed under the [BSD-3-Clause License](https://github.com/sinonjs/sinon/blob/v15.2.0/LICENSE):
|
|
@@ -2841,35 +2826,6 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
2841
2826
|
|
|
2842
2827
|
```
|
|
2843
2828
|
|
|
2844
|
-
### undici
|
|
2845
|
-
|
|
2846
|
-
This product includes source derived from [undici](https://github.com/nodejs/undici) ([v5.28.4](https://github.com/nodejs/undici/tree/v5.28.4)), distributed under the [MIT License](https://github.com/nodejs/undici/blob/v5.28.4/LICENSE):
|
|
2847
|
-
|
|
2848
|
-
```
|
|
2849
|
-
MIT License
|
|
2850
|
-
|
|
2851
|
-
Copyright (c) Matteo Collina and Undici contributors
|
|
2852
|
-
|
|
2853
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2854
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
2855
|
-
in the Software without restriction, including without limitation the rights
|
|
2856
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2857
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
2858
|
-
furnished to do so, subject to the following conditions:
|
|
2859
|
-
|
|
2860
|
-
The above copyright notice and this permission notice shall be included in all
|
|
2861
|
-
copies or substantial portions of the Software.
|
|
2862
|
-
|
|
2863
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2864
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2865
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2866
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2867
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2868
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
2869
|
-
SOFTWARE.
|
|
2870
|
-
|
|
2871
|
-
```
|
|
2872
|
-
|
|
2873
2829
|
### xmldom
|
|
2874
2830
|
|
|
2875
2831
|
This product includes source derived from [xmldom](https://github.com/xmldom/xmldom) ([v0.6.0](https://github.com/xmldom/xmldom/tree/v0.6.0)), distributed under the [MIT License](https://github.com/xmldom/xmldom/blob/v0.6.0/LICENSE):
|
|
@@ -2,25 +2,74 @@
|
|
|
2
2
|
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: New Relic Software License v1.0
|
|
4
4
|
*/
|
|
5
|
+
const { request, Agent, setGlobalDispatcher } = require('undici');
|
|
6
|
+
const commonUtils = require('../commonUtils');
|
|
7
|
+
const IASTUtil = require('./websocket/response/IASTUtils');
|
|
8
|
+
const DEFAULT_HEADERS = {
|
|
9
|
+
accept: null,
|
|
10
|
+
['accept-encoding']: null,
|
|
11
|
+
['content-type']: null,
|
|
12
|
+
['sec-ch-ua-platform']: null,
|
|
13
|
+
['user-agent']: null
|
|
14
|
+
};
|
|
5
15
|
|
|
6
|
-
|
|
16
|
+
class Request {
|
|
17
|
+
constructor(config = {}, logger) {
|
|
18
|
+
const serverName = config.serverName ?? 'localhost';
|
|
19
|
+
const host = `${serverName}:${config.serverPort}`;
|
|
20
|
+
this.logger = logger;
|
|
21
|
+
this.url = `${config.protocol}://${host}${config.url}`;
|
|
22
|
+
this.method = config.method;
|
|
23
|
+
this.body = config.body;
|
|
24
|
+
this.headers = this.assignHeaders(config)
|
|
25
|
+
this.id = config.id;
|
|
26
|
+
this.keepAlive = true
|
|
27
|
+
const agent = new Agent({
|
|
28
|
+
keepAliveTimeout: 5,
|
|
29
|
+
connect: {
|
|
30
|
+
rejectUnauthorized: false
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
setGlobalDispatcher(agent);
|
|
34
|
+
}
|
|
7
35
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
send(fuzzDetails) {
|
|
37
|
+
const { rawFuzzRequest, fuzzRequest } = fuzzDetails;
|
|
38
|
+
IASTUtil.completedRequestsMapInit(this.id)
|
|
39
|
+
this.logger.info(`Firing http request:: URL: ${this.url}`);
|
|
40
|
+
request(this.url, {
|
|
41
|
+
method: this.method,
|
|
42
|
+
body: this.body,
|
|
43
|
+
headers: this.headers,
|
|
44
|
+
signal: AbortSignal.timeout(5000)
|
|
45
|
+
}).then(() => {
|
|
46
|
+
this.logger.info('Fuzz success: ' + rawFuzzRequest)
|
|
47
|
+
}).catch(() => {
|
|
48
|
+
this.logger.debug('Error occurred: ', this.url, fuzzRequest);
|
|
49
|
+
}).finally(() => {
|
|
50
|
+
IASTUtil.removePendingRequestId(this.id);
|
|
51
|
+
if (commonUtils.scanStartTime === 0) {
|
|
52
|
+
commonUtils.scanStartTime = Date.now();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
assignHeaders({ headers = {}, id }) {
|
|
58
|
+
const contentType = headers['content-type'];
|
|
59
|
+
if (contentType) {
|
|
60
|
+
const [firstType] = contentType.split(';');
|
|
61
|
+
headers['content-type'] = firstType ?? contentType;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (headers['content-length']) {
|
|
65
|
+
delete headers['content-length'];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
headers['nr-csec-parent-id'] = id;
|
|
69
|
+
|
|
70
|
+
return {...DEFAULT_HEADERS, ...headers };
|
|
71
|
+
}
|
|
22
72
|
}
|
|
23
73
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
74
|
+
|
|
75
|
+
module.exports = Request;
|
package/lib/nr-security-agent/lib/core/connections/websocket/response/fuzz-request-handler.js
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable no-unused-vars */
|
|
7
7
|
const stringify = require('fast-safe-stringify');
|
|
8
|
-
|
|
9
|
-
const restClient = require('../../restclient');
|
|
8
|
+
const RestClient = require('../../restclient');
|
|
10
9
|
const grpcClient = require('../../grpcClient');
|
|
11
10
|
const { Agent } = require('../../../agent');
|
|
12
11
|
const { FuzzFailEvent } = require('../../../FuzzFailEvent');
|
|
@@ -163,27 +162,12 @@ function handleFuzzRequest(fuzzDetails) {
|
|
|
163
162
|
IASTUtil.removePendingRequestId(fuzzRequest.id);
|
|
164
163
|
|
|
165
164
|
} else {
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const splitted = type.split(';');
|
|
170
|
-
if (splitted[0]) {
|
|
171
|
-
config.headers['content-type'] = splitted[0];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
config.headers['nr-csec-parent-id'] = fuzzRequest.id;
|
|
176
|
-
|
|
177
|
-
IASTUtil.completedRequestsMapInit(fuzzRequest.id);
|
|
178
|
-
|
|
179
|
-
if (fuzzRequest.headers && fuzzRequest.headers[NR_CSEC_FUZZ_REQUEST_ID]) {
|
|
180
|
-
logScannedApiId(fuzzRequest.headers[NR_CSEC_FUZZ_REQUEST_ID], fuzzRequest.requestURI)
|
|
165
|
+
const client = new RestClient(fuzzRequest, logger);
|
|
166
|
+
if (client.headers[NR_CSEC_FUZZ_REQUEST_ID]) {
|
|
167
|
+
logScannedApiId(client.headers[NR_CSEC_FUZZ_REQUEST_ID], fuzzRequest.requestURI)
|
|
181
168
|
}
|
|
182
169
|
|
|
183
|
-
|
|
184
|
-
logger.info('Firing http request:: URL: ' + config.url);
|
|
185
|
-
const response = restClient.fireRequest(config);
|
|
186
|
-
handleFuzzResponse(response, fuzzDetails);
|
|
170
|
+
client.send(fuzzDetails);
|
|
187
171
|
}
|
|
188
172
|
} catch (err) {
|
|
189
173
|
const fuzzFailEvent = new FuzzFailEvent(fuzzRequest.headers[NR_CSEC_FUZZ_REQUEST_ID]);
|
|
@@ -196,53 +180,9 @@ function handleFuzzRequest(fuzzDetails) {
|
|
|
196
180
|
}
|
|
197
181
|
}
|
|
198
182
|
|
|
199
|
-
/**
|
|
200
|
-
* Handles the fuzz response Promise.
|
|
201
|
-
*
|
|
202
|
-
* @param {Promise} response
|
|
203
|
-
* @param {Object} fuzzDetails
|
|
204
|
-
*/
|
|
205
|
-
function handleFuzzResponse(response, fuzzDetails) {
|
|
206
|
-
const { rawFuzzRequest, fuzzRequest } = fuzzDetails;
|
|
207
|
-
if (response) {
|
|
208
|
-
IASTUtil.removePendingRequestId(fuzzRequest.id);
|
|
209
|
-
if (commonUtils.scanStartTime == 0) {
|
|
210
|
-
commonUtils.scanStartTime = Date.now();
|
|
211
|
-
}
|
|
212
|
-
response.then(() => {
|
|
213
|
-
logger.info('Fuzz success: ' + rawFuzzRequest);
|
|
214
|
-
}).catch(() => {
|
|
215
|
-
logger.debug('Error occured:', fuzzRequest.url, fuzzRequest);
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Parses the passed fuzz request object to
|
|
222
|
-
* Axios config.
|
|
223
|
-
*
|
|
224
|
-
* @param {JSON} requestObject
|
|
225
|
-
*/
|
|
226
|
-
function parseAxiosHttpRequestToFuzz(requestObject) {
|
|
227
|
-
let serverName = requestObject.serverName ? requestObject.serverName : LOCALHOST;
|
|
228
|
-
let host = serverName + COLON + requestObject.serverPort;
|
|
229
|
-
if (requestObject.headers && requestObject.headers['content-length']) {
|
|
230
|
-
delete requestObject.headers['content-length'];
|
|
231
|
-
}
|
|
232
|
-
return {
|
|
233
|
-
url: requestObject.protocol + COLON_SLASH_SLASH + host + requestObject.url,
|
|
234
|
-
method: requestObject.method,
|
|
235
|
-
data: requestObject.body,
|
|
236
|
-
headers: requestObject.headers,
|
|
237
|
-
timeout: 5000,
|
|
238
|
-
httpAgent: new http.Agent({ keepAlive: true }),
|
|
239
|
-
httpsAgent: new https.Agent({ keepAlive: true, rejectUnauthorized: false })
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
183
|
/**
|
|
244
184
|
* Parses the passed fuzz request object to
|
|
245
|
-
*
|
|
185
|
+
* grpc-js config.
|
|
246
186
|
*
|
|
247
187
|
* @param {JSON} requestObject
|
|
248
188
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/security-agent",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "New Relic Security Agent for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"jsonVersion": "1.2.9",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"Node.js Application Security"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=20",
|
|
33
33
|
"npm": ">=6.0.0"
|
|
34
34
|
},
|
|
35
35
|
"author": "newrelic",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"url": "https://github.com/newrelic/csec-node-agent.git"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"axios": "^1.12.0",
|
|
43
42
|
"check-disk-space": "^3.4.0",
|
|
44
43
|
"content-type": "^1.0.5",
|
|
45
44
|
"cron": "^3.1.7",
|
|
@@ -49,14 +48,15 @@
|
|
|
49
48
|
"html-entities": "^2.3.6",
|
|
50
49
|
"https-proxy-agent": "^7.0.4",
|
|
51
50
|
"is-invalid-path": "^1.0.2",
|
|
52
|
-
"js-yaml": "^4.1.
|
|
51
|
+
"js-yaml": "^4.1.1",
|
|
53
52
|
"jsonschema": "^1.4.1",
|
|
54
|
-
"lodash": "^4.17.
|
|
53
|
+
"lodash": "^4.17.23",
|
|
55
54
|
"log4js": "^6.9.1",
|
|
56
55
|
"pretty-bytes": "^5.6.0",
|
|
57
56
|
"request-ip": "^3.3.0",
|
|
58
57
|
"ringbufferjs": "^2.0.0",
|
|
59
58
|
"semver": "^7.5.4",
|
|
59
|
+
"undici": "^7.19.0",
|
|
60
60
|
"unescape": "^1.0.1",
|
|
61
61
|
"unescape-js": "^1.1.4",
|
|
62
62
|
"uuid": "^9.0.1",
|
|
@@ -87,11 +87,9 @@
|
|
|
87
87
|
"mongodb3": "npm:mongodb@^3.7.3",
|
|
88
88
|
"newrelic": "^10.3.1",
|
|
89
89
|
"request": "^2.88.2",
|
|
90
|
-
"restify": "^11.1.0",
|
|
91
90
|
"sinon": "^15.0.0",
|
|
92
91
|
"stream": "^0.0.2",
|
|
93
92
|
"tap": "^16.3.2",
|
|
94
|
-
"undici": "^5.28.0",
|
|
95
93
|
"xmldom": "^0.6.0",
|
|
96
94
|
"xpath": "^0.0.32",
|
|
97
95
|
"xpath.js": "^1.1.0"
|