@checkly/playwright-core 1.51.17-beta.3 → 1.51.17-beta.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/lib/checkly/index.js +16 -0
- package/lib/checkly/secretsFilter.js +57 -1
- package/lib/client/fetch.js +10 -2
- package/lib/server/har/harRecorder.js +1 -1
- package/lib/utils/isomorphic/protocolMetainfo.js +2 -3
- package/package.json +2 -1
- package/lib/checkly/checklyFileSystem.js +0 -44
- package/lib/escapeRegExp.js +0 -30
- package/lib/secretsFilter.js +0 -131
- package/lib/server/registry/index.d.ts +0 -86
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _secretsFilter = require("./secretsFilter");
|
|
7
|
+
Object.keys(_secretsFilter).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _secretsFilter[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _secretsFilter[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -3,13 +3,68 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.secretsFilter = void 0;
|
|
6
|
+
exports.secretsFilter = exports.addSecret = void 0;
|
|
7
|
+
var diagnostics_channel = _interopRequireWildcard(require("node:diagnostics_channel"));
|
|
7
8
|
var _escapeRegExp = _interopRequireDefault(require("./escapeRegExp"));
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
12
|
/* Copyright Checkly
|
|
10
13
|
*/
|
|
11
14
|
|
|
12
15
|
const IdentityFunction = s => s;
|
|
16
|
+
const dynamicallyAddedSecrets = new Set();
|
|
17
|
+
let cachedAuthorizationHeaderSecrets = null;
|
|
18
|
+
const extractAuthorizationHeaderValue = authorizationHeaderValue => {
|
|
19
|
+
const spaceIndex = authorizationHeaderValue.indexOf(' ');
|
|
20
|
+
return spaceIndex === -1 ? authorizationHeaderValue : authorizationHeaderValue.split(' ')[1];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// For http/https
|
|
24
|
+
diagnostics_channel.subscribe('http.client.request.start', message => {
|
|
25
|
+
const {
|
|
26
|
+
request
|
|
27
|
+
} = message;
|
|
28
|
+
const auth = request.getHeader('authorization');
|
|
29
|
+
if (auth) {
|
|
30
|
+
dynamicallyAddedSecrets.add(extractAuthorizationHeaderValue(auth));
|
|
31
|
+
cachedAuthorizationHeaderSecrets = new RegExp(Array.from(dynamicallyAddedSecrets).map(_escapeRegExp.default).join('|'), 'g');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// For undici (powers global fetch in Node 18+)
|
|
36
|
+
diagnostics_channel.subscribe('undici:request:create', message => {
|
|
37
|
+
var _request$headers;
|
|
38
|
+
const {
|
|
39
|
+
request
|
|
40
|
+
} = message;
|
|
41
|
+
const auth = (_request$headers = request.headers) === null || _request$headers === void 0 ? void 0 : _request$headers.authorization;
|
|
42
|
+
if (auth) {
|
|
43
|
+
dynamicallyAddedSecrets.add(extractAuthorizationHeaderValue(auth));
|
|
44
|
+
cachedAuthorizationHeaderSecrets = new RegExp(Array.from(dynamicallyAddedSecrets).map(_escapeRegExp.default).join('|'), 'g');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const addSecret = secret => {
|
|
48
|
+
try {
|
|
49
|
+
if (!secret || typeof secret !== 'string') return;
|
|
50
|
+
const secretValue = extractAuthorizationHeaderValue(secret);
|
|
51
|
+
if (!secretValue) return;
|
|
52
|
+
dynamicallyAddedSecrets.add(secretValue);
|
|
53
|
+
const escapedSecrets = Array.from(dynamicallyAddedSecrets).map(s => {
|
|
54
|
+
try {
|
|
55
|
+
return (0, _escapeRegExp.default)(s);
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}).filter(Boolean);
|
|
60
|
+
if (escapedSecrets.length > 0) cachedAuthorizationHeaderSecrets = new RegExp(escapedSecrets.join('|'), 'g');
|
|
61
|
+
console.log(`[CHECKLY_RUNTIME_SECRET]${secretValue}[/CHECKLY_RUNTIME_SECRET]`);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
// Silently fail to avoid breaking the application
|
|
64
|
+
// Error could be from RegExp construction or console.log
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.addSecret = addSecret;
|
|
13
68
|
const secretsFilter = () => {
|
|
14
69
|
const disabled = process.env['CHECKLY_INTERNAL_ENABLE_PATCHED_TRACING'] !== 'true';
|
|
15
70
|
if (disabled) return IdentityFunction;
|
|
@@ -40,6 +95,7 @@ const secretsFilter = () => {
|
|
|
40
95
|
|
|
41
96
|
// Scrub secrets
|
|
42
97
|
if (cachedRegex) filtered = filtered.replaceAll(cachedRegex, '*********');
|
|
98
|
+
if (cachedAuthorizationHeaderSecrets) filtered = filtered.replaceAll(cachedAuthorizationHeaderSecrets, '*********');
|
|
43
99
|
return filtered;
|
|
44
100
|
};
|
|
45
101
|
};
|
package/lib/client/fetch.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.APIResponse = exports.APIRequestContext = exports.APIRequest = void 0;
|
|
7
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
7
9
|
var _browserContext = require("./browserContext");
|
|
8
10
|
var _channelOwner = require("./channelOwner");
|
|
9
11
|
var _errors = require("./errors");
|
|
@@ -13,9 +15,8 @@ var _assert = require("../utils/isomorphic/assert");
|
|
|
13
15
|
var _fileUtils = require("./fileUtils");
|
|
14
16
|
var _headers = require("../utils/isomorphic/headers");
|
|
15
17
|
var _rtti = require("../utils/isomorphic/rtti");
|
|
16
|
-
var fs = _interopRequireWildcard(require("fs"));
|
|
17
18
|
var _fetch = require("../checkly/fetch");
|
|
18
|
-
var
|
|
19
|
+
var _secretsFilter = require("../checkly/secretsFilter");
|
|
19
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -218,6 +219,13 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
218
219
|
const fixtures = {
|
|
219
220
|
__testHookLookup: options.__testHookLookup
|
|
220
221
|
};
|
|
222
|
+
|
|
223
|
+
// [Checkly] We need to parse the headers in case there is the Authorization one.
|
|
224
|
+
for (const header of headers || []) {
|
|
225
|
+
if (header.name === 'Authorization') (0, _secretsFilter.addSecret)(header.value);
|
|
226
|
+
}
|
|
227
|
+
// [/Checkly]
|
|
228
|
+
|
|
221
229
|
const result = await this._channel.fetch({
|
|
222
230
|
url,
|
|
223
231
|
params: typeof options.params === 'object' ? objectToArray(options.params) : undefined,
|
|
@@ -58,7 +58,7 @@ class HarRecorder {
|
|
|
58
58
|
onEntryStarted(entry) {
|
|
59
59
|
this._entries.push(entry);
|
|
60
60
|
}
|
|
61
|
-
onEntryFinished(
|
|
61
|
+
onEntryFinished(entry) {}
|
|
62
62
|
onContentBlob(sha1, buffer) {
|
|
63
63
|
if (!this._zipFile || this._writtenZipEntries.has(sha1)) return;
|
|
64
64
|
this._writtenZipEntries.add(sha1);
|
|
@@ -63,7 +63,7 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
63
63
|
["Browser.defaultUserAgentForTest", { internal: true }],
|
|
64
64
|
["Browser.newContext", { title: "Create context" }],
|
|
65
65
|
["Browser.newContextForReuse", { internal: true }],
|
|
66
|
-
["Browser.
|
|
66
|
+
["Browser.stopPendingOperations", { internal: true, title: "Stop pending operations" }],
|
|
67
67
|
["Browser.newBrowserCDPSession", { internal: true, title: "Create CDP session" }],
|
|
68
68
|
["Browser.startTracing", { internal: true }],
|
|
69
69
|
["Browser.stopTracing", { internal: true }],
|
|
@@ -93,7 +93,6 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
93
93
|
["BrowserContext.storageState", { title: "Get storage state" }],
|
|
94
94
|
["BrowserContext.pause", { title: "Pause" }],
|
|
95
95
|
["BrowserContext.enableRecorder", { internal: true }],
|
|
96
|
-
["BrowserContext.disableRecorder", { internal: true }],
|
|
97
96
|
["BrowserContext.newCDPSession", { internal: true }],
|
|
98
97
|
["BrowserContext.harStart", { internal: true }],
|
|
99
98
|
["BrowserContext.harExport", { internal: true }],
|
|
@@ -160,7 +159,6 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
160
159
|
["Frame.fill", { title: 'Fill "{value}"', slowMo: true, snapshot: true, pausesBeforeInput: true }],
|
|
161
160
|
["Frame.focus", { title: "Focus", slowMo: true, snapshot: true }],
|
|
162
161
|
["Frame.frameElement", { internal: true }],
|
|
163
|
-
["Frame.generateLocatorString", { internal: true }],
|
|
164
162
|
["Frame.highlight", { internal: true }],
|
|
165
163
|
["Frame.getAttribute", { internal: true, snapshot: true }],
|
|
166
164
|
["Frame.goto", { title: 'Navigate to "{url}"', slowMo: true, snapshot: true }],
|
|
@@ -214,6 +212,7 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
214
212
|
["ElementHandle.dispatchEvent", { title: "Dispatch event", slowMo: true, snapshot: true }],
|
|
215
213
|
["ElementHandle.fill", { title: 'Fill "{value}"', slowMo: true, snapshot: true, pausesBeforeInput: true }],
|
|
216
214
|
["ElementHandle.focus", { title: "Focus", slowMo: true, snapshot: true }],
|
|
215
|
+
["ElementHandle.generateLocatorString", { internal: true }],
|
|
217
216
|
["ElementHandle.getAttribute", { internal: true }],
|
|
218
217
|
["ElementHandle.hover", { title: "Hover", slowMo: true, snapshot: true, pausesBeforeInput: true }],
|
|
219
218
|
["ElementHandle.innerHTML", { title: "Get HTML", snapshot: true }],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkly/playwright-core",
|
|
3
|
-
"version": "1.51.17-beta.
|
|
3
|
+
"version": "1.51.17-beta.5",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"./lib/server/utils/image_tools/imageChannel": "./lib/server/utils/image_tools/imageChannel.js",
|
|
32
32
|
"./lib/server/utils/image_tools/colorUtils": "./lib/server/utils/image_tools/colorUtils.js",
|
|
33
33
|
"./lib/server/registry/index": "./lib/server/registry/index.js",
|
|
34
|
+
"./lib/checkly": "./lib/checkly/index.js",
|
|
34
35
|
"./lib/utils": "./lib/utils.js",
|
|
35
36
|
"./lib/utilsBundle": "./lib/utilsBundle.js",
|
|
36
37
|
"./lib/zipBundle": "./lib/zipBundle.js",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var checklyFileSystem_exports = {};
|
|
20
|
-
__export(checklyFileSystem_exports, {
|
|
21
|
-
ChecklyFileSystem: () => ChecklyFileSystem
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(checklyFileSystem_exports);
|
|
24
|
-
var import_zipBundle = require("playwright-core/lib/zipBundle");
|
|
25
|
-
var import_fileUtils = require("../server/utils/fileUtils");
|
|
26
|
-
var import_secretsFilter = require("./secretsFilter");
|
|
27
|
-
const isSecretScrubbingEnabled = () => process.env["CHECKLY_INTERNAL_ENABLE_PATCHED_TRACING"] === "true";
|
|
28
|
-
class ChecklyFileSystem {
|
|
29
|
-
static create() {
|
|
30
|
-
return isSecretScrubbingEnabled() ? new import_fileUtils.SecretSerializedFS((0, import_secretsFilter.secretsFilter)()) : new import_fileUtils.SerializedFS();
|
|
31
|
-
}
|
|
32
|
-
static createZipFile() {
|
|
33
|
-
if (isSecretScrubbingEnabled()) {
|
|
34
|
-
const secretFS = new import_fileUtils.SecretSerializedFS((0, import_secretsFilter.secretsFilter)());
|
|
35
|
-
const ScrubbingZipFile = secretFS.createScrubbingZipFile(import_zipBundle.yazl.ZipFile);
|
|
36
|
-
return new ScrubbingZipFile();
|
|
37
|
-
}
|
|
38
|
-
return new import_zipBundle.yazl.ZipFile();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
ChecklyFileSystem
|
|
44
|
-
});
|
package/lib/escapeRegExp.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Copyright (c) 2009-2020 Lodash.
|
|
5
|
-
* Taken from: https://github.com/lodash/lodash/blob/main/src/escapeRegExp.ts
|
|
6
|
-
* Used to match `RegExp`
|
|
7
|
-
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
8
|
-
*/
|
|
9
|
-
const reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
10
|
-
const reHasRegExpChar = RegExp(reRegExpChar.source);
|
|
11
|
-
/**
|
|
12
|
-
* Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
|
|
13
|
-
* "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
|
|
14
|
-
*
|
|
15
|
-
* @since 3.0.0
|
|
16
|
-
* @category String
|
|
17
|
-
* @param {string} [string=''] The string to escape.
|
|
18
|
-
* @returns {string} Returns the escaped string.
|
|
19
|
-
* @see escape, escapeRegExp, unescape
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* escapeRegExp('[lodash](https://lodash.com/)')
|
|
23
|
-
* // => '\[lodash\]\(https://lodash\.com/\)'
|
|
24
|
-
*/
|
|
25
|
-
function escapeRegExp(string) {
|
|
26
|
-
return string && reHasRegExpChar.test(string)
|
|
27
|
-
? string.replace(reRegExpChar, '\\$&')
|
|
28
|
-
: string || '';
|
|
29
|
-
}
|
|
30
|
-
exports.default = escapeRegExp;
|
package/lib/secretsFilter.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.secretsFilter = void 0;
|
|
4
|
-
/* Copyright Checkly
|
|
5
|
-
*/
|
|
6
|
-
const escapeRegExp_1 = require("./escapeRegExp");
|
|
7
|
-
const IdentityFunction = (s) => s;
|
|
8
|
-
// Keys that may contain request/response body data that should be scrubbed
|
|
9
|
-
const REQUEST_BODY_KEYS = ['postData', 'body', 'requestBody', 'responseBody', 'payload', 'data'];
|
|
10
|
-
// Helper function to detect if a string might be base64 encoded
|
|
11
|
-
const isLikelyBase64 = (str) => {
|
|
12
|
-
if (typeof str !== 'string' || str.length === 0)
|
|
13
|
-
return false;
|
|
14
|
-
// Simple heuristic: base64 strings are typically longer and contain base64 characters
|
|
15
|
-
return str.length > 20 && /^[A-Za-z0-9+/=]+$/.test(str) && str.length % 4 === 0;
|
|
16
|
-
};
|
|
17
|
-
// Helper function to recursively scrub secrets from objects
|
|
18
|
-
const scrubObjectSecrets = (obj, secretsFilterFn) => {
|
|
19
|
-
if (obj === null || obj === undefined)
|
|
20
|
-
return obj;
|
|
21
|
-
if (Array.isArray(obj))
|
|
22
|
-
return obj.map(item => scrubObjectSecrets(item, secretsFilterFn));
|
|
23
|
-
if (typeof obj === 'object') {
|
|
24
|
-
const result = {};
|
|
25
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
26
|
-
if (typeof value === 'string')
|
|
27
|
-
result[key] = secretsFilterFn(value);
|
|
28
|
-
else
|
|
29
|
-
result[key] = scrubObjectSecrets(value, secretsFilterFn);
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
if (typeof obj === 'string')
|
|
34
|
-
return secretsFilterFn(obj);
|
|
35
|
-
return obj;
|
|
36
|
-
};
|
|
37
|
-
// Helper function to scrub request body content
|
|
38
|
-
const scrubRequestBody = (value, secretsFilterFn) => {
|
|
39
|
-
if (typeof value === 'string') {
|
|
40
|
-
// Try to detect if it's base64 encoded
|
|
41
|
-
if (isLikelyBase64(value)) {
|
|
42
|
-
try {
|
|
43
|
-
const decoded = Buffer.from(value, 'base64').toString('utf8');
|
|
44
|
-
// Try to parse as JSON first
|
|
45
|
-
try {
|
|
46
|
-
const parsedJson = JSON.parse(decoded);
|
|
47
|
-
const scrubbedJson = scrubObjectSecrets(parsedJson, secretsFilterFn);
|
|
48
|
-
const scrubbedString = JSON.stringify(scrubbedJson);
|
|
49
|
-
return Buffer.from(scrubbedString, 'utf8').toString('base64');
|
|
50
|
-
}
|
|
51
|
-
catch (jsonError) {
|
|
52
|
-
// Not JSON, scrub as regular text
|
|
53
|
-
const scrubbed = secretsFilterFn(decoded);
|
|
54
|
-
return Buffer.from(scrubbed, 'utf8').toString('base64');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
// If decoding fails, treat as regular string
|
|
59
|
-
return secretsFilterFn(value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// Try to parse as JSON first
|
|
64
|
-
try {
|
|
65
|
-
const parsedJson = JSON.parse(value);
|
|
66
|
-
const scrubbedJson = scrubObjectSecrets(parsedJson, secretsFilterFn);
|
|
67
|
-
return JSON.stringify(scrubbedJson);
|
|
68
|
-
}
|
|
69
|
-
catch (jsonError) {
|
|
70
|
-
// Not JSON, scrub as regular text
|
|
71
|
-
return secretsFilterFn(value);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else if (Buffer.isBuffer(value)) {
|
|
76
|
-
// Handle Buffer objects
|
|
77
|
-
const decoded = value.toString('utf8');
|
|
78
|
-
try {
|
|
79
|
-
const parsedJson = JSON.parse(decoded);
|
|
80
|
-
const scrubbedJson = scrubObjectSecrets(parsedJson, secretsFilterFn);
|
|
81
|
-
const scrubbedString = JSON.stringify(scrubbedJson);
|
|
82
|
-
return Buffer.from(scrubbedString, 'utf8');
|
|
83
|
-
}
|
|
84
|
-
catch (jsonError) {
|
|
85
|
-
// Not JSON, scrub as regular text
|
|
86
|
-
const scrubbed = secretsFilterFn(decoded);
|
|
87
|
-
return Buffer.from(scrubbed, 'utf8');
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else if (typeof value === 'object' && value !== null) {
|
|
91
|
-
// Handle JSON objects directly
|
|
92
|
-
return scrubObjectSecrets(value, secretsFilterFn);
|
|
93
|
-
}
|
|
94
|
-
return value;
|
|
95
|
-
};
|
|
96
|
-
const secretsFilter = () => {
|
|
97
|
-
const disabled = process.env['CHECKLY_INTERNAL_ENABLE_PATCHED_TRACING'] !== 'true';
|
|
98
|
-
if (disabled)
|
|
99
|
-
return IdentityFunction;
|
|
100
|
-
// Cache for regex to avoid recompiling on every call
|
|
101
|
-
let cachedRegex = null;
|
|
102
|
-
let cachedKeys = '';
|
|
103
|
-
// Regex to filter out console markers
|
|
104
|
-
const consoleMarkerRegex = /\[CHECKLY_RUNTIME_SECRET\].*?\[\/CHECKLY_RUNTIME_SECRET\]/g;
|
|
105
|
-
const filterFn = (s) => {
|
|
106
|
-
const keys = process.env['CHECKLY_INTERNAL_REPLACE_TRACE_KEYS'] || '[]';
|
|
107
|
-
// Only recompile regex if keys have changed (handles runtime CHECKLY_SECRET_ variables)
|
|
108
|
-
if (keys !== cachedKeys) {
|
|
109
|
-
const keylist = JSON.parse(keys);
|
|
110
|
-
if (keylist.length === 0) {
|
|
111
|
-
cachedRegex = null;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
const escapedList = keylist.map(escapeRegExp_1.default);
|
|
115
|
-
cachedRegex = new RegExp(escapedList.join('|'), 'g');
|
|
116
|
-
}
|
|
117
|
-
cachedKeys = keys;
|
|
118
|
-
}
|
|
119
|
-
// First filter out console markers entirely
|
|
120
|
-
let filtered = s.replace(consoleMarkerRegex, '');
|
|
121
|
-
// Scrub secrets
|
|
122
|
-
if (cachedRegex)
|
|
123
|
-
filtered = filtered.replace(cachedRegex, '*********');
|
|
124
|
-
return filtered;
|
|
125
|
-
};
|
|
126
|
-
// Extend the filter function with a method to scrub request bodies
|
|
127
|
-
filterFn.scrubRequestBody = (value) => scrubRequestBody(value, filterFn);
|
|
128
|
-
filterFn.isRequestBodyKey = (key) => REQUEST_BODY_KEYS.includes(key);
|
|
129
|
-
return filterFn;
|
|
130
|
-
};
|
|
131
|
-
exports.secretsFilter = secretsFilter;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
3
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
export { writeDockerVersion } from './dependencies';
|
|
18
|
-
export declare const registryDirectory: string;
|
|
19
|
-
type BrowsersJSON = {
|
|
20
|
-
comment: string;
|
|
21
|
-
browsers: {
|
|
22
|
-
name: string;
|
|
23
|
-
revision: string;
|
|
24
|
-
browserVersion?: string;
|
|
25
|
-
installByDefault: boolean;
|
|
26
|
-
revisionOverrides?: {
|
|
27
|
-
[os: string]: string;
|
|
28
|
-
};
|
|
29
|
-
}[];
|
|
30
|
-
};
|
|
31
|
-
export type BrowserInfo = {
|
|
32
|
-
browserName: string;
|
|
33
|
-
browserVersion: number;
|
|
34
|
-
browserPath: string;
|
|
35
|
-
referenceDir: string;
|
|
36
|
-
};
|
|
37
|
-
export type BrowserName = 'chromium' | 'firefox' | 'webkit' | '_bidiFirefox' | '_bidiChromium';
|
|
38
|
-
type InternalTool = 'ffmpeg' | 'winldd' | 'firefox-beta' | 'chromium-tip-of-tree' | 'chromium-headless-shell' | 'chromium-tip-of-tree-headless-shell' | 'android';
|
|
39
|
-
type BidiChannel = 'moz-firefox' | 'moz-firefox-beta' | 'moz-firefox-nightly' | 'bidi-chrome-canary' | 'bidi-chrome-stable' | 'bidi-chromium';
|
|
40
|
-
type ChromiumChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';
|
|
41
|
-
export interface Executable {
|
|
42
|
-
type: 'browser' | 'tool' | 'channel';
|
|
43
|
-
name: BrowserName | InternalTool | ChromiumChannel | BidiChannel;
|
|
44
|
-
browserName: BrowserName | undefined;
|
|
45
|
-
installType: 'download-by-default' | 'download-on-demand' | 'install-script' | 'none';
|
|
46
|
-
directory: string | undefined;
|
|
47
|
-
downloadURLs?: string[];
|
|
48
|
-
browserVersion?: string;
|
|
49
|
-
executablePathOrDie(sdkLanguage: string): string;
|
|
50
|
-
executablePath(sdkLanguage: string): string | undefined;
|
|
51
|
-
_validateHostRequirements(sdkLanguage: string): Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
export declare class Registry {
|
|
54
|
-
private _executables;
|
|
55
|
-
constructor(browsersJSON: BrowsersJSON);
|
|
56
|
-
private _createChromiumChannel;
|
|
57
|
-
private _createBidiFirefoxChannel;
|
|
58
|
-
private _createBidiChromiumChannel;
|
|
59
|
-
executables(): Executable[];
|
|
60
|
-
findExecutable(name: BrowserName): Executable;
|
|
61
|
-
findExecutable(name: string): Executable | undefined;
|
|
62
|
-
defaultExecutables(): Executable[];
|
|
63
|
-
private _dedupe;
|
|
64
|
-
private _validateHostRequirements;
|
|
65
|
-
installDeps(executablesToInstallDeps: Executable[], dryRun: boolean): Promise<void>;
|
|
66
|
-
install(executablesToInstall: Executable[], forceReinstall: boolean): Promise<void>;
|
|
67
|
-
uninstall(all: boolean): Promise<{
|
|
68
|
-
numberOfBrowsersLeft: number;
|
|
69
|
-
}>;
|
|
70
|
-
validateHostRequirementsForExecutablesIfNeeded(executables: Executable[], sdkLanguage: string): Promise<void>;
|
|
71
|
-
private _validateHostRequirementsForExecutableIfNeeded;
|
|
72
|
-
private _downloadURLs;
|
|
73
|
-
private _downloadExecutable;
|
|
74
|
-
private _installMSEdgeChannel;
|
|
75
|
-
private _installChromiumChannel;
|
|
76
|
-
listInstalledBrowsers(): Promise<BrowserInfo[]>;
|
|
77
|
-
private _validateInstallationCache;
|
|
78
|
-
private _traverseBrowserInstallations;
|
|
79
|
-
private _deleteStaleBrowsers;
|
|
80
|
-
private _deleteBrokenInstallations;
|
|
81
|
-
}
|
|
82
|
-
export declare function browserDirectoryToMarkerFilePath(browserDirectory: string): string;
|
|
83
|
-
export declare function buildPlaywrightCLICommand(sdkLanguage: string, parameters: string): string;
|
|
84
|
-
export declare function installBrowsersForNpmInstall(browsers: string[]): Promise<boolean>;
|
|
85
|
-
export declare function findChromiumChannelBestEffort(sdkLanguage: string): string | undefined;
|
|
86
|
-
export declare const registry: Registry;
|