@contrast/telemetry 1.16.1 → 1.18.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/lib/index.js +33 -3
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
13
|
* way not consistent with the End User License Agreement.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
// @ts-check
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { createHash, randomUUID } = require('crypto');
|
|
@@ -33,6 +33,7 @@ const TELEMETRY_VERSION = 'v0'; // TODO: set this to v1 when format is establish
|
|
|
33
33
|
* @param {{
|
|
34
34
|
* agentName: string,
|
|
35
35
|
* agentVersion: string,
|
|
36
|
+
* appInfo: import('@contrast/common').AppInfo,
|
|
36
37
|
* config: import('@contrast/config').Config,
|
|
37
38
|
* logger: import('@contrast/logger').Logger,
|
|
38
39
|
* messages: import('@contrast/common').Messages,
|
|
@@ -52,6 +53,7 @@ module.exports = function(core) {
|
|
|
52
53
|
const { instanceId, applicationId } = getIds(appInfo);
|
|
53
54
|
|
|
54
55
|
const telemetry = core.telemetry = {
|
|
56
|
+
/** @type {axios.AxiosInstance} */
|
|
55
57
|
client: null,
|
|
56
58
|
instanceId,
|
|
57
59
|
tags: {
|
|
@@ -60,13 +62,13 @@ module.exports = function(core) {
|
|
|
60
62
|
osArch: appInfo.os.architecture,
|
|
61
63
|
osPlatform: appInfo.os.platform,
|
|
62
64
|
osRelease: appInfo.os.release,
|
|
63
|
-
isContainer: !!appInfo.containerId,
|
|
65
|
+
isContainer: !!appInfo.containerId, // TODO: this is undefined
|
|
64
66
|
agent: agentName,
|
|
65
67
|
agentVersion,
|
|
66
68
|
isAssess: config.getEffectiveValue('assess.enable'),
|
|
67
69
|
isProtect: config.getEffectiveValue('protect.enable'),
|
|
68
70
|
nodeVersion: appInfo.nodeVersion,
|
|
69
|
-
telemetryVersion: TELEMETRY_VERSION
|
|
71
|
+
telemetryVersion: TELEMETRY_VERSION,
|
|
70
72
|
},
|
|
71
73
|
isEnabled() {
|
|
72
74
|
return (
|
|
@@ -122,6 +124,34 @@ module.exports = function(core) {
|
|
|
122
124
|
telemetry.tags.isProtect = config.getEffectiveValue('protect.enable');
|
|
123
125
|
});
|
|
124
126
|
|
|
127
|
+
let unsupportedLibs = [];
|
|
128
|
+
messages.on(Event.UNSUPPORTED_LIBRARY, (metadata) => {
|
|
129
|
+
unsupportedLibs.push({
|
|
130
|
+
timestamp: new Date().toISOString(),
|
|
131
|
+
instance: telemetry.instanceId,
|
|
132
|
+
tags: {
|
|
133
|
+
...telemetry.tags,
|
|
134
|
+
name: metadata.name,
|
|
135
|
+
version: metadata.version,
|
|
136
|
+
},
|
|
137
|
+
fields: {
|
|
138
|
+
supported: 0
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
setInterval(async () => {
|
|
144
|
+
if (unsupportedLibs.length < 1) return;
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await telemetry.client.post('/dependencies', unsupportedLibs);
|
|
148
|
+
} catch (err) {
|
|
149
|
+
logger.error({ err }, 'error occurred while reporting telemetry: /dependencies');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
unsupportedLibs = [];
|
|
153
|
+
}, 20_000).unref();
|
|
154
|
+
|
|
125
155
|
return core.telemetry;
|
|
126
156
|
};
|
|
127
157
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/telemetry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Telemetry reporting for the Contrast Node.js agent.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"test": "../scripts/test.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@contrast/common": "1.
|
|
17
|
-
"@contrast/config": "1.
|
|
18
|
-
"@contrast/core": "1.
|
|
19
|
-
"@contrast/logger": "1.
|
|
16
|
+
"@contrast/common": "1.28.0",
|
|
17
|
+
"@contrast/config": "1.38.0",
|
|
18
|
+
"@contrast/core": "1.43.0",
|
|
19
|
+
"@contrast/logger": "1.16.0",
|
|
20
20
|
"axios": "^1.7.4",
|
|
21
21
|
"getmac": "^6.3.0"
|
|
22
22
|
}
|