@newrelic/security-agent 0.0.4 → 0.0.5
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 +5 -0
- package/README.md +12 -1
- package/lib/nr-security-agent/index.js +6 -8
- package/lib/nr-security-agent/lib/core/Auth-headers.js +5 -6
- package/lib/nr-security-agent/lib/core/Policy.js +1 -1
- package/lib/nr-security-agent/lib/core/agent.js +0 -4
- package/lib/nr-security-agent/lib/core/applicationinfo.js +2 -6
- package/lib/nr-security-agent/lib/core/commonUtils.js +1 -1
- package/lib/nr-security-agent/lib/core/connections/websocket/response/startup-handshake-handler.js +2 -2
- package/lib/nr-security-agent/lib/core/connections/websocket/websocket.js +4 -5
- package/lib/nr-security-agent/lib/core/logging.js +1 -0
- package/lib/nr-security-agent/lib/core/sec-agent-constants.js +5 -5
- package/lib/nr-security-agent/lib/core/sec-util.js +1 -13
- package/lib/nr-security-agent/lib/core/websocket-client.js +5 -8
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
<a href="https://opensource.newrelic.com/oss-category/#community-plus"><picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/newrelic/opensource-website/raw/main/src/images/categories/dark/Community_Plus.png"><source media="(prefers-color-scheme: light)" srcset="https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Community_Plus.png"><img alt="New Relic Open Source community plus project banner." src="https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Community_Plus.png"></picture></a>
|
|
2
|
+
|
|
1
3
|
# New Relic Node.js security agent
|
|
4
|
+
[![npm status badge][1]][2] [![Security Agent CI][3]][4]
|
|
2
5
|
|
|
3
6
|
**Note**: The IAST capability should only be used in pre-production environments as the application is tested for real exploitable vulnerabilities.
|
|
4
7
|
|
|
@@ -40,6 +43,9 @@ The `@newrelic/security-agent` must be explicitly enabled in order to perform IA
|
|
|
40
43
|
|
|
41
44
|
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.
|
|
42
45
|
|
|
46
|
+
### Supported Node.js Versions
|
|
47
|
+
- Node version 14.x and above
|
|
48
|
+
|
|
43
49
|
### Supported Modules
|
|
44
50
|
|
|
45
51
|
- Node.js core modules
|
|
@@ -95,4 +101,9 @@ If you would like to contribute to this project, review [these guidelines](https
|
|
|
95
101
|
|
|
96
102
|
## License
|
|
97
103
|
The New Relic security agent is licensed under the New Relic Pre-Release Software Notice.
|
|
98
|
-
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.
|
|
104
|
+
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.
|
|
105
|
+
|
|
106
|
+
[1]: https://img.shields.io/npm/v/@newrelic/security-agent.svg
|
|
107
|
+
[2]: https://www.npmjs.com/package/@newrelic/security-agent
|
|
108
|
+
[3]: https://github.com/newrelic/csec-node-agent/workflows/CSEC%20Node%20Agent%20CI/badge.svg
|
|
109
|
+
[4]: https://github.com/newrelic/csec-node-agent/actions?query=workflow%3A%22CSEC+Node+Agent+CI%22
|
|
@@ -48,7 +48,6 @@ function extractApplicationDefForLambda(applications) {
|
|
|
48
48
|
* @param {*} applications
|
|
49
49
|
*/
|
|
50
50
|
function extractApplicationDef(execArgs, applications) {
|
|
51
|
-
initLogger.info(LOG_MESSAGES.DEP_APP_GATHERING_STARTED);
|
|
52
51
|
if (IS_LAMBDA_ENV) {
|
|
53
52
|
return extractApplicationDefForLambda(applications);
|
|
54
53
|
}
|
|
@@ -93,6 +92,7 @@ function extractApplicationDef(execArgs, applications) {
|
|
|
93
92
|
* Initialize the Agent.
|
|
94
93
|
*/
|
|
95
94
|
function initialize() {
|
|
95
|
+
initLogger.info("[STEP-1] => Security Agent is starting")
|
|
96
96
|
const policyManager = require('./lib/core/Policy');
|
|
97
97
|
policyManager.setDefaultPolicy();
|
|
98
98
|
commonUtils.initialSetup();
|
|
@@ -103,7 +103,7 @@ function initialize() {
|
|
|
103
103
|
// Initialize ApplicationInfo
|
|
104
104
|
const applicationInfo = applicationInfoModule.getInstance();
|
|
105
105
|
applicationInfoModule.setBuildDetails(AGENT_DIR, applicationInfo);
|
|
106
|
-
|
|
106
|
+
initLogger.info("[STEP-3] => Gathering information about the application :", JSON.stringify(applicationInfo));
|
|
107
107
|
if (NRAgent) {
|
|
108
108
|
NRAgent.on('started', () => {
|
|
109
109
|
if (NRAgent.config.security.enabled) {
|
|
@@ -118,7 +118,6 @@ function initialize() {
|
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
initLogger.info(LOG_MESSAGES.APP_INFO_GATHERING_STARTED);
|
|
122
121
|
|
|
123
122
|
// Fallback extract with process.argv in case application is not detected using proc cmdline
|
|
124
123
|
if ((extractApplicationDef(getProcCMDLineSanitized(applicationInfoModule), applications) || extractApplicationDef(process.argv, applications)) &&
|
|
@@ -131,10 +130,10 @@ function initialize() {
|
|
|
131
130
|
return false;
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
|
-
|
|
133
|
+
logger.info(LOG_MESSAGES.AGENT_INFO, applicationInfo.collectorVersion, applicationInfo.jsonVersion);
|
|
134
|
+
|
|
135
135
|
applicationInfoModule.addProperty('serverInfo.deployedApplications', applications);
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
|
|
138
137
|
shaSizeUtil.setLogger(logger);
|
|
139
138
|
|
|
140
139
|
// Initialize Agent Status
|
|
@@ -142,8 +141,6 @@ function initialize() {
|
|
|
142
141
|
|
|
143
142
|
// Initialize
|
|
144
143
|
Agent.init(applicationInfo, logger, wsClient, status);
|
|
145
|
-
initLogger.info(LOG_MESSAGES.AGENT_INIT_SUCCESSFUL, applicationInfo.pid, applicationInfo.applicationUUID);
|
|
146
|
-
initLogger.info(LOG_MESSAGES.AGENT_INIT_SUCCESSFUL_COMPLETE, applicationInfo.pid, applicationInfo.applicationUUID);
|
|
147
144
|
logger.info('Security Agent attached with application, with applicationUUID: %s', applicationInfo.applicationUUID);
|
|
148
145
|
} else {
|
|
149
146
|
// Do not load the agent.
|
|
@@ -164,5 +161,6 @@ function getProcCMDLineSanitized(applicationInfoModule) {
|
|
|
164
161
|
(() => {
|
|
165
162
|
if (initialize()) {
|
|
166
163
|
require('../instrumentation-security');
|
|
164
|
+
initLogger.info("[STEP-6] => Application instrumentation applied successfully");
|
|
167
165
|
}
|
|
168
166
|
})();
|
|
@@ -21,15 +21,15 @@ function AuthHeaders() {
|
|
|
21
21
|
const NRAgent = API.getNRAgent();
|
|
22
22
|
authHeaders = {}
|
|
23
23
|
authHeaders['NR-CSEC-CONNECTION-TYPE'] = 'LANGUAGE_COLLECTOR';
|
|
24
|
-
authHeaders['NR-AGENT-RUN-TOKEN'] =
|
|
25
|
-
const COLLECTOR_VERSION =
|
|
24
|
+
authHeaders['NR-AGENT-RUN-TOKEN'] = NRAgent.config.run_id;
|
|
25
|
+
const COLLECTOR_VERSION = appInfo.collectorVersion || '';
|
|
26
26
|
authHeaders['NR-CSEC-VERSION'] = COLLECTOR_VERSION.trim();
|
|
27
27
|
authHeaders['NR-CSEC-COLLECTOR-TYPE'] = 'NODE';
|
|
28
28
|
authHeaders['NR-CSEC-MODE'] = commonUtils.getCSECmode();
|
|
29
29
|
authHeaders['NR-CSEC-APP-UUID'] = commonUtils.getUUID();
|
|
30
|
-
authHeaders['NR-CSEC-JSON-VERSION'] =
|
|
31
|
-
authHeaders['NR-CSEC-BUILD-NUMBER'] =
|
|
32
|
-
authHeaders['NR-ACCOUNT-ID'] =
|
|
30
|
+
authHeaders['NR-CSEC-JSON-VERSION'] = appInfo.jsonVersion;
|
|
31
|
+
authHeaders['NR-CSEC-BUILD-NUMBER'] = appInfo.buildNumber;
|
|
32
|
+
authHeaders['NR-ACCOUNT-ID'] = NRAgent.config.account_id;
|
|
33
33
|
authHeaders['NR-LICENSE-KEY'] = NRAgent ? NRAgent.config.license_key : '';
|
|
34
34
|
} catch (error) {
|
|
35
35
|
logger.error("Exception in preparing auth headers:", error);
|
|
@@ -48,7 +48,6 @@ AuthHeaders.prototype.constructor = AuthHeaders;
|
|
|
48
48
|
function getInstance() {
|
|
49
49
|
if (!authHeaders) {
|
|
50
50
|
authHeaders = new AuthHeaders();
|
|
51
|
-
initLogger.info("[STEP-2][BEGIN][Auth-Headers]: Authentication Headers Created Successfully");
|
|
52
51
|
}
|
|
53
52
|
return authHeaders;
|
|
54
53
|
}
|
|
@@ -50,7 +50,7 @@ function setPolicyData(data) {
|
|
|
50
50
|
if (policy.data.version !== data.version) {
|
|
51
51
|
policy.data = data;
|
|
52
52
|
appInfoVersionUpdate(policy, data);
|
|
53
|
-
initLogger.info(
|
|
53
|
+
initLogger.info("[STEP-7] => Received and applied policy/configuration", JSON.stringify(policy.data));
|
|
54
54
|
logger.info('Applied policy is:', JSON.stringify(policy.data));
|
|
55
55
|
if (NRAgent && NRAgent.config.security.detection) {
|
|
56
56
|
logger.info('Security detection flags:', JSON.stringify(NRAgent.config.security.detection));
|
|
@@ -61,8 +61,6 @@ Agent.prototype.setApplicationInfo = function setApplicationInfo(applicationInfo
|
|
|
61
61
|
|
|
62
62
|
Agent.eventEmitter.emit(EVENTS.APPLICATION_INFO_UPDATE_EVENT, applicationInfoObject);
|
|
63
63
|
const logs = require('./logging');
|
|
64
|
-
const initLogger = logs.getInitLogger();
|
|
65
|
-
initLogger.info(LOG_MESSAGES.INIT_APPINFO_SEND, JSON.stringify(applicationInfoObject));
|
|
66
64
|
|
|
67
65
|
}
|
|
68
66
|
|
|
@@ -129,8 +127,6 @@ Agent.getAgent = function getAgent() {
|
|
|
129
127
|
Agent.setNRAgent = function setNRAgent(agent) {
|
|
130
128
|
if (agent) {
|
|
131
129
|
NRAgent = agent;
|
|
132
|
-
process.env.account_id = NRAgent.config.account_id;
|
|
133
|
-
process.env.agent_run_id = NRAgent.config.run_id;
|
|
134
130
|
}
|
|
135
131
|
const CSECAgent = Agent.getAgent();
|
|
136
132
|
if (CSECAgent) {
|
|
@@ -214,7 +214,6 @@ ApplicationInfo.prototype.updateSHAAndSize = async function updateSHAAndSize (Gl
|
|
|
214
214
|
// emit finalization of application info
|
|
215
215
|
if (Agent.getAgent()) {
|
|
216
216
|
Agent.getAgent().setApplicationInfo(applicationInfo);
|
|
217
|
-
initLogger.info(LOG_MESSAGES.APP_INFO_GENERATED, JSON.stringify(applicationInfo));
|
|
218
217
|
}
|
|
219
218
|
};
|
|
220
219
|
|
|
@@ -426,12 +425,9 @@ function getProcStartTime () {
|
|
|
426
425
|
function setBuildDetails (agentDir, applicationInfo) {
|
|
427
426
|
const jsonFileHandler = new JsonHandler(PACKAGE_JSON_FILE, agentDir);
|
|
428
427
|
const pkg = jsonFileHandler.getJSON();
|
|
429
|
-
|
|
430
|
-
applicationInfo.collectorVersion = pkg.collectorVersion;
|
|
428
|
+
applicationInfo.collectorVersion = pkg.version;
|
|
431
429
|
applicationInfo.jsonVersion = pkg.jsonVersion;
|
|
432
|
-
applicationInfo.buildNumber = pkg.
|
|
433
|
-
process.env.buildNumber = pkg.buildNumber;
|
|
434
|
-
process.env.jsonVersion = applicationInfo.jsonVersion;
|
|
430
|
+
applicationInfo.buildNumber = pkg.version;
|
|
435
431
|
}
|
|
436
432
|
|
|
437
433
|
function isK8S () {
|
|
@@ -384,7 +384,7 @@ function getCSECmode(){
|
|
|
384
384
|
* @returns
|
|
385
385
|
*/
|
|
386
386
|
function getPathOfCACert(){
|
|
387
|
-
const certPath =
|
|
387
|
+
const certPath = process.env.NEW_RELIC_SECURITY_CA_BUNDLE_PATH ? process.env.NEW_RELIC_SECURITY_CA_BUNDLE_PATH : path.resolve(__dirname, '../../resources/cert.pem');
|
|
388
388
|
return certPath
|
|
389
389
|
}
|
|
390
390
|
|
package/lib/nr-security-agent/lib/core/connections/websocket/response/startup-handshake-handler.js
CHANGED
|
@@ -15,8 +15,8 @@ module.exports.handler = function handler(json) {
|
|
|
15
15
|
const startupConfig = StartupConfig.getInstance();
|
|
16
16
|
startupConfig.config = json.data;
|
|
17
17
|
|
|
18
|
-
initLogger.info(LOG_MESSAGES.
|
|
19
|
-
initLogger.info('
|
|
18
|
+
initLogger.info(LOG_MESSAGES.AGENT_INIT_WITH_PROP, JSON.stringify(startupConfig.config));
|
|
19
|
+
initLogger.info('Security Agent is now ACTIVE for', applicationInfoModule.getInstance().applicationUUID);
|
|
20
20
|
|
|
21
21
|
} catch (error) {
|
|
22
22
|
logger.error(LOG_MESSAGES.PARSING_EXP_WELCOME_MSG, error);
|
|
@@ -98,7 +98,7 @@ SecWebSocket.prototype.init = function init() {
|
|
|
98
98
|
this.setValidatorNotReadyForEvents();
|
|
99
99
|
const validatorService = commonUtils.getValidatorServiceEndpointURL();
|
|
100
100
|
const authHeaders = require('../../Auth-headers').getInstance();
|
|
101
|
-
initLogger.info(`
|
|
101
|
+
initLogger.info(`Connecting to Validator at ${validatorService}`);
|
|
102
102
|
let cert = ''
|
|
103
103
|
try {
|
|
104
104
|
const certPath = commonUtils.getPathOfCACert();
|
|
@@ -311,15 +311,14 @@ const defaultOnOpenCB = () => async function onOpen() {
|
|
|
311
311
|
pingIntervalConst = setInterval(() => {
|
|
312
312
|
self.pingWS();
|
|
313
313
|
}, 30000)
|
|
314
|
-
|
|
314
|
+
const validatorService = commonUtils.getValidatorServiceEndpointURL();
|
|
315
|
+
initLogger.info(`[STEP-4] => Web socket connection to SaaS validator established successfully at ${validatorService}`)
|
|
315
316
|
try {
|
|
316
|
-
initLogger.info(LOG_MESSAGES.WS_CONNECTED);
|
|
317
317
|
|
|
318
318
|
this.wsRetryCount = 0;
|
|
319
319
|
process.env.WS_HEALTH = 'OK';
|
|
320
320
|
|
|
321
321
|
const applicationInfo = APP_INFO || Agent.getAgent().applicationInfo;
|
|
322
|
-
initLogger.info(LOG_MESSAGES.SENDING_APPINFO, JSON.stringify(applicationInfo));
|
|
323
322
|
await self.dispatchApplicationInfo(applicationInfo);
|
|
324
323
|
|
|
325
324
|
// by now we expect IC to be ready
|
|
@@ -329,7 +328,7 @@ const defaultOnOpenCB = () => async function onOpen() {
|
|
|
329
328
|
await self.flushEventQueue();
|
|
330
329
|
ResponseHandler.FuzzRequestHandler.setLastFuzzEnventTime();
|
|
331
330
|
releaseWebSocket();
|
|
332
|
-
initLogger.info(LOG_MESSAGES.SENDING_APPINFO_COMPLETE, JSON.stringify(applicationInfo));
|
|
331
|
+
initLogger.info(LOG_MESSAGES.SENDING_APPINFO_COMPLETE, JSON.stringify(applicationInfo));
|
|
333
332
|
} catch (err) {
|
|
334
333
|
logger.error(`Connection broken: ${err.message}`);
|
|
335
334
|
statusUtils.addErrortoBuffer(err);
|
|
@@ -143,6 +143,7 @@ function getLogger (applicationUUID = process.env.applicationUUID) {
|
|
|
143
143
|
initialize(applicationUUID);
|
|
144
144
|
logger = log4js.getLogger('NR_CSEC');
|
|
145
145
|
const initLogger = getInitLogger();
|
|
146
|
+
initLogger.info("[STEP-2] => Generating unique identifier:",applicationUUID )
|
|
146
147
|
if (NRAgent) {
|
|
147
148
|
setLevel(NRAgent.config.logging.level);
|
|
148
149
|
}
|
|
@@ -106,7 +106,7 @@ module.exports = {
|
|
|
106
106
|
|
|
107
107
|
LOG_MESSAGES: {
|
|
108
108
|
LOADED_CSEC_ENVS_MSG: '[STEP-1][COMPLETE][env] Environment Information Gathering Done.',
|
|
109
|
-
|
|
109
|
+
AGENT_INFO: 'Security Agent version : %s, json version : %s',
|
|
110
110
|
APP_INFO_GATHERING_STARTED: '[STEP-1][BEGIN][APP_INFO] Gathering Application Info For Current Process.',
|
|
111
111
|
DEP_APP_GATHERING_STARTED: '[BEGIN][APP_INFO][DEPLOYED_APP] Gathering deployed application info for current process',
|
|
112
112
|
APP_INFO_DEP_APP: '[APP_INFO][DEPLOYED_APP] Deployed application info generated :%s',
|
|
@@ -140,24 +140,24 @@ module.exports = {
|
|
|
140
140
|
UPDATE_POL_SENT_SERVER: 'Updated Policy Sent To Prevent Web',
|
|
141
141
|
EXP_RAISE_POL: 'Exception Raised In Policy Validation:',
|
|
142
142
|
FALLBACK_TO_CURR_POLICY: 'Fallback To Current Policy!!!:%s',
|
|
143
|
-
POLICY_APPLIED: '
|
|
143
|
+
POLICY_APPLIED: 'Received and applied policy/configuration :',
|
|
144
144
|
POL_PULL_INT_IS: 'Policy Pull Interval Is:',
|
|
145
145
|
LOG_LEVEL_UPDATED: 'Log Level Updated To:',
|
|
146
146
|
DEFAULT_POL_SET: 'Default Policy Has Been Set :',
|
|
147
147
|
UNABLE_SET_DEFAULT_POL: 'Unable To Set Default Policy',
|
|
148
|
-
|
|
148
|
+
AGENT_INIT_WITH_PROP: 'Security Agent is initialized with properties:',
|
|
149
149
|
PARSING_EXP_WELCOME_MSG: 'Parsing Exeception In Startup Welcome Command',
|
|
150
150
|
ACCESS_BLOCKED_IP_DETECTED: 'Access By Blocked Ip Address Detected : ',
|
|
151
151
|
FIRST_EVENT_INTERCEPTED: '[BEGIN][EVENT] First event intercepted',
|
|
152
152
|
FIRST_EVENT_PROCESSED: '[EVENT] First event processed :',
|
|
153
|
-
FIRST_EVENT_SENT: '[STEP-8]
|
|
153
|
+
FIRST_EVENT_SENT: '[STEP-8] => First event sent for validation. Security agent started successfully.',
|
|
154
154
|
DETECTED_BROKEN_CONN: 'Detected Broken Connection. Will Reconnect Now!',
|
|
155
155
|
MAX_WS_RETRY: 'Maximum WS Retry Limit Reached. Unable To Connect To Prevent Web Service!!!',
|
|
156
156
|
EVENT_SENT: 'Event Sent:: ',
|
|
157
157
|
ERROR_WHILE_SEND_EVENT: 'ERROR While Sending Event: {}',
|
|
158
158
|
WS_CONNECTED: '[STEP-4][COMPLETE][WS] Connected To Prevent-web Service',
|
|
159
159
|
SENDING_APPINFO: '[APP_INFO] Sending Application Info To Prevent-web Service: ',
|
|
160
|
-
SENDING_APPINFO_COMPLETE: '[COMPLETE][APP_INFO] Application info sent to Prevent-Web service :
|
|
160
|
+
SENDING_APPINFO_COMPLETE: '[COMPLETE][APP_INFO] Application info sent to Prevent-Web service :',
|
|
161
161
|
APPLY_INSTRUMENTATION: '[STEP-6][BEGIN][instrumentation] Applying Instrumentation',
|
|
162
162
|
AVAIL_DISK: 'Available Disk Space Is: ',
|
|
163
163
|
AVAIL_DISK_ERROR: 'Insufficient Disk Space Available To The Location %s Is : %s',
|
|
@@ -15,7 +15,6 @@ const NRAgent = API.getNRAgent();
|
|
|
15
15
|
|
|
16
16
|
const statusUtils = require('./statusUtils');
|
|
17
17
|
|
|
18
|
-
let firstEvent = false;
|
|
19
18
|
let firstEventSent = false;
|
|
20
19
|
|
|
21
20
|
const events = require('events');
|
|
@@ -89,20 +88,9 @@ function generateSecEvent(securityMetadata) {
|
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
const isClientDetectedFromXFF = false;
|
|
92
|
-
|
|
93
|
-
if (!firstEvent) {
|
|
94
|
-
initLogger.info(LOG_MESSAGES.FIRST_EVENT_INTERCEPTED, securityMetadata.eventCategory, JSON.stringify(request));
|
|
95
|
-
}
|
|
96
91
|
const isAPIBlocked = false;
|
|
97
|
-
|
|
98
92
|
const event = new SecEvent(traceObject.sourceDetails.fileName, traceObject.sourceDetails.funcName, traceObject.sourceDetails.lineNumber, securityMetadata.interceptedArgs, securityMetadata.executionId, agentModule.applicationInfo, securityMetadata.request, securityMetadata.eventType, traceObject.sourceDetails.source, securityMetadata.eventCategory, metaData, stakTrace, apiId, isAPIBlocked);
|
|
99
93
|
event.metaData.isClientDetectedFromXFF = isClientDetectedFromXFF;
|
|
100
|
-
|
|
101
|
-
if (!firstEvent) {
|
|
102
|
-
initLogger.info(LOG_MESSAGES.FIRST_EVENT_PROCESSED, JSON.stringify(event));
|
|
103
|
-
firstEvent = true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
94
|
return event;
|
|
107
95
|
} catch (e) {
|
|
108
96
|
statusUtils.addErrortoBuffer(e);
|
|
@@ -148,7 +136,7 @@ function sendEvent(secEvent) {
|
|
|
148
136
|
if (agentModule.status.getStatus() === 'active' && NRAgent.config.security.enabled) {
|
|
149
137
|
agentModule.client.dispatcher(secEvent);
|
|
150
138
|
if (!firstEventSent) {
|
|
151
|
-
initLogger.info(
|
|
139
|
+
initLogger.info("[STEP-8] => First event sent for validation. Security Agent started successfully", JSON.stringify(secEvent));
|
|
152
140
|
firstEventSent = true;
|
|
153
141
|
}
|
|
154
142
|
}
|
|
@@ -85,17 +85,14 @@ const initialize = function () {
|
|
|
85
85
|
wsInstance.reconnect();
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
// Initiate HC send routine in the provided hcInterval.
|
|
89
|
-
initLogger.info(LOG_MESSAGES.SCHED_SERVICE_START);
|
|
90
|
-
initLogger.info(LOG_MESSAGES.START_HC);
|
|
91
88
|
|
|
92
89
|
setTimeout(() => {
|
|
93
90
|
setInterval(sendHC, HC_INTERVAL_MS);
|
|
94
|
-
initLogger.info(LOG_MESSAGES.END_HC);
|
|
95
91
|
sendHC();
|
|
96
92
|
}, 30000);
|
|
97
93
|
|
|
98
94
|
setInterval(commonUtils.logRollOver, 30000);
|
|
95
|
+
initLogger.info("[STEP-5] => Security Agent schedular started");
|
|
99
96
|
};
|
|
100
97
|
|
|
101
98
|
/**
|
|
@@ -247,13 +244,13 @@ const sendHC = async function () {
|
|
|
247
244
|
*/
|
|
248
245
|
function getDispatcherAndSendEvent(eventJson) {
|
|
249
246
|
const eventType = eventJson.jsonName;
|
|
250
|
-
if(eventType==='Event'){
|
|
247
|
+
if (eventType === 'Event') {
|
|
251
248
|
hc.getInstance().registerEventProcessed();
|
|
252
249
|
}
|
|
253
|
-
|
|
250
|
+
|
|
254
251
|
dispatcher(eventJson);
|
|
255
252
|
|
|
256
|
-
if(eventType==='Event'){
|
|
253
|
+
if (eventType === 'Event') {
|
|
257
254
|
hc.getInstance().registerEventSent();
|
|
258
255
|
}
|
|
259
256
|
|
|
@@ -316,7 +313,7 @@ function busyWaitOnWorkerThread(startTime = Date.now()) {
|
|
|
316
313
|
}
|
|
317
314
|
}
|
|
318
315
|
|
|
319
|
-
function obeyReconnect(){
|
|
316
|
+
function obeyReconnect() {
|
|
320
317
|
if (workerSupported) {
|
|
321
318
|
const reConnectMsg = new WorkerMessage(WorkerMessage.TYPE.OBEY_RECONNECT, {});
|
|
322
319
|
wsWorker.postMessage(reConnectMsg);
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/security-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Newrelic Security Agent for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"collectorVersion": "1.0.1-limited-preview",
|
|
7
|
-
"buildNumber": 103,
|
|
8
7
|
"jsonVersion": "1.0.1",
|
|
9
8
|
"contributors": [
|
|
10
9
|
{
|