browserstack-cypress-cli 1.36.19 → 1.36.21
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/.coderabbit.yaml +15 -0
- package/.github/workflows/Semgrep.yml +4 -1
- package/bin/commands/runs.js +2 -2
- package/bin/helpers/buildArtifacts.js +4 -3
- package/bin/helpers/capabilityHelper.js +14 -1
- package/bin/helpers/distrustedCaCheck.js +119 -0
- package/bin/helpers/reporterHTML.js +7 -8
- package/bin/helpers/utils.js +7 -0
- package/bin/testhub/testhubHandler.js +2 -2
- package/bin/testhub/utils.js +5 -1
- package/package.json +7 -3
package/.coderabbit.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
inheritance: true
|
|
2
|
+
reviews:
|
|
3
|
+
review_details: true
|
|
4
|
+
request_changes_workflow: true
|
|
5
|
+
auto_review:
|
|
6
|
+
enabled: true
|
|
7
|
+
knowledge_base:
|
|
8
|
+
code_guidelines:
|
|
9
|
+
filePatterns:
|
|
10
|
+
- "browserstack/browserstack-ai-harness:stacks/stack-domain-browserstack-cypress-cli/rules/**/*.md"
|
|
11
|
+
- "browserstack/browserstack-ai-harness:stacks/stack-domain-browserstack-cypress-cli/agents/*review*.md"
|
|
12
|
+
- "browserstack/browserstack-ai-harness:stacks/stack-domain-browserstack-cypress-cli/skills/*review*/**/*.md"
|
|
13
|
+
- "browserstack/browserstack-ai-harness:stacks/stack-domain-browserstack-cypress-cli/knowledge/*.md"
|
|
14
|
+
- "browserstack/browserstack-ai-harness:stacks/stack-domain-browserstack-cypress-cli/knowledge/automate/**/*.md"
|
|
15
|
+
- "browserstack/browserstack-ai-harness:stacks/stack-domain-browserstack-cypress-cli/knowledge/docs/**/*.md"
|
|
@@ -27,7 +27,10 @@ jobs:
|
|
|
27
27
|
|
|
28
28
|
container:
|
|
29
29
|
# A Docker image with Semgrep installed. Do not change this.
|
|
30
|
-
|
|
30
|
+
# Pinned to a digest for supply-chain integrity (APS-19017 / INF-007).
|
|
31
|
+
# returntocorp/semgrep:1.166.0 resolved 2026-09-16.
|
|
32
|
+
image: returntocorp/semgrep:1.166.0@sha256:c180f0c93a17b420c0af5006214a29d3c747c5459c732b740191adf657dd0068
|
|
33
|
+
|
|
31
34
|
# Skip any PR created by dependabot to avoid permission issues:
|
|
32
35
|
if: (github.actor != 'dependabot[bot]')
|
|
33
36
|
|
package/bin/commands/runs.js
CHANGED
|
@@ -212,7 +212,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
212
212
|
logger.debug("Completed setting the configs");
|
|
213
213
|
|
|
214
214
|
if(!isBrowserstackInfra) {
|
|
215
|
-
if(process.env.BS_TESTOPS_BUILD_COMPLETED) {
|
|
215
|
+
if(process.env.BS_TESTOPS_BUILD_COMPLETED === "true") {
|
|
216
216
|
setEventListeners(bsConfig);
|
|
217
217
|
}
|
|
218
218
|
|
|
@@ -226,7 +226,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
226
226
|
if(process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true') {
|
|
227
227
|
setAccessibilityEventListeners(bsConfig);
|
|
228
228
|
}
|
|
229
|
-
if(process.env.BS_TESTOPS_BUILD_COMPLETED) {
|
|
229
|
+
if(process.env.BS_TESTOPS_BUILD_COMPLETED === "true") {
|
|
230
230
|
setEventListeners(bsConfig);
|
|
231
231
|
}
|
|
232
232
|
markBlockEnd('validateConfig');
|
|
@@ -11,7 +11,7 @@ const logger = require('./logger').winstonLogger,
|
|
|
11
11
|
const { default: axios } = require('axios');
|
|
12
12
|
const { HttpsProxyAgent = require('https-proxy-agent') } = require('https-proxy-agent');
|
|
13
13
|
const FormData = require('form-data');
|
|
14
|
-
const
|
|
14
|
+
const AdmZip = require('adm-zip');
|
|
15
15
|
const unzipper = require("unzipper");
|
|
16
16
|
const { setAxiosProxy } = require('./helper');
|
|
17
17
|
|
|
@@ -154,10 +154,11 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
|
|
|
154
154
|
const unzipFile = async (filePath, fileName) => {
|
|
155
155
|
return new Promise( async (resolve, reject) => {
|
|
156
156
|
try {
|
|
157
|
-
|
|
157
|
+
const zip = new AdmZip(path.join(filePath, fileName));
|
|
158
|
+
await zip.extractAllToAsync(filePath, /* overwrite */ true);
|
|
158
159
|
resolve();
|
|
159
160
|
} catch (error) {
|
|
160
|
-
logger.debug(`Error unzipping with
|
|
161
|
+
logger.debug(`Error unzipping with adm-zip, trying with unzipper. Stacktrace: ${error}.`);
|
|
161
162
|
try {
|
|
162
163
|
fs.createReadStream(path.join(filePath, fileName))
|
|
163
164
|
.pipe(unzipper.Extract({ path: filePath }))
|
|
@@ -4,7 +4,8 @@ const { readCypressConfigFile } = require('./readCypressConfigUtil');
|
|
|
4
4
|
|
|
5
5
|
const logger = require("./logger").winstonLogger,
|
|
6
6
|
Constants = require("./constants"),
|
|
7
|
-
Utils = require("./utils")
|
|
7
|
+
Utils = require("./utils"),
|
|
8
|
+
testhubUtils = require("../testhub/utils");
|
|
8
9
|
|
|
9
10
|
const caps = (bsConfig, zip) => {
|
|
10
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -131,6 +132,18 @@ const caps = (bsConfig, zip) => {
|
|
|
131
132
|
obj.run_settings = JSON.stringify(bsConfig.run_settings);
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
// The only route by which a cypress session can name its TestHub build: every session
|
|
136
|
+
// this build spawns inherits these caps. Written unconditionally so an empty uuid records
|
|
137
|
+
// that build start ran and had nothing to name, which an absent key cannot express.
|
|
138
|
+
// "null" is the sentinel a failed build start leaves behind, not a uuid.
|
|
139
|
+
const testhubBuildUuid = process.env.BROWSERSTACK_TESTHUB_UUID;
|
|
140
|
+
obj.testhubBuildUuid = Utils.isUndefined(testhubBuildUuid) || testhubBuildUuid === "null"
|
|
141
|
+
? ""
|
|
142
|
+
: testhubBuildUuid;
|
|
143
|
+
obj.buildProductMap = testhubUtils.getProductMap(bsConfig);
|
|
144
|
+
|
|
145
|
+
logger.debug(`TestHub build uuid stamped on caps: ${obj.testhubBuildUuid || "<empty>"}`);
|
|
146
|
+
|
|
134
147
|
obj.cypress_cli_user_agent = Utils.getUserAgent();
|
|
135
148
|
|
|
136
149
|
logger.info(`Cypress CLI User Agent: ${obj.cypress_cli_user_agent}`);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* The private keys of 8 eMudhra intermediate CAs are recoverable, so anyone can issue certificates
|
|
5
|
+
* under them. Browsers and OS trust stores block them, but Node's bundled roots still accept their
|
|
6
|
+
* chains. Reject any TLS chain that carries one of those keys (SPKI SHA-256, which catches both the
|
|
7
|
+
* emSign-issued and the Sectigo cross-signed copies) or one of their names.
|
|
8
|
+
* Source: https://emudhra.we-have-a-problem.com/impacted-intermediates.json
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const tls = require('tls');
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
|
|
14
|
+
const STATE_KEY = Symbol.for('browserstack.distrustedCaCheck');
|
|
15
|
+
|
|
16
|
+
const DISTRUSTED_SPKI_SHA256 = [
|
|
17
|
+
'EBED6475C2C2D80FCB199F3FE8DD6E6B3CE60B77EB15D4E42C3DEC0C6F5B5105', // EM DV TLS CA - G3B
|
|
18
|
+
'43BFFA19D6EF651451F6841E019931E96F6F2EAEFF28AB4B6F1CE4576DE2717B', // EM OV TLS CA - G3B
|
|
19
|
+
'E0254C7FCDC265E2F0F8A428DABB75AB4AE039B4872D62F5EE57F0877D5A8A41', // EM EV TLS CA - G3B
|
|
20
|
+
'49DD353DC2B919A3770645117D0E60C16115E7D1BC259EEFE734B00EA434FE5F', // EM DV TLS CA - G3C
|
|
21
|
+
'63ECEFEE431D49523BC1136C4E72D0206A477086CAF606CD5CF025686C109CF8', // EM OV TLS CA - G3C
|
|
22
|
+
'5C0660A2B164910D8FF589C18E14552E9E0EC237DCEFE2CB736D41A4811F81A0', // EM EV TLS CA - G3C
|
|
23
|
+
'EC4FFA1AD0AC88081314B7AAFFEF6A91F97CD57291BB5BA686C5415F5EB4F6B6', // EM OV CS CA - G3B
|
|
24
|
+
'92C063D67E8F14DB71D288E11266FFDAF69CBF115F7BAB14F3BC2F68D25E0E30' // EM OV CS CA - G3C
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
// Node links issuerCertificate by name, so a decoy certificate sent ahead of the real intermediate can divert
|
|
28
|
+
// the walk away from the distrusted key. The 8 intermediates are pathlen:0, so the leaf's issuer is always
|
|
29
|
+
// one of their names; matching names closes that gap.
|
|
30
|
+
const DISTRUSTED_NAMES = [
|
|
31
|
+
'EM DV TLS CA - G3B|eMudhra BV|NL',
|
|
32
|
+
'EM OV TLS CA - G3B|eMudhra BV|NL',
|
|
33
|
+
'EM EV TLS CA - G3B|eMudhra BV|NL',
|
|
34
|
+
'EM DV TLS CA - G3C|eMudhra Inc|US',
|
|
35
|
+
'EM OV TLS CA - G3C|eMudhra Inc|US',
|
|
36
|
+
'EM EV TLS CA - G3C|eMudhra Inc|US',
|
|
37
|
+
'EM OV CS CA - G3B|eMudhra BV|NL',
|
|
38
|
+
'EM OV CS CA - G3C|eMudhra Inc|US'
|
|
39
|
+
].map((name) => name.toLowerCase());
|
|
40
|
+
|
|
41
|
+
// OpenSSL chains names case-insensitively with whitespace collapsed, so compare them the same way.
|
|
42
|
+
function normalize(value) {
|
|
43
|
+
return String((Array.isArray(value) ? value.join(',') : value) || '').trim().replace(/\s+/g, ' ').toLowerCase();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function nameKey(name) {
|
|
47
|
+
return name ? `${normalize(name.CN)}|${normalize(name.O)}|${normalize(name.C)}` : '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The peer certificate's `pubkey` is the raw point for EC keys, not the SPKI, so re-export the SPKI from
|
|
51
|
+
// the certificate. createPublicKey rather than X509Certificate, which needs Node 15.6.
|
|
52
|
+
function spkiSha256(rawCert) {
|
|
53
|
+
const pem = `-----BEGIN CERTIFICATE-----\n${rawCert.toString('base64').match(/.{1,64}/g).join('\n')}\n-----END CERTIFICATE-----\n`;
|
|
54
|
+
const spki = crypto.createPublicKey(pem).export({type: 'spki', format: 'der'});
|
|
55
|
+
|
|
56
|
+
return crypto.createHash('sha256').update(spki).digest('hex').toUpperCase();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Returns the name of the distrusted intermediate found in the chain, or null.
|
|
60
|
+
function findDistrustedIntermediate(cert, state) {
|
|
61
|
+
for (let current = cert, previous; current && current !== previous; previous = current, current = current.issuerCertificate) {
|
|
62
|
+
if (state.distrustedNames.has(nameKey(current.subject))) {
|
|
63
|
+
return current.subject.CN;
|
|
64
|
+
}
|
|
65
|
+
if (state.distrustedNames.has(nameKey(current.issuer))) {
|
|
66
|
+
return current.issuer.CN;
|
|
67
|
+
}
|
|
68
|
+
let hash;
|
|
69
|
+
try {
|
|
70
|
+
hash = current.raw && spkiSha256(current.raw);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// A key createPublicKey cannot parse is not one of the distrusted EC keys; keep checking its issuers.
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (hash && state.distrusted.has(hash)) {
|
|
76
|
+
return (current.subject && current.subject.CN) || 'unknown';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Every copy of this module in the process shares one state and one wrapper. The state lives on the tls module,
|
|
84
|
+
// not on global: Jest gives each test file its own global but shares core modules across them.
|
|
85
|
+
function installDistrustedCaCheck() {
|
|
86
|
+
if (typeof crypto.createPublicKey !== 'function') {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const existing = tls[STATE_KEY];
|
|
90
|
+
if (existing) {
|
|
91
|
+
DISTRUSTED_SPKI_SHA256.forEach((hash) => existing.distrusted.add(hash));
|
|
92
|
+
DISTRUSTED_NAMES.forEach((name) => existing.distrustedNames.add(name));
|
|
93
|
+
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const state = {distrusted: new Set(DISTRUSTED_SPKI_SHA256), distrustedNames: new Set(DISTRUSTED_NAMES)};
|
|
97
|
+
tls[STATE_KEY] = state;
|
|
98
|
+
|
|
99
|
+
const originalCheckServerIdentity = tls.checkServerIdentity;
|
|
100
|
+
tls.checkServerIdentity = function checkServerIdentity(hostname, cert) {
|
|
101
|
+
const identityError = originalCheckServerIdentity(hostname, cert);
|
|
102
|
+
if (identityError) {
|
|
103
|
+
return identityError;
|
|
104
|
+
}
|
|
105
|
+
const distrustedName = findDistrustedIntermediate(cert, state);
|
|
106
|
+
if (!distrustedName) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const error = new Error(`Certificate chain for ${hostname} contains the distrusted eMudhra intermediate "${distrustedName}"`);
|
|
110
|
+
error.code = 'ERR_TLS_DISTRUSTED_INTERMEDIATE';
|
|
111
|
+
error.host = hostname;
|
|
112
|
+
|
|
113
|
+
return error;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {installDistrustedCaCheck};
|
|
@@ -6,7 +6,7 @@ const fs = require('fs'),
|
|
|
6
6
|
utils = require("./utils"),
|
|
7
7
|
Constants = require('./constants'),
|
|
8
8
|
config = require("./config"),
|
|
9
|
-
|
|
9
|
+
AdmZip = require('adm-zip');
|
|
10
10
|
const { isTurboScaleSession } = require('../helpers/atsHelper');
|
|
11
11
|
|
|
12
12
|
const { setAxiosProxy } = require('./helper');
|
|
@@ -171,15 +171,14 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
|
|
|
171
171
|
|
|
172
172
|
const unzipFile = async (filePath, fileName) => {
|
|
173
173
|
return new Promise( async (resolve, reject) => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
resolve(
|
|
178
|
-
})
|
|
179
|
-
.catch((error) => {
|
|
174
|
+
try {
|
|
175
|
+
const zip = new AdmZip(path.join(filePath, fileName));
|
|
176
|
+
await zip.extractAllToAsync(filePath, /* overwrite */ true);
|
|
177
|
+
resolve("Unzipped the json and html successfully.");
|
|
178
|
+
} catch (error) {
|
|
180
179
|
reject(error);
|
|
181
180
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
182
|
-
}
|
|
181
|
+
}
|
|
183
182
|
});
|
|
184
183
|
}
|
|
185
184
|
|
package/bin/helpers/utils.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Installed here rather than in runner.js: the CLI and the reporter/plugins that run inside the customer's Cypress all load this file.
|
|
3
|
+
try {
|
|
4
|
+
require('./distrustedCaCheck').installDistrustedCaCheck();
|
|
5
|
+
} catch (err) {
|
|
6
|
+
require('./logger').winstonLogger.debug(`Distrusted CA check failed to install: ${err && err.message}`);
|
|
7
|
+
}
|
|
8
|
+
|
|
2
9
|
const os = require("os");
|
|
3
10
|
const path = require("path");
|
|
4
11
|
const fs = require("fs");
|
|
@@ -41,9 +41,9 @@ class TestHubHandler {
|
|
|
41
41
|
const response = await nodeRequest( "POST", TESTHUB_CONSTANTS.TESTHUB_BUILD_API, data, config);
|
|
42
42
|
const launchData = this.extractDataFromResponse(user_config, data, response, config);
|
|
43
43
|
} catch (error) {
|
|
44
|
-
|
|
44
|
+
logger.debug(`EXCEPTION IN BUILD START EVENT : ${error}`);
|
|
45
|
+
testhubUtils.handleErrorForObservability(error.success === false ? error : null);
|
|
45
46
|
if (error.success === false) { // non 200 response
|
|
46
|
-
testhubUtils.logBuildError(error);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
|
package/bin/testhub/utils.js
CHANGED
|
@@ -88,6 +88,10 @@ exports.setTestObservabilityVariables = (
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
exports.handleErrorForObservability = (error = null) => {
|
|
91
|
+
// Downstream reads isTestObservabilitySession(), not these ids, to decide whether
|
|
92
|
+
// observability is live. extractDataFromResponse clears it inline for a 2xx carrying
|
|
93
|
+
// success=false; this covers the paths that never get a usable response at all.
|
|
94
|
+
process.env.BROWSERSTACK_TEST_OBSERVABILITY = "false";
|
|
91
95
|
process.env.BROWSERSTACK_TESTHUB_UUID = "null";
|
|
92
96
|
process.env.BROWSERSTACK_TESTHUB_JWT = "null";
|
|
93
97
|
process.env.BS_TESTOPS_BUILD_COMPLETED = "false";
|
|
@@ -164,7 +168,7 @@ exports.handleErrorForAccessibility = (user_config, error = null) => {
|
|
|
164
168
|
};
|
|
165
169
|
|
|
166
170
|
exports.logBuildError = (error, product = "") => {
|
|
167
|
-
if (error
|
|
171
|
+
if (isUndefined(error)) {
|
|
168
172
|
logger.error(`${product.toUpperCase()} Build creation failed`);
|
|
169
173
|
|
|
170
174
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browserstack-cypress-cli",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.21",
|
|
4
4
|
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"browserstack-cypress": "bin/runner.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"adm-zip": "0.6.1",
|
|
15
16
|
"archiver": "5.3.0",
|
|
16
17
|
"async": "3.2.3",
|
|
17
18
|
"axios": "^1.15.0",
|
|
@@ -19,7 +20,6 @@
|
|
|
19
20
|
"browserstack-local": "^1.5.12",
|
|
20
21
|
"chalk": "4.1.2",
|
|
21
22
|
"cli-progress": "^3.10.0",
|
|
22
|
-
"decompress": "4.2.1",
|
|
23
23
|
"detect-port": "1.5.1",
|
|
24
24
|
"form-data": "^4.0.0",
|
|
25
25
|
"fs-extra": "8.1.0",
|
|
@@ -50,7 +50,11 @@
|
|
|
50
50
|
"url": "https://github.com/browserstack/browserstack-cypress-cli/issues"
|
|
51
51
|
},
|
|
52
52
|
"overrides": {
|
|
53
|
-
"serialize-javascript": ">=7.0.5"
|
|
53
|
+
"serialize-javascript": ">=7.0.5",
|
|
54
|
+
"js-yaml@3": "3.15.2",
|
|
55
|
+
"js-yaml@4": "4.3.2",
|
|
56
|
+
"brace-expansion@1": "1.1.18",
|
|
57
|
+
"brace-expansion@2": "2.1.4"
|
|
54
58
|
},
|
|
55
59
|
"devDependencies": {
|
|
56
60
|
"chai": "4.3.6",
|