@newrelic/security-agent 0.4.0 → 0.5.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/CHANGELOG.md +11 -0
- package/THIRD_PARTY_NOTICES.md +16 -17
- package/lib/instrumentation-security/hooks/@nestjs/nr-nestjs-core.js +62 -0
- package/lib/instrumentation-security/hooks/fs/nr-fs.js +1 -1
- package/lib/instrumentation-security/index.js +9 -0
- package/lib/nr-security-agent/lib/core/applicationinfo.js +1 -1
- package/lib/nr-security-agent/lib/core/connections/websocket/websocket.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
### v0.5.0 (2023-11-17)
|
|
2
|
+
#### Features
|
|
3
|
+
* IAST support for NestJS framework
|
|
4
|
+
#### Bug Fixes
|
|
5
|
+
* Fixed misspelled constant in fs.open() hook
|
|
6
|
+
* Minor fix in applicationInfo for pod properties
|
|
7
|
+
#### Miscellaneous chores
|
|
8
|
+
* Upgraded ws to v8.14.2 and updated initialization of websocket for v8.x.
|
|
9
|
+
* Upgraded check-disk-space to v3.4.0
|
|
10
|
+
* Upgraded @aws-sdk/client-lambda to v3.436.0
|
|
11
|
+
|
|
1
12
|
### v0.4.0 (2023-10-27)
|
|
2
13
|
#### Features
|
|
3
14
|
* Added event stats for RASP, IAST and exit events in healthcheck.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -75,7 +75,7 @@ code, the source code can be found at [https://github.com/newrelic/csec-node-age
|
|
|
75
75
|
|
|
76
76
|
### @aws-sdk/client-lambda
|
|
77
77
|
|
|
78
|
-
This product includes source derived from [@aws-sdk/client-lambda](https://github.com/aws/aws-sdk-js-v3) ([v3.
|
|
78
|
+
This product includes source derived from [@aws-sdk/client-lambda](https://github.com/aws/aws-sdk-js-v3) ([v3.436.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.436.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.436.0/LICENSE):
|
|
79
79
|
|
|
80
80
|
```
|
|
81
81
|
Apache License
|
|
@@ -299,7 +299,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
299
299
|
|
|
300
300
|
### check-disk-space
|
|
301
301
|
|
|
302
|
-
This product includes source derived from [check-disk-space](https://github.com/Alex-D/check-disk-space) ([v3.
|
|
302
|
+
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):
|
|
303
303
|
|
|
304
304
|
```
|
|
305
305
|
MIT License
|
|
@@ -795,30 +795,29 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
795
795
|
|
|
796
796
|
### ws
|
|
797
797
|
|
|
798
|
-
This product includes source derived from [ws](https://github.com/websockets/ws) ([
|
|
798
|
+
This product includes source derived from [ws](https://github.com/websockets/ws) ([v8.14.2](https://github.com/websockets/ws/tree/v8.14.2)), distributed under the [MIT License](https://github.com/websockets/ws/blob/v8.14.2/LICENSE):
|
|
799
799
|
|
|
800
800
|
```
|
|
801
|
-
The MIT License (MIT)
|
|
802
|
-
|
|
803
801
|
Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
802
|
+
Copyright (c) 2013 Arnout Kazemier and contributors
|
|
803
|
+
Copyright (c) 2016 Luigi Pinca and contributors
|
|
804
804
|
|
|
805
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
805
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
806
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
807
|
+
the Software without restriction, including without limitation the rights to
|
|
808
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
809
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
810
|
+
subject to the following conditions:
|
|
811
811
|
|
|
812
812
|
The above copyright notice and this permission notice shall be included in all
|
|
813
813
|
copies or substantial portions of the Software.
|
|
814
814
|
|
|
815
815
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
816
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
SOFTWARE.
|
|
816
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
817
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
818
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
819
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
820
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
822
821
|
|
|
823
822
|
```
|
|
824
823
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: New Relic Pre-Release
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict'
|
|
7
|
+
|
|
8
|
+
const secUtils = require('../../core/sec-utils');
|
|
9
|
+
const { ATTHERATE, DOUBLE_DOLLAR, EMPTY_STR } = require('../../core/constants');
|
|
10
|
+
const routeManager = require('../../core/route-manager');
|
|
11
|
+
const API = require("../../../nr-security-api");
|
|
12
|
+
const logger = API.getLogger();
|
|
13
|
+
const semver = require('semver')
|
|
14
|
+
|
|
15
|
+
const RequestMethods = {
|
|
16
|
+
"0": "GET",
|
|
17
|
+
"1": "POST",
|
|
18
|
+
"2": "PUT",
|
|
19
|
+
"3": "DELETE",
|
|
20
|
+
"4": "PATCH",
|
|
21
|
+
"5": "ALL",
|
|
22
|
+
"6": "OPTIONS",
|
|
23
|
+
"7": "HEAD",
|
|
24
|
+
"8": "SEARCH",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = function initialize(shim) {
|
|
28
|
+
const nestJsVersion = shim.require('./package.json').version
|
|
29
|
+
logger.info("Instrumenting nestjs", nestJsVersion)
|
|
30
|
+
if (semver.lt(nestJsVersion, '8.0.0')) {
|
|
31
|
+
logger.debug(
|
|
32
|
+
`Not instrumenting Nest.js version ${nestJsVersion}; minimum instrumentable version is 8.0.0`
|
|
33
|
+
)
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const routerExplorer = shim.require("./router/router-explorer").RouterExplorer;
|
|
38
|
+
|
|
39
|
+
shim.wrap(routerExplorer.prototype, 'applyCallbackToRouter', function wrapApplyCallbackToRouter(shim, fn) {
|
|
40
|
+
if (!shim.isFunction(fn)) {
|
|
41
|
+
return fn
|
|
42
|
+
}
|
|
43
|
+
return function wrappedApplyCallbackToRouter() {
|
|
44
|
+
try {
|
|
45
|
+
const stakTrace = secUtils.traceElementForRoute();
|
|
46
|
+
const splittedStack = stakTrace[0].split(DOUBLE_DOLLAR);
|
|
47
|
+
const verb = RequestMethods[arguments[1].requestMethod];
|
|
48
|
+
const path = (arguments[4].ctrlPath) + (arguments[1].path[0] == '/' ? EMPTY_STR : arguments[1].path[0]);
|
|
49
|
+
const key = verb + ATTHERATE + path;
|
|
50
|
+
routeManager.setRoute(key, splittedStack[0]);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
}
|
|
53
|
+
return fn.apply(this, arguments);
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
@@ -136,7 +136,7 @@ function openHook(shim, mod, moduleName) {
|
|
|
136
136
|
const trimedURL = url.split(QUESTIONMARK)[0];
|
|
137
137
|
if (!trimedURL.includes(path.basename(parameters[0])) || decodedURL.includes(DOTDOTSLASH) || dynamicScanningFlag) {
|
|
138
138
|
try {
|
|
139
|
-
if (parameters[0].startsWith(
|
|
139
|
+
if (parameters[0].startsWith(DOTDOTSLASH)) {
|
|
140
140
|
parameters[0] = agentModule.applicationInfo.serverInfo.deployedApplications[0].deployedPath + SLASH + parameters[0];
|
|
141
141
|
} else if (parameters[0].startsWith(SLASHDOTDOT)) {
|
|
142
142
|
parameters[0] = agentModule.applicationInfo.serverInfo.deployedApplications[0].deployedPath + parameters[0];
|
|
@@ -181,6 +181,15 @@ newrelic.instrumentWebframework({
|
|
|
181
181
|
}
|
|
182
182
|
})
|
|
183
183
|
|
|
184
|
+
newrelic.instrumentWebframework({
|
|
185
|
+
moduleName: '@nestjs/core',
|
|
186
|
+
isEsm: true,
|
|
187
|
+
onRequire: require('./hooks/@nestjs/nr-nestjs-core'),
|
|
188
|
+
onError: function intrumentErrorHandler(err) {
|
|
189
|
+
logger.error(err.message, err.stack)
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
|
|
184
193
|
|
|
185
194
|
|
|
186
195
|
|
|
@@ -589,7 +589,7 @@ function setPodProperties (identifier, containerProp) {
|
|
|
589
589
|
podProp.namespace = getPodNameSpace();
|
|
590
590
|
podProp.name = getHostName();
|
|
591
591
|
podProp.creationTimestamp = new Date().getTime();
|
|
592
|
-
podProp.
|
|
592
|
+
podProp.containerProperties.push(containerProp);
|
|
593
593
|
logger.debug("podProp:", podProp);
|
|
594
594
|
} catch (e) {
|
|
595
595
|
logger.error(e);
|
|
@@ -111,7 +111,7 @@ SecWebSocket.prototype.init = function init() {
|
|
|
111
111
|
logger.error("Error in reading certificate:", error);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
webSocket = new WebSocket(validatorService,
|
|
114
|
+
webSocket = new WebSocket(validatorService, { headers: authHeaders, cert: cert, handshakeTimeout: 10000 });
|
|
115
115
|
|
|
116
116
|
webSocket.on(WS_ON_OPEN, this.openCB);
|
|
117
117
|
webSocket.on(WS_ON_MSG, this.msgCB);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/security-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "New Relic Security Agent for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"jsonVersion": "1.1.0",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"url": "https://github.com/newrelic/csec-node-agent.git"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@aws-sdk/client-lambda": "^3.
|
|
38
|
+
"@aws-sdk/client-lambda": "^3.436.0",
|
|
39
39
|
"axios": "1.6.0",
|
|
40
|
-
"check-disk-space": "3.
|
|
40
|
+
"check-disk-space": "3.4.0",
|
|
41
41
|
"content-type": "^1.0.5",
|
|
42
42
|
"fast-safe-stringify": "^2.1.1",
|
|
43
43
|
"find-package-json": "^1.2.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"unescape": "^1.0.1",
|
|
57
57
|
"unescape-js": "^1.1.4",
|
|
58
58
|
"uuid": "^9.0.1",
|
|
59
|
-
"ws": "^
|
|
59
|
+
"ws": "^8.14.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@hapi/hapi": "^21.3.0",
|