@checkly/playwright-core 1.51.16-beta.0 → 1.51.17-beta.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/checkly/secretsFilter.js +11 -31
- package/package.json +1 -1
|
@@ -10,41 +10,21 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const IdentityFunction = s => s;
|
|
13
|
+
const secretPlaceholder = '*********';
|
|
13
14
|
const secretsFilter = () => {
|
|
14
15
|
const disabled = process.env['CHECKLY_INTERNAL_ENABLE_PATCHED_TRACING'] !== 'true';
|
|
15
16
|
if (disabled) return IdentityFunction;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const consoleMarkerRegex = /\[CHECKLY_RUNTIME_SECRET\].*?\[\/CHECKLY_RUNTIME_SECRET\]/g;
|
|
17
|
+
const keys = process.env['CHECKLY_INTERNAL_REPLACE_TRACE_KEYS'] || '[]';
|
|
18
|
+
const gitLeaksKeys = process.env['CHECKLY_GITLEAKS_RULES'] || '[]';
|
|
19
|
+
const keylist = JSON.parse(keys);
|
|
20
|
+
const gitLeaksKeyList = JSON.parse(gitLeaksKeys).map(rule => new RegExp(rule, 'gi'));
|
|
21
|
+
const escapedList = keylist.map(_escapeRegExp.default);
|
|
22
|
+
const regex = new RegExp(escapedList.join('|'), 'g');
|
|
23
23
|
return s => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const keylist = JSON.parse(keys);
|
|
30
|
-
if (keylist.length === 0) {
|
|
31
|
-
cachedRegex = null;
|
|
32
|
-
} else {
|
|
33
|
-
const escapedList = keylist.map(_escapeRegExp.default);
|
|
34
|
-
cachedRegex = new RegExp(escapedList.join('|'), 'g');
|
|
35
|
-
}
|
|
36
|
-
cachedKeys = keys;
|
|
37
|
-
} catch (e) {
|
|
38
|
-
// If parsing fails, we keep using the previous cached regex
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// First filter out console markers entirely
|
|
43
|
-
let filtered = s.replace(consoleMarkerRegex, '');
|
|
44
|
-
|
|
45
|
-
// Scrub secrets
|
|
46
|
-
if (cachedRegex) filtered = filtered.replaceAll(cachedRegex, '*********');
|
|
47
|
-
return filtered;
|
|
24
|
+
// Replace with GitLeaks secrets and Checkly secrets
|
|
25
|
+
return gitLeaksKeyList.reduce((memo, gitLeaksRule) => {
|
|
26
|
+
return memo.replaceAll(gitLeaksRule, secretPlaceholder);
|
|
27
|
+
}, s.replaceAll(regex, secretPlaceholder));
|
|
48
28
|
};
|
|
49
29
|
};
|
|
50
30
|
exports.secretsFilter = secretsFilter;
|