@newrelic/security-agent 0.7.0 → 1.1.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 (90) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +20 -25
  3. package/README.md +16 -2
  4. package/lib/instrumentation-security/core/constants.js +1 -1
  5. package/lib/instrumentation-security/core/event-constants.js +1 -1
  6. package/lib/instrumentation-security/core/grpc-utils.js +53 -0
  7. package/lib/instrumentation-security/core/request-manager.js +1 -1
  8. package/lib/instrumentation-security/core/route-manager.js +29 -6
  9. package/lib/instrumentation-security/core/sec-trace.js +1 -1
  10. package/lib/instrumentation-security/core/sec-utils.js +4 -4
  11. package/lib/instrumentation-security/core/security-metadata.js +1 -1
  12. package/lib/instrumentation-security/core/stack-trace.js +1 -1
  13. package/lib/instrumentation-security/hooks/@nestjs/nr-nestjs-core.js +1 -1
  14. package/lib/instrumentation-security/hooks/director/nr-director.js +1 -1
  15. package/lib/instrumentation-security/hooks/express/nr-express.js +3 -5
  16. package/lib/instrumentation-security/hooks/fastify/nr-fastify.js +1 -1
  17. package/lib/instrumentation-security/hooks/fs/nr-fs.js +1 -1
  18. package/lib/instrumentation-security/hooks/grpc-js/nr-grpc.js +284 -0
  19. package/lib/instrumentation-security/hooks/hapi/nr-hapi.js +1 -1
  20. package/lib/instrumentation-security/hooks/http/nr-http.js +1 -1
  21. package/lib/instrumentation-security/hooks/koa/@koa/nr-@koa-router.js +1 -1
  22. package/lib/instrumentation-security/hooks/ldap/nr-ldap.js +1 -1
  23. package/lib/instrumentation-security/hooks/mongodb/common.js +1 -1
  24. package/lib/instrumentation-security/hooks/mongodb/constants.js +1 -1
  25. package/lib/instrumentation-security/hooks/mongodb/nr-mongodb.js +1 -1
  26. package/lib/instrumentation-security/hooks/mongodb/v2-mongo.js +1 -1
  27. package/lib/instrumentation-security/hooks/mongodb/v3-mongo.js +1 -1
  28. package/lib/instrumentation-security/hooks/mongodb/v4-mongo.js +1 -1
  29. package/lib/instrumentation-security/hooks/mysql/nr-mysql.js +1 -1
  30. package/lib/instrumentation-security/hooks/native/nr-childProcess.js +1 -1
  31. package/lib/instrumentation-security/hooks/postgres/nr-postgres.js +1 -1
  32. package/lib/instrumentation-security/hooks/require/nr-require.js +1 -1
  33. package/lib/instrumentation-security/hooks/restify/nr-restify.js +1 -1
  34. package/lib/instrumentation-security/hooks/undici/nr-undici.js +139 -0
  35. package/lib/instrumentation-security/hooks/xpath/nr-xpath.js +1 -1
  36. package/lib/instrumentation-security/index.js +57 -1
  37. package/lib/nr-security-agent/index.js +1 -1
  38. package/lib/nr-security-agent/lib/core/Auth-headers.js +1 -1
  39. package/lib/nr-security-agent/lib/core/ContainerProperties.js +1 -1
  40. package/lib/nr-security-agent/lib/core/ECSProperties.js +1 -1
  41. package/lib/nr-security-agent/lib/core/FuzzFailEvent.js +1 -1
  42. package/lib/nr-security-agent/lib/core/LinkingMetadata.js +1 -1
  43. package/lib/nr-security-agent/lib/core/LogMessage.js +1 -1
  44. package/lib/nr-security-agent/lib/core/PodProperties.js +1 -1
  45. package/lib/nr-security-agent/lib/core/Policy.js +1 -1
  46. package/lib/nr-security-agent/lib/core/agent-status.js +1 -1
  47. package/lib/nr-security-agent/lib/core/agent.js +1 -1
  48. package/lib/nr-security-agent/lib/core/apiEndpoints.js +29 -0
  49. package/lib/nr-security-agent/lib/core/applicationinfo.js +1 -1
  50. package/lib/nr-security-agent/lib/core/commonUtils.js +5 -5
  51. package/lib/nr-security-agent/lib/core/connections/aws-lambda-client.js +1 -1
  52. package/lib/nr-security-agent/lib/core/connections/grpcClient.js +111 -0
  53. package/lib/nr-security-agent/lib/core/connections/restclient.js +1 -1
  54. package/lib/nr-security-agent/lib/core/connections/websocket/index.js +1 -1
  55. package/lib/nr-security-agent/lib/core/connections/websocket/response/IASTUtils.js +1 -1
  56. package/lib/nr-security-agent/lib/core/connections/websocket/response/collecotor-policy-error-handler.js +1 -1
  57. package/lib/nr-security-agent/lib/core/connections/websocket/response/collector-policy-handler.js +1 -1
  58. package/lib/nr-security-agent/lib/core/connections/websocket/response/fuzz-request-handler.js +32 -12
  59. package/lib/nr-security-agent/lib/core/connections/websocket/response/iast-cool-down.js +1 -1
  60. package/lib/nr-security-agent/lib/core/connections/websocket/response/iast-record-deletion.js +1 -1
  61. package/lib/nr-security-agent/lib/core/connections/websocket/response/index.js +1 -1
  62. package/lib/nr-security-agent/lib/core/connections/websocket/response/no-op-handler.js +1 -1
  63. package/lib/nr-security-agent/lib/core/connections/websocket/response/startup-handshake-handler.js +4 -1
  64. package/lib/nr-security-agent/lib/core/connections/websocket/response/unsupported-agent-handler.js +1 -1
  65. package/lib/nr-security-agent/lib/core/connections/websocket/response/ws-reconnect.js +1 -1
  66. package/lib/nr-security-agent/lib/core/connections/websocket/websocket.js +1 -1
  67. package/lib/nr-security-agent/lib/core/event-stats.js +1 -1
  68. package/lib/nr-security-agent/lib/core/event.js +7 -2
  69. package/lib/nr-security-agent/lib/core/health-check.js +1 -1
  70. package/lib/nr-security-agent/lib/core/json-file-handler.js +1 -1
  71. package/lib/nr-security-agent/lib/core/jsonValidator.js +1 -1
  72. package/lib/nr-security-agent/lib/core/lambda-delegated-task-service.js +1 -1
  73. package/lib/nr-security-agent/lib/core/logging.js +6 -6
  74. package/lib/nr-security-agent/lib/core/sec-agent-constants.js +1 -1
  75. package/lib/nr-security-agent/lib/core/sec-util.js +1 -1
  76. package/lib/nr-security-agent/lib/core/sha-size-util.js +1 -1
  77. package/lib/nr-security-agent/lib/core/sha_worker.js +1 -1
  78. package/lib/nr-security-agent/lib/core/startup-config.js +1 -1
  79. package/lib/nr-security-agent/lib/core/statusUtils.js +3 -3
  80. package/lib/nr-security-agent/lib/core/timeunit.js +1 -1
  81. package/lib/nr-security-agent/lib/core/websocket-client.js +11 -2
  82. package/lib/nr-security-agent/lib/core/xss-utils.js +1 -1
  83. package/lib/nr-security-agent/lib/models/lambda-delegated-task/constants.js +1 -1
  84. package/lib/nr-security-agent/lib/models/lambda-delegated-task/index.js +1 -1
  85. package/lib/nr-security-agent/lib/models/lambda-delegated-task/lambda-delegated-sha-calculation.js +1 -1
  86. package/lib/nr-security-agent/lib/models/lambda-delegated-task/lambda-delegated-task-base.js +1 -1
  87. package/lib/nr-security-agent/lib/models/lambda-delegated-task/lambda-delegated-task-type.js +1 -1
  88. package/lib/nr-security-agent/resources/config.js +1 -1
  89. package/lib/nr-security-api/index.js +1 -1
  90. package/package.json +7 -3
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const { BasicInfo } = require('./event');
@@ -1,7 +1,7 @@
1
1
 
