@newrelic/security-agent 0.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 +0 -0
- package/CONTRIBUTING.md +23 -0
- package/LICENSE +43 -0
- package/README.md +98 -0
- package/THIRD_PARTY_NOTICES.md +2909 -0
- package/index.js +24 -0
- package/lib/instrumentation-security/core/constants.js +66 -0
- package/lib/instrumentation-security/core/event-constants.js +49 -0
- package/lib/instrumentation-security/core/request-manager.js +73 -0
- package/lib/instrumentation-security/core/route-manager.js +30 -0
- package/lib/instrumentation-security/core/sec-trace.js +134 -0
- package/lib/instrumentation-security/core/sec-utils.js +212 -0
- package/lib/instrumentation-security/core/security-metadata.js +34 -0
- package/lib/instrumentation-security/core/stack-trace.js +156 -0
- package/lib/instrumentation-security/hooks/director/nr-director.js +98 -0
- package/lib/instrumentation-security/hooks/express/nr-express.js +106 -0
- package/lib/instrumentation-security/hooks/fastify/nr-fastify.js +155 -0
- package/lib/instrumentation-security/hooks/fs/nr-fs.js +391 -0
- package/lib/instrumentation-security/hooks/hapi/nr-hapi.js +131 -0
- package/lib/instrumentation-security/hooks/http/nr-http.js +461 -0
- package/lib/instrumentation-security/hooks/koa/@koa/nr-@koa-router.js +110 -0
- package/lib/instrumentation-security/hooks/ldap/nr-ldap.js +81 -0
- package/lib/instrumentation-security/hooks/mongodb/common.js +239 -0
- package/lib/instrumentation-security/hooks/mongodb/constants.js +91 -0
- package/lib/instrumentation-security/hooks/mongodb/nr-mongodb.js +49 -0
- package/lib/instrumentation-security/hooks/mongodb/v2-mongo.js +91 -0
- package/lib/instrumentation-security/hooks/mongodb/v3-mongo.js +36 -0
- package/lib/instrumentation-security/hooks/mongodb/v4-mongo.js +17 -0
- package/lib/instrumentation-security/hooks/mysql/nr-mysql.js +232 -0
- package/lib/instrumentation-security/hooks/native/nr-childProcess.js +131 -0
- package/lib/instrumentation-security/hooks/postgres/nr-postgres.js +131 -0
- package/lib/instrumentation-security/hooks/require/nr-require.js +93 -0
- package/lib/instrumentation-security/hooks/restify/nr-restify.js +104 -0
- package/lib/instrumentation-security/hooks/xpath/nr-xpath.js +91 -0
- package/lib/instrumentation-security/index.js +171 -0
- package/lib/nr-security-agent/index.js +170 -0
- package/lib/nr-security-agent/lib/core/Auth-headers.js +58 -0
- package/lib/nr-security-agent/lib/core/ContainerProperties.js +42 -0
- package/lib/nr-security-agent/lib/core/ECSProperties.js +34 -0
- package/lib/nr-security-agent/lib/core/FuzzFailEvent.js +27 -0
- package/lib/nr-security-agent/lib/core/LinkingMetadata.js +21 -0
- package/lib/nr-security-agent/lib/core/LogMessage.js +47 -0
- package/lib/nr-security-agent/lib/core/PodProperties.js +36 -0
- package/lib/nr-security-agent/lib/core/Policy.js +105 -0
- package/lib/nr-security-agent/lib/core/agent-status.js +56 -0
- package/lib/nr-security-agent/lib/core/agent.js +146 -0
- package/lib/nr-security-agent/lib/core/applicationinfo.js +634 -0
- package/lib/nr-security-agent/lib/core/commonUtils.js +411 -0
- package/lib/nr-security-agent/lib/core/connections/aws-lambda-client.js +55 -0
- package/lib/nr-security-agent/lib/core/connections/restclient.js +20 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/index.js +25 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/collecotor-policy-error-handler.js +18 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/collector-policy-handler.js +20 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/fuzz-request-handler.js +171 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/index.js +47 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/no-op-handler.js +12 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/startup-handshake-handler.js +27 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/unsupported-agent-handler.js +18 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/response/ws-reconnect.js +14 -0
- package/lib/nr-security-agent/lib/core/connections/websocket/websocket.js +443 -0
- package/lib/nr-security-agent/lib/core/event.js +186 -0
- package/lib/nr-security-agent/lib/core/health-check.js +159 -0
- package/lib/nr-security-agent/lib/core/json-file-handler.js +66 -0
- package/lib/nr-security-agent/lib/core/jsonValidator.js +149 -0
- package/lib/nr-security-agent/lib/core/lambda-delegated-task-service.js +90 -0
- package/lib/nr-security-agent/lib/core/logging.js +176 -0
- package/lib/nr-security-agent/lib/core/sec-agent-constants.js +173 -0
- package/lib/nr-security-agent/lib/core/sec-util.js +166 -0
- package/lib/nr-security-agent/lib/core/sha-size-util.js +338 -0
- package/lib/nr-security-agent/lib/core/sha_worker.js +24 -0
- package/lib/nr-security-agent/lib/core/startup-config.js +29 -0
- package/lib/nr-security-agent/lib/core/statusUtils.js +157 -0
- package/lib/nr-security-agent/lib/core/timeunit.js +44 -0
- package/lib/nr-security-agent/lib/core/websocket-client.js +335 -0
- package/lib/nr-security-agent/lib/core/worker-entities.js +82 -0
- package/lib/nr-security-agent/lib/core/worker.js +148 -0
- package/lib/nr-security-agent/lib/core/xss-utils.js +297 -0
- package/lib/nr-security-agent/lib/models/lambda-delegated-task/constants.js +12 -0
- package/lib/nr-security-agent/lib/models/lambda-delegated-task/index.js +15 -0
- package/lib/nr-security-agent/lib/models/lambda-delegated-task/lambda-delegated-sha-calculation.js +37 -0
- package/lib/nr-security-agent/lib/models/lambda-delegated-task/lambda-delegated-task-base.js +50 -0
- package/lib/nr-security-agent/lib/models/lambda-delegated-task/lambda-delegated-task-type.js +17 -0
- package/lib/nr-security-agent/resources/cert.pem +31 -0
- package/lib/nr-security-agent/resources/config.js +19 -0
- package/lib/nr-security-agent/resources/default-policy.yaml +36 -0
- package/lib/nr-security-api/index.js +111 -0
- package/package.json +95 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
let newrelic;
|
|
7
|
+
let NRAgent;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @returns NewRelic Agent instance
|
|
12
|
+
*/
|
|
13
|
+
function getNRAgent(){
|
|
14
|
+
return NRAgent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* API to set newrelic agent object.
|
|
19
|
+
* @param {*} agent
|
|
20
|
+
*/
|
|
21
|
+
function setNRAgent(agent){
|
|
22
|
+
NRAgent = agent;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* API to get security agent
|
|
27
|
+
* @returns Security Agent instanace
|
|
28
|
+
*/
|
|
29
|
+
function getSecAgent(){
|
|
30
|
+
const Agent = require('../nr-security-agent/lib/core/agent').Agent;
|
|
31
|
+
const csecAgent = Agent.getAgent();
|
|
32
|
+
if(csecAgent){
|
|
33
|
+
return csecAgent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* API to get status of security agent
|
|
39
|
+
* @returns Security Agent status
|
|
40
|
+
*/
|
|
41
|
+
function getSecAgentStatus(){
|
|
42
|
+
const Agent = require('../nr-security-agent/lib/core/agent').Agent;
|
|
43
|
+
if(Agent.getAgent()){
|
|
44
|
+
return Agent.getAgent().status.getStatus()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* API to generate security event from the intermediate data
|
|
50
|
+
* @param {*} securityMetadata
|
|
51
|
+
* @returns security event object
|
|
52
|
+
*/
|
|
53
|
+
function generateSecEvent(securityMetadata){
|
|
54
|
+
return require('../nr-security-agent/lib/core/sec-util').generateSecEvent(securityMetadata);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* API to send security event
|
|
59
|
+
* @param {*} secEvent
|
|
60
|
+
*/
|
|
61
|
+
function sendEvent(secEvent){
|
|
62
|
+
require('../nr-security-agent/lib/core/sec-util').sendEvent(secEvent);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* API to get logger instance
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function getLogger(){
|
|
70
|
+
return require('../nr-security-agent/lib/core/logging').getLogger();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* API to validate RXSS
|
|
74
|
+
* @param {*} secRequest
|
|
75
|
+
* @param {*} responseBody
|
|
76
|
+
* @param {*} responseHeaders
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
function checkForReflectedXSS(secRequest, responseBody, responseHeaders){
|
|
80
|
+
return require('../nr-security-agent/lib/core/xss-utils').checkForReflectedXSS(secRequest, responseBody, responseHeaders);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* API to get security agent policy
|
|
85
|
+
* @returns security agent policy
|
|
86
|
+
*/
|
|
87
|
+
function getPolicy(){
|
|
88
|
+
return require('../nr-security-agent/lib/core/Policy').getInstance();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* API to generate Exit event
|
|
93
|
+
* @param {*} event
|
|
94
|
+
*/
|
|
95
|
+
function generateExitEvent(event){
|
|
96
|
+
require('../nr-security-agent/lib/core/sec-util').generateExitEvent(event);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
newrelic,
|
|
101
|
+
getNRAgent,
|
|
102
|
+
getSecAgent,
|
|
103
|
+
getSecAgentStatus,
|
|
104
|
+
generateSecEvent,
|
|
105
|
+
sendEvent,
|
|
106
|
+
getLogger,
|
|
107
|
+
checkForReflectedXSS,
|
|
108
|
+
getPolicy,
|
|
109
|
+
generateExitEvent,
|
|
110
|
+
setNRAgent
|
|
111
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@newrelic/security-agent",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Newrelic Security Agent for Node.js",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"collectorVersion": "1.0.1-limited-preview",
|
|
7
|
+
"buildNumber": 103,
|
|
8
|
+
"jsonVersion": "1.0.1",
|
|
9
|
+
"contributors": [
|
|
10
|
+
{
|
|
11
|
+
"name": "Sumit Suthar",
|
|
12
|
+
"email": "ssuthar@newrelic.com",
|
|
13
|
+
"web": "http://newrelic.com"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "Pratik Gunjetiya",
|
|
17
|
+
"email": "pgunjetiya@newrelic.com",
|
|
18
|
+
"web": "http://newrelic.com"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "tap --test-regex='(\\/|^test\\/instrumentation-security\\/.*\\.test\\.js)$' --no-coverage",
|
|
23
|
+
"posttest": "rm -f newrelic_agent.log && rm -rf nr-security-home && rm -rf .nyc_output",
|
|
24
|
+
"third-party-updates": "oss third-party manifest && oss third-party notices && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [],
|
|
27
|
+
"author": "newrelic",
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/newrelic/csec-node-agent.git"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@aws-sdk/client-lambda": "3.276.0",
|
|
35
|
+
"axios": "0.21.4",
|
|
36
|
+
"check-disk-space": "^3.1.0",
|
|
37
|
+
"content-type": "^1.0.4",
|
|
38
|
+
"fast-safe-stringify": "^2.0.7",
|
|
39
|
+
"find-package-json": "^1.2.0",
|
|
40
|
+
"hash.js": "^1.1.7",
|
|
41
|
+
"html-entities": "^1.2.1",
|
|
42
|
+
"is-invalid-path": "^1.0.2",
|
|
43
|
+
"js-yaml": "^4.1.0",
|
|
44
|
+
"jsonschema": "^1.4.0",
|
|
45
|
+
"lodash": "^4.17.21",
|
|
46
|
+
"log4js": "^6.0.0",
|
|
47
|
+
"pretty-bytes": "^5.6.0",
|
|
48
|
+
"request-ip": "^2.1.3",
|
|
49
|
+
"ringbufferjs": "^2.0.0",
|
|
50
|
+
"semver": "^6.3.0",
|
|
51
|
+
"sync-request": "^6.1.0",
|
|
52
|
+
"unescape": "^1.0.1",
|
|
53
|
+
"unescape-js": "^1.1.4",
|
|
54
|
+
"uuid": "^3.4.0",
|
|
55
|
+
"ws": "^7.5.9"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@hapi/hapi": "^21.3.0",
|
|
59
|
+
"@koa/router": "^12.0.0",
|
|
60
|
+
"@newrelic/newrelic-oss-cli": "^0.1.2",
|
|
61
|
+
"@newrelic/test-utilities": "7.2.1",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^4.15.0",
|
|
63
|
+
"@typescript-eslint/parser": "^4.15.0",
|
|
64
|
+
"director": "^1.2.8",
|
|
65
|
+
"eslint-config-prettier": "^8.3.0",
|
|
66
|
+
"eslint-config-standard": "^16.0.3",
|
|
67
|
+
"eslint-plugin-disable": "^2.0.1",
|
|
68
|
+
"eslint-plugin-header": "^3.1.1",
|
|
69
|
+
"eslint-plugin-import": "^2.23.4",
|
|
70
|
+
"eslint-plugin-jsdoc": "^39.3.6",
|
|
71
|
+
"eslint-plugin-node": "^11.1.0",
|
|
72
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
73
|
+
"eslint-plugin-promise": "^4.3.1",
|
|
74
|
+
"eslint-plugin-sonarjs": "^0.15.0",
|
|
75
|
+
"koa": "^2.14.1",
|
|
76
|
+
"mongodb": "^4.13.0",
|
|
77
|
+
"mongodb-memory-server": "^8.11.2",
|
|
78
|
+
"mongodb2": "npm:mongodb@^2.2.36",
|
|
79
|
+
"mongodb3": "npm:mongodb@^3.7.3",
|
|
80
|
+
"newrelic": "^9.15.0",
|
|
81
|
+
"request": "^2.88.2",
|
|
82
|
+
"restify": "^11.1.0",
|
|
83
|
+
"sinon": "^15.0.0",
|
|
84
|
+
"tap": "^16.3.2",
|
|
85
|
+
"xmldom": "^0.6.0",
|
|
86
|
+
"xpath": "^0.0.32",
|
|
87
|
+
"xpath.js": "^1.1.0"
|
|
88
|
+
},
|
|
89
|
+
"files": [
|
|
90
|
+
"index.js",
|
|
91
|
+
"*.md",
|
|
92
|
+
"LICENSE",
|
|
93
|
+
"lib/"
|
|
94
|
+
]
|
|
95
|
+
}
|