browserstack-cypress-cli 1.36.4 → 1.36.6

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.
@@ -195,6 +195,7 @@ exports.getHostInfo = () => {
195
195
 
196
196
  exports.getCiInfo = () => {
197
197
  var env = process.env;
198
+
198
199
  // Jenkins
199
200
  if ((typeof env.JENKINS_URL === "string" && env.JENKINS_URL.length > 0) || (typeof env.JENKINS_HOME === "string" && env.JENKINS_HOME.length > 0)) {
200
201
  return {
@@ -202,7 +203,7 @@ exports.getCiInfo = () => {
202
203
  build_url: env.BUILD_URL,
203
204
  job_name: env.JOB_NAME,
204
205
  build_number: env.BUILD_NUMBER
205
- }
206
+ };
206
207
  }
207
208
  // CircleCI
208
209
  if (env.CI === "true" && env.CIRCLECI === "true") {
@@ -211,7 +212,7 @@ exports.getCiInfo = () => {
211
212
  build_url: env.CIRCLE_BUILD_URL,
212
213
  job_name: env.CIRCLE_JOB,
213
214
  build_number: env.CIRCLE_BUILD_NUM
214
- }
215
+ };
215
216
  }
216
217
  // Travis CI
217
218
  if (env.CI === "true" && env.TRAVIS === "true") {
@@ -220,7 +221,7 @@ exports.getCiInfo = () => {
220
221
  build_url: env.TRAVIS_BUILD_WEB_URL,
221
222
  job_name: env.TRAVIS_JOB_NAME,
222
223
  build_number: env.TRAVIS_BUILD_NUMBER
223
- }
224
+ };
224
225
  }
225
226
  // Codeship
226
227
  if (env.CI === "true" && env.CI_NAME === "codeship") {
@@ -229,7 +230,7 @@ exports.getCiInfo = () => {
229
230
  build_url: null,
230
231
  job_name: null,
231
232
  build_number: null
232
- }
233
+ };
233
234
  }
234
235
  // Bitbucket
235
236
  if (env.BITBUCKET_BRANCH && env.BITBUCKET_COMMIT) {
@@ -238,7 +239,7 @@ exports.getCiInfo = () => {
238
239
  build_url: env.BITBUCKET_GIT_HTTP_ORIGIN,
239
240
  job_name: null,
240
241
  build_number: env.BITBUCKET_BUILD_NUMBER
241
- }
242
+ };
242
243
  }
243
244
  // Drone
244
245
  if (env.CI === "true" && env.DRONE === "true") {
@@ -247,7 +248,7 @@ exports.getCiInfo = () => {
247
248
  build_url: env.DRONE_BUILD_LINK,
248
249
  job_name: null,
249
250
  build_number: env.DRONE_BUILD_NUMBER
250
- }
251
+ };
251
252
  }
252
253
  // Semaphore
253
254
  if (env.CI === "true" && env.SEMAPHORE === "true") {
@@ -256,7 +257,7 @@ exports.getCiInfo = () => {
256
257
  build_url: env.SEMAPHORE_ORGANIZATION_URL,
257
258
  job_name: env.SEMAPHORE_JOB_NAME,
258
259
  build_number: env.SEMAPHORE_JOB_ID
259
- }
260
+ };
260
261
  }
261
262
  // GitLab
262
263
  if (env.CI === "true" && env.GITLAB_CI === "true") {
@@ -265,7 +266,16 @@ exports.getCiInfo = () => {
265
266
  build_url: env.CI_JOB_URL,
266
267
  job_name: env.CI_JOB_NAME,
267
268
  build_number: env.CI_JOB_ID
268
- }
269
+ };
270
+ }
271
+ // GitHub Actions
272
+ if (env.GITHUB_ACTIONS === "true" || env.CI === "true" && env.GITHUB_RUN_ID) {
273
+ return {
274
+ name: "GitHub Actions",
275
+ build_url: `${env.GITHUB_SERVER_URL || 'https://github.com'}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}`,
276
+ job_name: env.GITHUB_WORKFLOW || env.GITHUB_JOB,
277
+ build_number: env.GITHUB_RUN_NUMBER
278
+ };
269
279
  }
270
280
  // Buildkite