2
2
  /*
3
3
  * Copyright 2023 New Relic Corporation. All rights reserved.
4
- * SPDX-License-Identifier: New Relic Pre-Release
4
+ * SPDX-License-Identifier: New Relic Software License v1.0
5
5
  */
6
6
 
7
7
  const API = require('../../../nr-security-api');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const LinkingMetaData = require('./LinkingMetadata');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let podProperties;
@@ -1,7 +1,7 @@
1
1
 
2
2
  /*
3
3
  * Copyright 2023 New Relic Corporation. All rights reserved.
4
- * SPDX-License-Identifier: New Relic Pre-Release
4
+ * SPDX-License-Identifier: New Relic Software License v1.0
5
5
  */
6
6
 
7
7
  const API = require('../../../nr-security-api');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
  const SecAgentStatus = function () {
6
6
  if (Object.getPrototypeOf(this).constructor !== SecAgentStatus) {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const { EventEmitter } = require('events');
@@ -0,0 +1,29 @@
1
+
2
+ /*
3
+ * Copyright 2023 New Relic Corporation. All rights reserved.
4
+ * SPDX-License-Identifier: New Relic Software License v1.0
5
+ */
6
+
7
+ const { BasicInfo } = require('./event');
8
+ const applicationInfo = require('./applicationinfo').getInstance();
9
+ /**
10
+ * Function Constructor to create object of FuzzFail event
11
+ * @param {*} fuzzHeader
12
+ */
13
+ function APIEndPoint (apiEndpoints) {
14
+ BasicInfo.call(this);
15
+ this.jsonVersion = applicationInfo.jsonVersion;
16
+ this.jsonName = 'sec-application-url-mapping';
17
+ this.eventType = "sec-application-url-mapping"
18
+ this.applicationUUID = applicationInfo.applicationUUID;
19
+ this.groupName = applicationInfo.groupName;
20
+ this.mappings = apiEndpoints;
21
+
22
+ return this;
23
+ }
24
+
25
+ APIEndPoint.prototype.constructor = APIEndPoint;
26
+
27
+ module.exports = {
28
+ APIEndPoint
29
+ };
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  /* eslint-disable prefer-promise-reject-errors */
@@ -97,11 +97,11 @@ function runtimeSupportsAsyncFunctionGenerators() {
97
97
  function createPathIfNotExist(dir) {
98
98
  try {
99
99
  if (!fs.existsSync(dir)) {
100
- fs.mkdirSync(dir, 777, { recursive: true });
100
+ fs.mkdirSync(dir, 770, { recursive: true });
101
101
  logger.info(dir + ' Created');
102
- fs.chmodSync(dir, 0o777);
102
+ fs.chmodSync(dir, 0o770);
103
103
  } else {
104
- fs.chmodSync(dir, 0o777);
104
+ fs.chmodSync(dir, 0o770);
105
105
  logger.debug(dir + ' Already Exists');
106
106
  }
107
107
  } catch (error) {
@@ -139,7 +139,7 @@ function createDirectories() {
139
139
  createPathIfNotExist(`${CSEC_HOME}${SLASH}nr-security-home${SLASH}tmp${SLASH}language-agent${SLASH}${getUUID()}`);
140
140
  createPathIfNotExist(`${CSEC_HOME}${SLASH}nr-security-home${SLASH}tmp${SLASH}language-agent${SLASH}${getUUID()}${SLASH}ds-tmp`);
141
141
  try {
142
- fs.chmodSync(`${CSEC_HOME}${SLASH}nr-security-home`, 0o777);
142
+ fs.chmodSync(`${CSEC_HOME}${SLASH}nr-security-home`, 0o770);
143
143
  } catch (error) {
144
144
  }
145
145
  }
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const _ = require('lodash');
@@ -0,0 +1,111 @@
1
+ /*
2
+ * Copyright 2023 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: New Relic Pre-Release
4
+ */
5
+ const logger = require('../logging').getLogger();
6
+ const grpcutils = require('../../../../instrumentation-security/core/grpc-utils');
7
+ const clientMap = new Map();
8
+ let grpc;
9
+ const { NR_CSEC_FUZZ_REQUEST_ID } = require('../../core/sec-agent-constants');
10
+ try {
11
+ grpc = require("@grpc/grpc-js");
12
+ } catch (error) {
13
+
14
+ }
15
+
16
+ /**
17
+ * Utility to get client object
18
+ * @param {*} config
19
+ * @returns
20
+ */
21
+ function getGPRCClient(config) {
22
+ try {
23
+ const serviceName = grpcutils.getMethod(config.method).serviceName;
24
+
25
+ if (clientMap.has(serviceName)) {
26
+ return clientMap.get(serviceName);
27
+ }
28
+ const serviceObject = grpcutils.getService(serviceName);
29
+ const definition = grpc.loadPackageDefinition(serviceObject);
30
+ let service = getNestedValue(definition, serviceName)
31
+ if (service) {
32
+ logger.info("GRPC client service extracted successfully");
33
+ }
34
+ const client = new service(
35
+ "localhost:" + config.serverPort,
36
+ grpc.credentials.createInsecure()
37
+ );
38
+ if (!clientMap.has(serviceName)) {
39
+ clientMap.set(serviceName, client);
40
+ }
41
+ if(client){
42
+ logger.info("GRPC IAST client created successfully");
43
+ }
44
+ return client;
45
+ } catch (error) {
46
+ logger.error("error while creating client:", error);
47
+ }
48
+
49
+ }
50
+
51
+ /**
52
+ * Utility to fire unary requests
53
+ * @param {*} client
54
+ * @param {*} config
55
+ */
56
+ function fireUnaryRequest(client, config) {
57
+ try {
58
+ const methodObj = grpcutils.getMethod(config.requestURI);
59
+ if (methodObj && methodObj.originalName) {
60
+ let method = methodObj.originalName;
61
+ let metadata = new grpc.Metadata();
62
+ let bufferObj = Buffer.from(config.headers[NR_CSEC_FUZZ_REQUEST_ID], "utf8");
63
+ let base64String = bufferObj.toString("base64");
64
+ metadata.add(NR_CSEC_FUZZ_REQUEST_ID, base64String);
65
+ client[method](JSON.parse(config.data), metadata, (err, res) => {
66
+ if (err) {
67
+ logger.debug("Error occured:", err);
68
+ return
69
+ }
70
+
71
+ logger.info("Fuzz success: ", JSON.stringify(config));
72
+ return res;
73
+ })
74
+ }
75
+ else {
76
+ logger.debug("Not Found:", config.url);
77
+ }
78
+ } catch (error) {
79
+ logger.debug("Error while firing Unary request:", error);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * fire gRPC request based on provided config
85
+ * @param {*} config
86
+ * @returns
87
+ */
88
+ function fireRequest(config) {
89
+ let client = getGPRCClient(config);
90
+ fireUnaryRequest(client, config)
91
+ }
92
+
93
+
94
+ function getNestedValue(obj, targetKey) {
95
+ for (const key in obj) {
96
+ if (key === targetKey) {
97
+ return obj[key];
98
+ } else if (typeof obj[key] === 'object' && obj[key] !== null) {
99
+ const result = getNestedValue(obj[key], targetKey);
100
+ if (result !== undefined) {
101
+ return result;
102
+ }
103
+ }
104
+ }
105
+ return undefined; // Key not found
106
+ }
107
+
108
+
109
+ module.exports = {
110
+ fireRequest
111
+ };
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const axios = require('axios').default;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
  const { Agent } = require('../../../agent');
6
6
  let pendingRequestIds = new Set();
@@ -1,7 +1,7 @@
1
1
 
2
2
  /*
3
3
  * Copyright 2023 New Relic Corporation. All rights reserved.
4
- * SPDX-License-Identifier: New Relic Pre-Release
4
+ * SPDX-License-Identifier: New Relic Software License v1.0
5
5
  */
6
6
 
7
7
  let logger;
@@ -1,7 +1,7 @@
1
1
 
2
2
  /*
3
3
  * Copyright 2023 New Relic Corporation. All rights reserved.
4
- * SPDX-License-Identifier: New Relic Pre-Release
4
+ * SPDX-License-Identifier: New Relic Software License v1.0
5
5
  */
6
6
 
7
7
  let logger;
@@ -1,12 +1,13 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  /* eslint-disable no-unused-vars */
7
7
  const stringify = require('fast-safe-stringify');
8
8
 
9
9
  const restClient = require('../../restclient');
10
+ const grpcClient = require('../../grpcClient');
10
11
  const { Agent } = require('../../../agent');
11
12
  const { FuzzFailEvent } = require('../../../FuzzFailEvent');
12
13
  const { CSEC_HOME_TMP, COLON, NR_CSEC_FUZZ_REQUEST_ID, SLASH, CSEC_SEP, SEVERE } = require('../../../sec-agent-constants');
@@ -20,9 +21,6 @@ const LogMessage = require('../../../LogMessage');
20
21
  require('dns').setDefaultResultOrder('ipv4first')
21
22
  const PolicyManager = require('../../../Policy');
22
23
 
23
- const {
24
- IS_LAMBDA_ENV,
25
- AWS_LAMBDA_FUNCTION_VERSION_ENV_IDENTIFIER } = require('../../../sec-agent-constants');
26
24
  const statusUtils = require('../../../statusUtils');
27
25
 
28
26
  const find = `${SLASH}{{NR_CSEC_VALIDATOR_HOME_TMP}}`;
@@ -125,13 +123,16 @@ function handler(json) {
125
123
  function handleFuzzRequest(fuzzDetails) {
126
124
  const { fuzzRequest } = fuzzDetails;
127
125
  try {
128
- if (IS_LAMBDA_ENV) {
129
- const qualifiedARN = Agent.getAgent().applicationInfo.applicationUUID;
130
- const splitArn = String.prototype.split.call(qualifiedARN, ':');
131
- const arn = splitArn.slice(0, splitArn.length - 1).join(':');
132
- const ver = process.env[AWS_LAMBDA_FUNCTION_VERSION_ENV_IDENTIFIER];
133
- logger.info('Invoking Lambda:: ARN: ' + arn);
134
- logger.info('Invoking Lambda:: Version: ' + ver);
126
+ if (fuzzRequest.protocol == 'grpc') {
127
+ const config = parseGRPCRequestToFuzz(fuzzRequest);
128
+ config.headers['nr-csec-parent-id'] = fuzzRequest.id;
129
+ IASTUtil.completedRequestsMapInit(fuzzRequest.id);
130
+ grpcClient.fireRequest(config);
131
+ if (fuzzRequest.headers && fuzzRequest.headers[NR_CSEC_FUZZ_REQUEST_ID]) {
132
+ logScannedApiId(fuzzRequest.headers[NR_CSEC_FUZZ_REQUEST_ID], fuzzRequest.requestURI)
133
+ }
134
+
135
+ IASTUtil.removePendingRequestId(fuzzRequest.id);
135
136
 
136
137
  } else {
137
138
  const config = parseAxiosHttpRequestToFuzz(fuzzRequest);
@@ -153,7 +154,6 @@ function handleFuzzRequest(fuzzDetails) {
153
154
 
154
155
 
155
156
  logger.info('Firing http request:: URL: ' + config.url);
156
-
157
157
  const response = restClient.fireRequest(config);
158
158
  handleFuzzResponse(response, fuzzDetails);
159
159
  }
@@ -210,6 +210,26 @@ function parseAxiosHttpRequestToFuzz(requestObject) {
210
210
  };
211
211
  }
212
212
 
213
+ /**
214
+ * Parses the passed fuzz request object to
215
+ * Axios config.
216
+ *
217
+ * @param {JSON} requestObject
218
+ */
219
+ function parseGRPCRequestToFuzz(requestObject) {
220
+ let serverName = requestObject.serverName ? requestObject.serverName : LOCALHOST;
221
+ let host = serverName + COLON + requestObject.serverPort
222
+ return {
223
+ url: requestObject.protocol + COLON_SLASH_SLASH + host + requestObject.url,
224
+ requestURI: requestObject.requestURI,
225
+ protocol: requestObject.protocol,
226
+ serverPort: requestObject.serverPort,
227
+ method: requestObject.method,
228
+ data: requestObject.body,
229
+ headers: requestObject.headers,
230
+ timeout: 5000,
231
+ };
232
+ }
213
233
 
214
234
 
215
235
  /**
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let logger;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let logger;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const _ = require('lodash');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let logger;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const StartupConfig = require('../../../startup-config');
@@ -9,6 +9,7 @@ let logger = logs.getLogger();
9
9
  const initLogger = logs.getInitLogger();
10
10
  const LOG_MESSAGES = require('../../../sec-agent-constants').LOG_MESSAGES;
11
11
  const applicationInfoModule = require('../../../applicationinfo');
12
+ const LogMessage = require('../../../LogMessage');
12
13
 
13
14
  module.exports.handler = function handler(json) {
14
15
  try {
@@ -17,6 +18,8 @@ module.exports.handler = function handler(json) {
17
18
 
18
19
  initLogger.info(LOG_MESSAGES.AGENT_INIT_WITH_PROP, JSON.stringify(startupConfig.config));
19
20
  initLogger.info('Security Agent is now ACTIVE for', applicationInfoModule.getInstance().applicationUUID);
21
+ const logMessage = new LogMessage.logMessage("SEVERE", `Security Agent is ACTIVE for ${ applicationInfoModule.getInstance().applicationUUID}`, __filename, null);
22
+ require('../../../commonUtils').addLogEventtoBuffer(logMessage);
20
23
 
21
24
  } catch (error) {
22
25
  logger.error(LOG_MESSAGES.PARSING_EXP_WELCOME_MSG, error);
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const agentStatus = require('../../../agent-status');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let logger;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let eventStats = undefined;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -24,7 +24,12 @@ function BasicInfo() {
24
24
  this.jsonVersion = AGENT_VERSION;
25
25
  this.collectorType = COLLECTOR_TYPE;
26
26
  this.language = LANGUAGE;
27
- this.framework = EMPTY_STR;
27
+ try {
28
+ let framework = NRAgent.environment.get('Framework')[0];
29
+ this.framework = framework ? framework : EMPTY_STR;
30
+ } catch (error) {
31
+ this.framework = EMPTY_STR;
32
+ }
28
33
  this.groupName = commonUtils.getCSECmode();
29
34
  this.policyVersion = (!lodash.isEmpty(policyManager.getInstance().data)) ? policyManager.getInstance().data.version : 'DEFAULT';
30
35
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const fs = require('fs');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const Validator = require('jsonschema').Validator;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const { Agent } = require('./agent');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -31,11 +31,11 @@ const CSEC_ROOT = `${CSEC_HOME}${sep}nr-security-home${sep}`;
31
31
  function createLogPathIfNotExist(dir) {
32
32
  try {
33
33
  if (!fs.existsSync(dir)) {
34
- fs.mkdirSync(dir, 777, { recursive: true });
35
- fs.chmodSync(dir, 0o777);
34
+ fs.mkdirSync(dir, 770, { recursive: true });
35
+ fs.chmodSync(dir, 0o770);
36
36
  }
37
37
  else {
38
- fs.chmodSync(dir, 0o777);
38
+ fs.chmodSync(dir, 0o770);
39
39
  }
40
40
  } catch (error) {
41
41
  }
@@ -168,8 +168,8 @@ function getLogger(applicationUUID = process.env.applicationUUID) {
168
168
  logger = log4js.getLogger('NR_CSEC');
169
169
  const initLogger = getInitLogger();
170
170
  try {
171
- fs.chmodSync(`${logFileName}`, 0o777);
172
- fs.chmodSync(`${initLogFileName}`, 0o777);
171
+ fs.chmodSync(`${logFileName}`, 0o660);
172
+ fs.chmodSync(`${initLogFileName}`, 0o660);
173
173
  } catch (error) {
174
174
  }
175
175
  initLogger.info("[STEP-2] => Generating unique identifier:", applicationUUID)
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  const { workerData, parentPort } = require('worker_threads');
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  let startupConfig = undefined;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright 2023 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: New Relic Pre-Release
3
+ * SPDX-License-Identifier: New Relic Software License v1.0
4
4
  */
5
5
 
6
6
  /* eslint-disable new-cap */
@@ -93,7 +93,7 @@ function getFormattedData() {
93
93
  function writeSnapshot() {
94
94
  const snapshot = getFormattedData();
95
95
  commonUtils.removeOlderSnapshots();
96
- fs.writeFile(statusFile, snapshot, { mode: 0o777 }, function (err) {
96
+ fs.writeFile(statusFile, snapshot, { mode: 0o660 }, function (err) {
97
97
  if (err) {
98
98
  logger.debug(err.message);
99
99
  const LogMessage = require('./LogMessage');
@@ -101,7 +101,7 @@ function writeSnapshot() {
101
101
  commonUtils.addLogEventtoBuffer(logMessage);
102
102
  } else {
103
103
  logger.info('Snapshot updated to file: %s', statusFile);
104
- fs.chmod(statusFile, 0o777, (err) => {
104
+ fs.chmod(statusFile, 0o660, (err) => {
105
105
  if (err) {
106
106
  addErrortoBuffer(err);
107
107
  }