@newrelic/security-agent 0.1.2 → 0.2.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.
Files changed (28) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/THIRD_PARTY_NOTICES.md +17 -28
  3. package/lib/instrumentation-security/core/constants.js +0 -1
  4. package/lib/instrumentation-security/hooks/fs/nr-fs.js +6 -5
  5. package/lib/instrumentation-security/hooks/http/nr-http.js +2 -2
  6. package/lib/instrumentation-security/hooks/mysql/nr-mysql.js +16 -0
  7. package/lib/instrumentation-security/hooks/native/nr-childProcess.js +1 -1
  8. package/lib/instrumentation-security/hooks/require/nr-require.js +12 -5
  9. package/lib/nr-security-agent/lib/core/Auth-headers.js +1 -0
  10. package/lib/nr-security-agent/lib/core/applicationinfo.js +1 -1
  11. package/lib/nr-security-agent/lib/core/commonUtils.js +12 -12
  12. package/lib/nr-security-agent/lib/core/connections/websocket/index.js +0 -6
  13. package/lib/nr-security-agent/lib/core/connections/websocket/response/IASTUtils.js +50 -0
  14. package/lib/nr-security-agent/lib/core/connections/websocket/response/collector-policy-handler.js +4 -1
  15. package/lib/nr-security-agent/lib/core/connections/websocket/response/fuzz-request-handler.js +90 -31
  16. package/lib/nr-security-agent/lib/core/connections/websocket/response/iast-cool-down.js +15 -0
  17. package/lib/nr-security-agent/lib/core/connections/websocket/response/iast-record-deletion.js +19 -0
  18. package/lib/nr-security-agent/lib/core/connections/websocket/response/index.js +17 -5
  19. package/lib/nr-security-agent/lib/core/connections/websocket/websocket.js +23 -61
  20. package/lib/nr-security-agent/lib/core/logging.js +89 -71
  21. package/lib/nr-security-agent/lib/core/sec-agent-constants.js +3 -2
  22. package/lib/nr-security-agent/lib/core/statusUtils.js +1 -1
  23. package/lib/nr-security-agent/lib/core/websocket-client.js +5 -168
  24. package/lib/nr-security-agent/lib/core/xss-utils.js +2 -3
  25. package/lib/nr-security-agent/resources/config.js +2 -2
  26. package/package.json +11 -11
  27. package/lib/nr-security-agent/lib/core/worker-entities.js +0 -82
  28. package/lib/nr-security-agent/lib/core/worker.js +0 -148
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ### v0.2.0 (2023-07-24)
2
+ #### Features
3
+ * IAST data pull implementation
4
+ * Logging update
5
+
6
+ #### Bug Fixes
7
+ * Param fixes for mysql and file hooks.
8
+
9
+ ### v0.1.3
10
+ * Updated semver to v7.5.3 (Fix for CWE-1333)
11
+ * Updated request-ip, log4js, html-entities, uuid and fast-safe-stringify to latest version.
12
+ * Fix for system call event generation to avoid null parameters in event.
13
+ * Fix for id in nr-csec-tracing-data.
14
+ * WS logging update.
15
+
1
16
  ### v0.1.2
2
17
  * bump @aws-sdk/client-lambda to v3.348.0
3
18
  * Minor fix in ws reconnect.