271
281
  if (env.CI === "true" && env.BUILDKITE === "true") {
@@ -274,7 +284,7 @@ exports.getCiInfo = () => {
274
284
  build_url: env.BUILDKITE_BUILD_URL,
275
285
  job_name: env.BUILDKITE_LABEL || env.BUILDKITE_PIPELINE_NAME,
276
286
  build_number: env.BUILDKITE_BUILD_NUMBER
277
- }
287
+ };
278
288
  }
279
289
  // Visual Studio Team Services
280
290
  if (env.TF_BUILD === "True") {
@@ -283,7 +293,7 @@ exports.getCiInfo = () => {
283
293
  build_url: `${env.SYSTEM_TEAMFOUNDATIONSERVERURI}${env.SYSTEM_TEAMPROJECTID}`,
284
294
  job_name: env.SYSTEM_DEFINITIONID,
285
295
  build_number: env.BUILD_BUILDID
286
- }
296
+ };
287
297
  }
288
298
  // if no matches, return null
289
299
  return null;
@@ -8,6 +8,26 @@ const constants = require("./constants");
8
8
  const utils = require("./utils");
9
9
  const logger = require('./logger').winstonLogger;
10
10
 
11
+ // Defense-in-depth: reject file paths containing shell metacharacters.
12
+ // This guards against command injection even if execFileSync is ever
13
+ // replaced with a shell-based exec in the future.
14
+ //
15
+ // Note: backslash (\) is intentionally NOT included here because it is a
16
+ // legitimate path separator on Windows (e.g. C:\Users\me\cypress.config.js).
17
+ // The actual security boundary is execFileSync (no shell), not this regex.
18
+ const DANGEROUS_PATH_CHARS = /[;"`$|&(){}]/;
19
+
20
+ function validateFilePath(filepath) {
21
+ if (DANGEROUS_PATH_CHARS.test(filepath)) {
22
+ throw new Error(
23
+ `Invalid cypress config file path: "${filepath}" contains disallowed characters. ` +
24
+ 'File paths must not include shell metacharacters such as ; " ` $ | & ( ) { }'
25
+ );
26
+ }
27
+ }
28
+
29
+ exports.validateFilePath = validateFilePath;
30
+
11
31
  exports.detectLanguage = (cypress_config_filename) => {
12
32
  const extension = cypress_config_filename.split('.').pop()
13
33
  return constants.CYPRESS_V10_AND_ABOVE_CONFIG_FILE_EXTENSIONS.includes(extension) ? extension : 'js'
@@ -186,13 +206,29 @@ exports.convertTsConfig = (bsConfig, cypress_config_filepath, bstack_node_module
186
206
  }
187
207
 
188
208
  exports.loadJsFile = (cypress_config_filepath, bstack_node_modules_path) => {
189
- const require_module_helper_path = path.join(__dirname, 'requireModule.js')
190
- let load_command = `NODE_PATH="${bstack_node_modules_path}" node "${require_module_helper_path}" "${cypress_config_filepath}"`
191
- if (/^win/.test(process.platform)) {
192
- load_command = `set NODE_PATH=${bstack_node_modules_path}&& node "${require_module_helper_path}" "${cypress_config_filepath}"`
209
+ // Security: validate file path to reject shell metacharacters (defense-in-depth)
210
+ validateFilePath(cypress_config_filepath);
211
+
212
+ // UX: surface a clear error if the cypress config file is missing.
213
+ // (This is purely a UX check — the security boundary is execFileSync above
214
+ // plus the metacharacter regex; existsSync alone would NOT prevent injection.)
215
+ if (!fs.existsSync(cypress_config_filepath)) {
216
+ throw new Error(`Cypress config file not found at: ${cypress_config_filepath}`);
193
217
  }
194
- logger.debug(`Running: ${load_command}`)
195
- cp.execSync(load_command)
218
+
219
+ const require_module_helper_path = path.join(__dirname, 'requireModule.js')
220
+
221
+ // Security fix: use execFileSync instead of execSync to avoid shell interpolation.
222
+ // execFileSync spawns the process directly without a shell, so user-controlled
223
+ // values in cypress_config_filepath cannot break out into shell commands.
224
+ const execOptions = {
225
+ env: Object.assign({}, process.env, { NODE_PATH: bstack_node_modules_path })
226
+ };
227
+ const args = [require_module_helper_path, cypress_config_filepath];
228
+
229
+ logger.debug(`Running: node ${args.map(a => '"' + a + '"').join(' ')} (via execFileSync, NODE_PATH=${bstack_node_modules_path})`);
230
+ cp.execFileSync('node', args, execOptions);
231
+
196
232
  const cypress_config = JSON.parse(fs.readFileSync(config.configJsonFileName).toString())
197
233
  if (fs.existsSync(config.configJsonFileName)) {
198
234
  fs.unlinkSync(config.configJsonFileName)
@@ -160,6 +160,10 @@ function ci_environment() {
160
160
  if (env.CI === "true" && env.GITLAB_CI === "true") {
161
161
  return "GitLab";
162
162
  }
163
+ // GitHub Actions
164
+ if (env.GITHUB_ACTIONS === "true" || (env.CI === "true" && env.GITHUB_RUN_ID)) {
165
+ return "GitHub Actions";
166
+ }
163
167
  // Buildkite
164
168
  if (env.CI === "true" && env.BUILDKITE === "true") {
165
169
  return "Buildkite";
@@ -201,24 +201,30 @@ Cypress.on('command:end', (command) => {
201
201
  });
202
202
  });
203
203
 
204
- Cypress.Commands.overwrite('log', (originalFn, ...args) => {
204
+ Cypress.on('command:enqueued', (attrs) => {
205
+ if (!Cypress.env('BROWSERSTACK_O11Y_LOGS')) return;
206
+ if (!attrs || attrs.name !== 'log') return;
207
+ const args = attrs.args || [];
205
208
  if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
206
209
  const message = args.reduce((result, logItem) => {
207
210
  if (typeof logItem === 'object') {
208
211
  return [result, JSON.stringify(logItem)].join(' ');
209
212
  }
210
-
211
213
  return [result, logItem ? logItem.toString() : ''].join(' ');
212
214
  }, '');
213
215
  eventsQueue.push({
214
216
  task: 'test_observability_log',
215
217
  data: {
216
- 'level': 'info',
218
+ level: 'info',
217
219
  message,
218
220
  timestamp: new Date().toISOString()
219
221
  },
220
222
  options: { log: false }
221
223
  });
224
+ });
225
+
226
+ Cypress.Commands.overwrite('log', (originalFn, ...args) => {
227
+ if (args.includes('test_observability_log') || args.includes('test_observability_command')) return;
222
228
  originalFn(...args);
223
229
  });
224
230
 
@@ -407,6 +407,7 @@ exports.launchTestSession = async (user_config, bsConfigPath) => {
407
407
  sdkVersion: helper.getAgentVersion()
408
408
  }
409
409
  };
410
+
410
411
  const config = {
411
412
  auth: {
412
413
  username: obsUserName,
@@ -631,7 +631,9 @@ class MyReporter {
631
631
  if(this.current_hook && ( this.current_hook.hookAnalyticsId && !this.runStatusMarkedHash[this.current_hook.hookAnalyticsId] )) {
632
632
  log.hook_run_uuid = this.current_hook.hookAnalyticsId;
633
633
  }
634
- if(!log.hook_run_uuid && this.current_test && ( this.current_test.testAnalyticsId && !this.runStatusMarkedHash[this.current_test.testAnalyticsId] )) log.test_run_uuid = this.current_test.testAnalyticsId;
634
+ if(!log.hook_run_uuid && this.current_test && this.current_test.testAnalyticsId) {
635
+ log.test_run_uuid = this.current_test.testAnalyticsId;
636
+ }
635
637
  if(log.hook_run_uuid || log.test_run_uuid) {
636
638
  await uploadEventData({
637
639
  event_type: 'LogCreated',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.36.4",
3
+ "version": "1.36.6",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "archiver": "5.3.0",
16
16
  "async": "3.2.3",
17
- "axios": "^1.7.7",
17
+ "axios": "^1.15.0",
18
18
  "axios-retry": "^3.5.0",
19
19
  "browserstack-local": "^1.5.12",
20
20
  "chalk": "4.1.2",