@contrast/core 1.37.0 → 1.39.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/app-info.js +3 -3
- package/lib/capture-stacktrace.js +3 -2
- package/lib/contrast-methods.js +3 -2
- package/lib/index.d.ts +1 -0
- package/lib/messages.js +6 -1
- package/lib/sensitive-data-masking/index.js +2 -2
- package/lib/sensitive-data-masking/protect-listener.js +4 -3
- package/lib/system-info/index.js +6 -5
- package/package.json +7 -6
package/lib/app-info.js
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
const os = require('os');
|
|
19
19
|
const fs = require('fs');
|
|
20
20
|
const path = require('path');
|
|
21
|
-
const semver = require('semver');
|
|
21
|
+
const semver = require('semver');
|
|
22
22
|
const process = require('process');
|
|
23
|
-
const { IntentionalError } = require('@contrast/common');
|
|
23
|
+
const { IntentionalError, primordials: { ArrayPrototypeJoin } } = require('@contrast/common');
|
|
24
24
|
const { findPackageJsonSync } = require('@contrast/find-package-json');
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -98,7 +98,7 @@ module.exports = function (core) {
|
|
|
98
98
|
*/
|
|
99
99
|
function getCommand() {
|
|
100
100
|
const args = [process.argv0, ...process.argv].map((a) => path.basename(a));
|
|
101
|
-
const cmd = Array.from(new Set(args))
|
|
101
|
+
const cmd = ArrayPrototypeJoin.call(Array.from(new Set(args)), ' ');
|
|
102
102
|
const message = 'application command matches cmd_ignore_list config option';
|
|
103
103
|
|
|
104
104
|
if (cmd_ignore_list) {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
const process = require('process');
|
|
19
19
|
const fnInspect = require('@contrast/fn-inspect');
|
|
20
|
+
const { primordials: { StringPrototypeReplace, RegExpPrototypeExec } } = require('@contrast/common');
|
|
20
21
|
|
|
21
22
|
/** @typedef {import('.').Frame} Frame */
|
|
22
23
|
/** @typedef {import('.').CreateSnapshotOpts} CreateSnapshotOpts */
|
|
@@ -186,7 +187,7 @@ class StacktraceFactory {
|
|
|
186
187
|
|
|
187
188
|
if (callsite.isEval()) {
|
|
188
189
|
evalOrigin = StacktraceFactory.formatFileName(callsite.getEvalOrigin());
|
|
189
|
-
const matches =
|
|
190
|
+
const matches = RegExpPrototypeExec.call(EVAL_ORIGIN_REGEX, evalOrigin);
|
|
190
191
|
if (matches) {
|
|
191
192
|
file = matches[1];
|
|
192
193
|
lineNumber = parseInt(matches[2]);
|
|
@@ -215,7 +216,7 @@ class StacktraceFactory {
|
|
|
215
216
|
const idx = fileName.indexOf(cwd);
|
|
216
217
|
|
|
217
218
|
if (idx > -1) {
|
|
218
|
-
return
|
|
219
|
+
return StringPrototypeReplace.call(fileName, cwd, ''); // + 1 to remove /
|
|
219
220
|
}
|
|
220
221
|
return fileName;
|
|
221
222
|
}
|
package/lib/contrast-methods.js
CHANGED
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
+
const { primordials: { StringPrototypeSlice } } = require('@contrast/common');
|
|
19
|
+
|
|
18
20
|
module.exports = function (core) {
|
|
19
21
|
const { logger, patcher } = core;
|
|
20
22
|
|
|
21
23
|
const getOrig = (v) => patcher.unwrap(v);
|
|
22
|
-
const
|
|
23
|
-
const toUntrackedString = (v) => slice.call(` ${v}`, 1);
|
|
24
|
+
const toUntrackedString = (v) => StringPrototypeSlice.call(` ${v}`, 1);
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Components e.g. Assess, Protect, can
|
package/lib/index.d.ts
CHANGED
package/lib/messages.js
CHANGED
|
@@ -18,5 +18,10 @@
|
|
|
18
18
|
const EventEmitter = require('events');
|
|
19
19
|
|
|
20
20
|
module.exports = function init(core) {
|
|
21
|
-
|
|
21
|
+
const messages = new EventEmitter();
|
|
22
|
+
|
|
23
|
+
// pad for number of components that listen for server-settings-update messages
|
|
24
|
+
messages.setMaxListeners(20);
|
|
25
|
+
|
|
26
|
+
return core.messages = messages;
|
|
22
27
|
};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
-
const { traverseKeys } = require('@contrast/common');
|
|
18
|
+
const { traverseKeys, primordials: { StringPrototypeToLowerCase } } = require('@contrast/common');
|
|
19
19
|
const { CONTRAST_REDACTED } = require('./constants');
|
|
20
20
|
|
|
21
21
|
module.exports = function(core) {
|
|
@@ -23,7 +23,7 @@ module.exports = function(core) {
|
|
|
23
23
|
const keywordSets = [];
|
|
24
24
|
|
|
25
25
|
function getRedactedText(key) {
|
|
26
|
-
key =
|
|
26
|
+
key = StringPrototypeToLowerCase.call(key);
|
|
27
27
|
for (const set of keywordSets) {
|
|
28
28
|
if (set.has(key)) {
|
|
29
29
|
return `${CONTRAST_REDACTED}-${idMap.get(set)}`;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { URLSearchParams } = require('url');
|
|
19
|
-
const { Event } = require('@contrast/common');
|
|
19
|
+
const { Event, primordials: { StringPrototypeReplace } } = require('@contrast/common');
|
|
20
20
|
|
|
21
21
|
const { CONTRAST_REDACTED } = require('./constants');
|
|
22
22
|
|
|
@@ -50,9 +50,10 @@ module.exports = function (core) {
|
|
|
50
50
|
const redactedText = getRedactedText(key);
|
|
51
51
|
if (redactedText) {
|
|
52
52
|
const encoded = encodeURIComponent(value);
|
|
53
|
-
msg.protect.reqData.uriPath =
|
|
53
|
+
msg.protect.reqData.uriPath = StringPrototypeReplace.call(
|
|
54
|
+
msg.protect.reqData.uriPath,
|
|
54
55
|
encoded,
|
|
55
|
-
redactedText
|
|
56
|
+
redactedText
|
|
56
57
|
);
|
|
57
58
|
msg.protect.parsedParams[key] = redactedText;
|
|
58
59
|
}
|
package/lib/system-info/index.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
const fs = require('fs/promises');
|
|
19
19
|
const os = require('os');
|
|
20
20
|
const { getCloudProviderMetadata } = require('./cloud-provider-metadata');
|
|
21
|
+
const { primordials: { StringPrototypeConcat, StringPrototypeMatch } } = require('@contrast/common');
|
|
21
22
|
|
|
22
23
|
const MOUNTINFO_REGEX = /\/docker\/containers\/(.*?)\//;
|
|
23
24
|
const CGROUP_REGEX = /:\/docker\/([^/]+)$/;
|
|
@@ -36,7 +37,7 @@ async function isDocker() {
|
|
|
36
37
|
try {
|
|
37
38
|
const result = await fs.readFile('/proc/self/mountinfo', 'utf8');
|
|
38
39
|
// @ts-expect-error readFile with encoding returns a string, not a Buffer
|
|
39
|
-
const matches =
|
|
40
|
+
const matches = StringPrototypeMatch.call(result, MOUNTINFO_REGEX);
|
|
40
41
|
if (matches) return { isDocker: true, containerID: matches[1] };
|
|
41
42
|
} catch (err) {
|
|
42
43
|
// else check /proc/self/cgroup
|
|
@@ -45,7 +46,7 @@ async function isDocker() {
|
|
|
45
46
|
try {
|
|
46
47
|
const result = await fs.readFile('/proc/self/cgroup', 'utf8');
|
|
47
48
|
// @ts-expect-error readFile with encoding returns a string, not a Buffer
|
|
48
|
-
const matches =
|
|
49
|
+
const matches = StringPrototypeMatch.call(result, CGROUP_REGEX);
|
|
49
50
|
if (matches) return { isDocker: true, containerID: matches[1] };
|
|
50
51
|
} catch (err) {
|
|
51
52
|
// else check /.dockerenv
|
|
@@ -114,9 +115,9 @@ module.exports = function(core) {
|
|
|
114
115
|
Docker: await isDocker(),
|
|
115
116
|
PM2: isUsingPM2(appInfo.pkg),
|
|
116
117
|
Memory: {
|
|
117
|
-
Total: (totalmem / 1e6).toFixed(0)
|
|
118
|
-
Free: (freemem / 1e6).toFixed(0)
|
|
119
|
-
Used: ((totalmem - freemem) / 1e6).toFixed(0)
|
|
118
|
+
Total: StringPrototypeConcat.call((totalmem / 1e6).toFixed(0), ' MB'),
|
|
119
|
+
Free: StringPrototypeConcat.call((freemem / 1e6).toFixed(0), ' MB'),
|
|
120
|
+
Used: StringPrototypeConcat.call(((totalmem - freemem) / 1e6).toFixed(0), ' MB'),
|
|
120
121
|
}
|
|
121
122
|
},
|
|
122
123
|
Application: appInfo.pkg,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"description": "Preconfigured Contrast agent core services and models",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
"test": "../scripts/test.sh"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@contrast/common": "1.
|
|
20
|
-
"@contrast/config": "1.
|
|
19
|
+
"@contrast/common": "1.26.0",
|
|
20
|
+
"@contrast/config": "1.34.0",
|
|
21
21
|
"@contrast/find-package-json": "^1.1.0",
|
|
22
22
|
"@contrast/fn-inspect": "^4.3.0",
|
|
23
|
-
"@contrast/logger": "1.
|
|
24
|
-
"@contrast/patcher": "1.
|
|
25
|
-
"axios": "^1.7.4"
|
|
23
|
+
"@contrast/logger": "1.12.0",
|
|
24
|
+
"@contrast/patcher": "1.11.0",
|
|
25
|
+
"axios": "^1.7.4",
|
|
26
|
+
"semver": "^7.6.0"
|
|
26
27
|
}
|
|
27
28
|
}
|