@@ -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.348.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.348.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.348.0/LICENSE):
78
+ This product includes source derived from [@aws-sdk/client-lambda](https://github.com/aws/aws-sdk-js-v3) ([v3.358.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.358.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.358.0/LICENSE):
79
79
 
80
80
  ```
81
81
  Apache License
@@ -311,7 +311,7 @@ THE SOFTWARE.
311
311
 
312
312
  ### check-disk-space
313
313
 
314
- This product includes source derived from [check-disk-space](https://github.com/Alex-D/check-disk-space) ([v3.3.1](https://github.com/Alex-D/check-disk-space/tree/v3.3.1)), distributed under the [MIT License](https://github.com/Alex-D/check-disk-space/blob/v3.3.1/LICENSE):
314
+ 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
315
 
316
316
  ```
317
317
  MIT License
@@ -433,10 +433,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
433
433
 
434
434
  ### html-entities
435
435
 
436
- This product includes source derived from [html-entities](https://github.com/mdevils/node-html-entities) ([v1.4.0](https://github.com/mdevils/node-html-entities/tree/v1.4.0)), distributed under the [MIT License](https://github.com/mdevils/node-html-entities/blob/v1.4.0/LICENSE):
436
+ This product includes source derived from [html-entities](https://github.com/mdevils/html-entities) ([v2.3.6](https://github.com/mdevils/html-entities/tree/v2.3.6)), distributed under the [MIT License](https://github.com/mdevils/html-entities/blob/v2.3.6/LICENSE):
437
437
 
438
438
  ```
439
- Copyright (c) 2013 Dulin Marat
439
+ Copyright (c) 2021 Dulin Marat
440
440
 
441
441
  Permission is hereby granted, free of charge, to any person obtaining a copy
442
442
  of this software and associated documentation files (the "Software"), to deal
@@ -455,6 +455,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
455
455
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
456
456
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
457
457
  THE SOFTWARE.
458
+
458
459
  ```
459
460
 
460
461
  ### is-invalid-path
@@ -639,7 +640,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
639
640
 
640
641
  ### request-ip
641
642
 
642
- This product includes source derived from [request-ip](https://github.com/pbojinov/request-ip) ([v2.2.0](https://github.com/pbojinov/request-ip/tree/v2.2.0)), distributed under the [MIT License](https://github.com/pbojinov/request-ip/blob/v2.2.0/LICENSE.md):
643
+ This product includes source derived from [request-ip](https://github.com/pbojinov/request-ip) ([v3.3.0](https://github.com/pbojinov/request-ip/tree/v3.3.0)), distributed under the [MIT License](https://github.com/pbojinov/request-ip/blob/v3.3.0/LICENSE.md):
643
644
 
644
645
  ```
645
646
  The MIT License (MIT)
@@ -683,7 +684,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
683
684
 
684
685
  ### semver
685
686
 
686
- This product includes source derived from [semver](https://github.com/npm/node-semver) ([v6.3.0](https://github.com/npm/node-semver/tree/v6.3.0)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v6.3.0/LICENSE):
687
+ This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.5.3](https://github.com/npm/node-semver/tree/v7.5.3)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.5.3/LICENSE):
687
688
 
688
689
  ```
689
690
  The ISC License
@@ -789,30 +790,18 @@ THE SOFTWARE.
789
790
 
790
791
  ### uuid
791
792
 
792
- This product includes source derived from [uuid](https://github.com/uuidjs/uuid) ([v3.4.0](https://github.com/uuidjs/uuid/tree/v3.4.0)), distributed under the [MIT License](https://github.com/uuidjs/uuid/blob/v3.4.0/LICENSE.md):
793
+ This product includes source derived from [uuid](https://github.com/uuidjs/uuid) ([v9.0.0](https://github.com/uuidjs/uuid/tree/v9.0.0)), distributed under the [MIT License](https://github.com/uuidjs/uuid/blob/v9.0.0/LICENSE.md):
793
794
 
794
795
  ```
795
796
  The MIT License (MIT)
796
797
 
797
- Copyright (c) 2010-2016 Robert Kieffer and other contributors
798
+ Copyright (c) 2010-2020 Robert Kieffer and other contributors
798
799
 
799
- Permission is hereby granted, free of charge, to any person obtaining a copy
800
- of this software and associated documentation files (the "Software"), to deal
801
- in the Software without restriction, including without limitation the rights
802
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
803
- copies of the Software, and to permit persons to whom the Software is
804
- furnished to do so, subject to the following conditions:
800
+ 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:
805
801
 
806
- The above copyright notice and this permission notice shall be included in all
807
- copies or substantial portions of the Software.
802
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
808
803
 
809
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
810
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
811
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
812
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
813
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
814
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
815
- SOFTWARE.
804
+ 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.
816
805
 
817
806
  ```
818
807
 
@@ -1851,7 +1840,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1851
1840
 
1852
1841
  ### mongodb-memory-server
1853
1842
 
1854
- This product includes source derived from [mongodb-memory-server](https://github.com/nodkz/mongodb-memory-server) ([v8.12.2](https://github.com/nodkz/mongodb-memory-server/tree/v8.12.2)), distributed under the [MIT License](https://github.com/nodkz/mongodb-memory-server/blob/v8.12.2/LICENSE.md):
1843
+ This product includes source derived from [mongodb-memory-server](https://github.com/nodkz/mongodb-memory-server) ([v8.13.0](https://github.com/nodkz/mongodb-memory-server/tree/v8.13.0)), distributed under the [MIT License](https://github.com/nodkz/mongodb-memory-server/blob/v8.13.0/LICENSE.md):
1855
1844
 
1856
1845
  ```
1857
1846
  The MIT License (MIT)
@@ -2076,7 +2065,7 @@ Apache License
2076
2065
 
2077
2066
  ### mongodb
2078
2067
 
2079
- This product includes source derived from [mongodb](https://github.com/mongodb/node-mongodb-native) ([v3.7.3](https://github.com/mongodb/node-mongodb-native/tree/v3.7.3)), distributed under the [Apache-2.0 License](undefined):
2068
+ This product includes source derived from [mongodb](https://github.com/mongodb/node-mongodb-native) ([v3.7.4](https://github.com/mongodb/node-mongodb-native/tree/v3.7.4)), distributed under the [Apache-2.0 License](undefined):
2080
2069
 
2081
2070
  ```
2082
2071
  Apache License
@@ -2492,7 +2481,7 @@ Apache License
2492
2481
 
2493
2482
  ### newrelic
2494
2483
 
2495
- This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v9.15.0](https://github.com/newrelic/node-newrelic/tree/v9.15.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v9.15.0/LICENSE):
2484
+ This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v10.3.1](https://github.com/newrelic/node-newrelic/tree/v10.3.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v10.3.1/LICENSE):
2496
2485
 
2497
2486
  ```
2498
2487
  Apache License
@@ -2789,7 +2778,7 @@ THE SOFTWARE
2789
2778
 
2790
2779
  ### sinon
2791
2780
 
2792
- This product includes source derived from [sinon](https://github.com/sinonjs/sinon) ([v15.0.4](https://github.com/sinonjs/sinon/tree/v15.0.4)), distributed under the [BSD-3-Clause License](https://github.com/sinonjs/sinon/blob/v15.0.4/LICENSE):
2781
+ 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):
2793
2782
 
2794
2783
  ```
2795
2784
  (The BSD License)
@@ -2824,7 +2813,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2824
2813
 
2825
2814
  ### tap
2826
2815
 
2827
- This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.4](https://github.com/tapjs/node-tap/tree/v16.3.4)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.3.4/LICENSE):
2816
+ This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.7](https://github.com/tapjs/node-tap/tree/v16.3.7)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.3.7/LICENSE):
2828
2817
 
2829
2818
  ```
2830
2819
  The ISC License
@@ -60,7 +60,6 @@ module.exports = {
60
60
  SLASHDOTDOT: '/..',
61
61
  UNDEFINED: 'undefined',
62
62
  SELF_FD_PATH: '/proc/self/fd/',
63
- CSEC_LAST_FUZZ_REQUEST_TIME: 'CSEC_LAST_FUZZ_REQUEST_TIME',
64
63
  NR_CSEC_FUZZ_REQUEST_ID: 'nr-csec-fuzz-request-id',
65
64
 
66
65
  };
@@ -16,6 +16,7 @@ const logger = API.getLogger();
16
16
  const { STRING, QUESTIONMARK, DOTDOTSLASH, UNDEFINED, SELF_FD_PATH, SLASH, SLASHDOTDOT, NR_CSEC_FUZZ_REQUEST_ID } = require('../../core/constants');
17
17
  const fsConsts = process.binding('constants').fs;
18
18
  const agentModule = API.getSecAgent();
19
+ const lodash = require('lodash');
19
20
 
20
21
  const requireHook = require('../require/nr-require');
21
22
 
@@ -127,7 +128,7 @@ function openHook(shim, mod, moduleName) {
127
128
  parameters[0] = arguments[0];
128
129
  }
129
130
  }
130
- if (request && typeof parameters[0] === STRING) {
131
+ if (request && typeof parameters[0] === STRING && !lodash.isEmpty(parameters[0]) ) {
131
132
  const policy = API.getPolicy();
132
133
  const dynamicScanningFlag = policy.data ? policy.data.vulnerabilityScan.iastScan.enabled : false;
133
134
  const url = request.url;
@@ -180,7 +181,7 @@ function probableToFAHooks(shim, mod, moduleName) {
180
181
  const interceptedArgs = [arguments[0]];
181
182
  shim.interceptedArgs = interceptedArgs;
182
183
  const request = requestManager.getRequest(shim);
183
- if (request && typeof arguments[0] === STRING) {
184
+ if (request && typeof arguments[0] === STRING && !lodash.isEmpty(arguments[0])) {
184
185
  const traceObject = secUtils.getTraceObject(shim);
185
186
  const secMetadata = securityMetaData.getSecurityMetaData(request, interceptedArgs, traceObject, secUtils.getExecutionId(), EVENT_TYPE.FILE_OPERATION, EVENT_CATEGORY.FILE)
186
187
  this.secEvent = API.generateSecEvent(secMetadata);
@@ -209,7 +210,7 @@ function probableToFIHooks(shim, mod, moduleName) {
209
210
  const interceptedArgs = [arguments[0]];
210
211
  shim.interceptedArgs = interceptedArgs;
211
212
  const request = requestManager.getRequest(shim);
212
- if (request && typeof arguments[0] === STRING) {
213
+ if (request && typeof arguments[0] === STRING && !lodash.isEmpty(arguments[0])) {
213
214
  const traceObject = secUtils.getTraceObject(shim);
214
215
  if (fun === COPY_FILE || fun === RENAME) {
215
216
  const secMetadata = securityMetaData.getSecurityMetaData(request, arguments[1], traceObject, secUtils.getExecutionId(), getCase(arguments[1]), EVENT_CATEGORY.FILE)
@@ -243,7 +244,7 @@ function probablePromiseToFAHooks(shim, mod, moduleName) {
243
244
  const interceptedArgs = [arguments[0]];
244
245
  shim.interceptedArgs = interceptedArgs;
245
246
  const request = requestManager.getRequest(shim);
246
- if (request && typeof arguments[0] === STRING) {
247
+ if (request && typeof arguments[0] === STRING && !lodash.isEmpty(arguments[0])) {
247
248
  const traceObject = secUtils.getTraceObject(shim);
248
249
  const secMetadata = securityMetaData.getSecurityMetaData(request, interceptedArgs, traceObject, secUtils.getExecutionId(), EVENT_TYPE.FILE_OPERATION, EVENT_CATEGORY.FILE)
249
250
  this.secEvent = API.generateSecEvent(secMetadata);
@@ -268,7 +269,7 @@ function probablePromiseToFIHooks(shim, mod, moduleName) {
268
269
  const interceptedArgs = [arguments[0]];
269
270
  shim.interceptedArgs = interceptedArgs;
270
271
  const request = requestManager.getRequest(shim);
271
- if (request && typeof arguments[0] === STRING) {
272
+ if (request && typeof arguments[0] === STRING && !lodash.isEmpty(arguments[0])) {
272
273
  const traceObject = secUtils.getTraceObject(shim);
273
274
  if (fun === COPY_FILE || fun === RENAME) {
274
275
  const secMetadata = securityMetaData.getSecurityMetaData(request, arguments[1], traceObject, secUtils.getExecutionId(), getCase(arguments[1]), EVENT_CATEGORY.FILE)
@@ -135,10 +135,10 @@ function outboundHook(shim, mod, method, moduleName) {
135
135
  if (arguments[0] instanceof Object) {
136
136
  if (arguments[0] && arguments[0].headers && request.headers) {
137
137
  arguments[0].headers.SECHOOK = id;
138
- arguments[0].headers[NRCSECTRACINGDATA] = traceHeader + appUUID + '/' + this.secEvent.apiId + '/' + id + ';';
138
+ arguments[0].headers[NRCSECTRACINGDATA] = traceHeader + appUUID + '/' + this.secEvent.apiId + '/' + this.secEvent.id + ';';
139
139
  } else {
140
140
  arguments[0].headers = {};
141
- arguments[0].headers[NRCSECTRACINGDATA] = traceHeader + appUUID + '/' + this.secEvent.apiId + '/' + id + ';';
141
+ arguments[0].headers[NRCSECTRACINGDATA] = traceHeader + appUUID + '/' + this.secEvent.apiId + '/' + this.secEvent.id + ';';
142
142
  arguments[0].headers.SECHOOK = id;
143
143
  }
144
144
  if (request && request.headers[NR_CSEC_FUZZ_REQUEST_ID] && arguments[0].headers) {
@@ -171,6 +171,19 @@ function wrapQueryable(shim, queryable, isPoolQuery) {
171
171
  }
172
172
  return true;
173
173
  }
174
+ /**
175
+ * Utility to check list contains only string
176
+ * @param {*} list
177
+ * @returns
178
+ */
179
+ function containsOnlyStrings(list) {
180
+ for (let i = 0; i < list.length; i++) {
181
+ if (typeof list[i] !== 'string') {
182
+ return false;
183
+ }
184
+ }
185
+ return true;
186
+ }
174
187
 
175
188
  /**
176
189
  * Utility to extract query from the intercepted args
@@ -199,6 +212,9 @@ function extractQueryArgs(shim, args) {
199
212
  param = args[1];
200
213
  param = Object.values(param)
201
214
  }
215
+ if(!containsOnlyStrings(param)){
216
+ param = [];
217
+ }
202
218
  return {
203
219
  rawQuery: rawQuery,
204
220
  param: param,
@@ -30,7 +30,7 @@ function execFileHook(shim, childProcess, moduleName) {
30
30
  const interceptedArgs = [arguments[0]];
31
31
  shim.interceptedArgs = interceptedArgs;
32
32
  const request = requestManager.getRequest(shim);
33
- if (request) {
33
+ if (request && arguments[0]) {
34
34
  const traceObject = secUtils.getTraceObject(shim);
35
35
  const secMetadata = securityMetaData.getSecurityMetaData(request, interceptedArgs, traceObject, secUtils.getExecutionId(), EVENT_TYPE.SYSTEM_COMMAND, EVENT_CATEGORY.SYS)
36
36
  const secEvent = API.generateSecEvent(secMetadata);
@@ -14,9 +14,11 @@ const Module = require('module');
14
14
  const refDirRegEx = /^(\.\/)|^(\.\.\/)/g;
15
15
  const path = require('path');
16
16
  const CSEC = 'nr-security-agent';
17
+ const FN_INSPECT = '@contrast/fn-inspect';
18
+ const NEWRELIC = 'newrelic';
17
19
 
18
20
  /**
19
- * Entry point for xpath module hook
21
+ * Entry point for require module hook
20
22
  * @param {*} shim
21
23
  * @param {*} mod
22
24
  * @param {*} moduleName
@@ -33,17 +35,22 @@ function initialize(shim) {
33
35
  if (arguments[0].match(refDirRegEx) && arguments[1] && arguments[1].path) {
34
36
  moduleName = path.resolve(arguments[1].path, arguments[0]);
35
37
  }
36
-
38
+
37
39
  let flag = false;
38
- if (moduleName && typeof (moduleName) === STRING && !moduleName.includes(CSEC)) {
40
+ if (moduleName && typeof (moduleName) === STRING && !moduleName.includes(CSEC) && !moduleName.includes(FN_INSPECT)) {
39
41
  flag = true;
40
42
  }
41
- else if (parent && parent.id && typeof (parent.id) === STRING && moduleName.includes(CSEC) && parent.id.includes(CSEC)) {
43
+ else if (parent && parent.id && typeof (parent.id) === STRING && moduleName.includes(CSEC) && parent.id.includes(CSEC) && moduleName.includes(FN_INSPECT)) {
42
44
  flag = false;
43
45
  }
44
- else if (parent && parent.id && moduleName && typeof (moduleName) === STRING && moduleName.includes(CSEC) && parent.id.includes(CSEC)) {
46
+ else if (parent && parent.id && moduleName && typeof (moduleName) === STRING && moduleName.includes(CSEC) && parent.id.includes(CSEC) && moduleName.includes(FN_INSPECT)) {
45
47
  flag = false;
46
48
  }
49
+
50
+ if ((parent && parent.id && typeof (parent.id) === STRING && parent.id.includes(NEWRELIC)) || moduleName.includes(NEWRELIC)){
51
+ flag = false;
52
+ }
53
+
47
54
  if (flag) {
48
55
  requireHook(shim, moduleName, parent);
49
56
  }
@@ -31,6 +31,7 @@ function AuthHeaders() {
31
31
  authHeaders['NR-CSEC-BUILD-NUMBER'] = appInfo.buildNumber;
32
32
  authHeaders['NR-ACCOUNT-ID'] = NRAgent.config.account_id;
33
33
  authHeaders['NR-LICENSE-KEY'] = NRAgent ? NRAgent.config.license_key : '';
34
+ authHeaders["NR-CSEC-IAST-DATA-TRANSFER-MODE"] = "PULL";
34
35
  } catch (error) {
35
36
  logger.error("Exception in preparing auth headers:", error);
36
37
  }
@@ -200,7 +200,7 @@ ApplicationInfo.prototype.updateSHAAndSize = async function updateSHAAndSize (Gl
200
200
  applicationInfo.sha256 = await shaSizeUtil.getSHA256ForFile(process.argv[0]);
201
201
 
202
202
  let stat = {};
203
- if (process.hasWorker) {
203
+ if (commonUtils.hasWorker()) {
204
204
  stat = await getApplicationSHAAndSizeFromWorker(applicationInfo, application.deployedPath);
205
205
  } else {
206
206
  stat = await shaSizeUtil.getApplicationSHAAndSize(application.deployedPath, GlobalPromise);
@@ -5,7 +5,7 @@
5
5
 
6
6
  /* eslint-disable prefer-promise-reject-errors */
7
7
  const fs = require('fs');
8
- const uuidv4 = require('uuid/v4');
8
+ const uuidV = require('uuid');
9
9
  const logs = require('./logging');
10
10
  const logger = logs.getLogger();
11
11
  const OS = require('os');
@@ -27,7 +27,7 @@ let websocketHealth;
27
27
  * @returns UUID
28
28
  */
29
29
  function getUUID(){
30
- let uuid = process.env.applicationUUID || uuidv4();
30
+ let uuid = process.env.applicationUUID || uuidV.v4();
31
31
  process.env.applicationUUID = uuid;
32
32
  return uuid;
33
33
  }
@@ -55,8 +55,14 @@ function getKindIdPair (identifier, hostId) {
55
55
  * @returns
56
56
  */
57
57
  function hasWorker () {
58
- process.hasWorker = false;
59
- return process.hasWorker;
58
+ let workerFlag = false;
59
+ try {
60
+ require('worker_threads');
61
+ workerFlag = true;
62
+ } catch (error) {
63
+ workerFlag = false;
64
+ }
65
+ return workerFlag;
60
66
  }
61
67
 
62
68
  function runtimeSupportsFunctionGenerators () {
@@ -136,13 +142,6 @@ function createDirectories () {
136
142
  */
137
143
  async function initialSetup () {
138
144
  try {
139
- checkDiskSpace(`${CSEC_HOME}`).then((diskSpace) => {
140
- if (diskSpace.free < 1000000000) {
141
- logger.error(LOG_MESSAGES.AVAIL_DISK_ERROR, `${CSEC_HOME}`, prettyBytes(diskSpace.free));
142
- process.exit();
143
- }
144
- }).catch(() => {
145
- });
146
145
  createDirectories();
147
146
  } catch (err) {
148
147
  logger.error(err);
@@ -329,7 +328,8 @@ function logRollOver () {
329
328
  return;
330
329
  }
331
330
  } catch (error) {
332
- logger.error('Error in getting stats of log file:', error);
331
+ logger.debug('Error in getting stats of log file:', error.message);
332
+ return;
333
333
  }
334
334
 
335
335
  try {
@@ -6,9 +6,6 @@
6
6
  const {
7
7
  SecWebSocket,
8
8
  WSCallbacks,
9
- aquireWebSocket,
10
- isWebSocketBusy,
11
- releaseWebSocket,
12
9
  setWebSocketConn
13
10
  } = require('./websocket');
14
11
 
@@ -17,9 +14,6 @@ const ResponseHandler = require('./response');
17
14
  module.exports = {
18
15
  SecWebSocket,
19
16
  WSCallbacks,
20
- aquireWebSocket,
21
- isWebSocketBusy,
22
- releaseWebSocket,
23
17
  setWebSocketConn,
24
18
  ResponseHandler
25
19
  };
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2023 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: New Relic Pre-Release
4
+ */
5
+ const { Agent } = require('../../../agent');
6
+ let completedRequestIds = new Set();
7
+ const PolicyManager = require('../../../Policy');
8
+ let batchSize;
9
+ const batchthreshold = 300;
10
+ function getCompletedRequestIds() {
11
+ return [...completedRequestIds];
12
+ }
13
+
14
+ function addRequestId(id) {
15
+ completedRequestIds.add(id);
16
+ }
17
+
18
+ function removeRequestId(id) {
19
+ completedRequestIds.delete(id);
20
+ }
21
+
22
+ function generateIASTDataRequest() {
23
+ const policyInstance = PolicyManager.getInstance();
24
+ if (policyInstance.data && policyInstance.data.vulnerabilityScan && policyInstance.data.vulnerabilityScan.iastScan) {
25
+ batchSize = batchSize ? batchSize : policyInstance.data.vulnerabilityScan.iastScan.probing.batchSize;
26
+ if (batchSize > batchthreshold) {
27
+ batchSize = policyInstance.data.vulnerabilityScan.iastScan.probing.batchSize;
28
+ }
29
+ }
30
+ if (getCompletedRequestIds().length >= batchSize || batchSize < batchthreshold) {
31
+ batchSize = (2 * batchSize);
32
+ }
33
+ let object = {};
34
+ object['jsonName'] = 'iast-data-request';
35
+ object['applicationUUID'] = Agent.getAgent().applicationInfo.applicationUUID;
36
+ object["batchSize"] = batchSize ? batchSize : 300;
37
+ object['completedRequestIds'] = getCompletedRequestIds();
38
+ return object;
39
+
40
+ }
41
+
42
+
43
+ module.exports = {
44
+ getCompletedRequestIds,
45
+ addRequestId,
46
+ removeRequestId,
47
+ generateIASTDataRequest,
48
+ }
49
+
50
+
@@ -11,7 +11,10 @@ module.exports.handler = function handler(json) {
11
11
  const policyData = json.data;
12
12
  const PolicyManager = require('../../../Policy');
13
13
  PolicyManager.setPolicyData(policyData);
14
-
14
+ if (policyData.vulnerabilityScan.enabled && policyData.vulnerabilityScan.iastScan.enabled) {
15
+ require('./fuzz-request-handler').startIASTSchedular();
16
+ }
17
+
15
18
  } catch (error) {
16
19
  logger.error('paring exception while parsing configuration', error);
17
20
  }