Skip to content

Commit

Permalink
send specs details and don't call build artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
nagpalkaran95 committed Dec 8, 2023
1 parent 0ca8b1a commit 8ca4324
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
17 changes: 6 additions & 11 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = function run(args, rawArgs) {
// accept the access key from command line or env variable if provided
utils.setAccessKey(bsConfig, args);

let buildReportData = !isBrowserstackInfra ? null : await getInitialDetails(bsConfig, args, rawArgs);
let buildReportData = (turboScaleSession || !isBrowserstackInfra) ? null : await getInitialDetails(bsConfig, args, rawArgs);

// accept the build name from command line if provided
utils.setBuildName(bsConfig, args);
Expand Down Expand Up @@ -158,11 +158,6 @@ module.exports = function run(args, rawArgs) {

if (gridDetails && Object.keys(gridDetails).length > 0) {
Constants.turboScaleObj.gridDetails = gridDetails;

if (gridDetails.isTrialGrid) {
logger.info('Will be running the build on Trial Grid. Ensure you are using connect-grid command if using a private website');
}

Constants.turboScaleObj.gridUrl = gridDetails.cypressUrl;
Constants.turboScaleObj.uploadUrl = gridDetails.cypressUrl + '/upload';
Constants.turboScaleObj.buildUrl = gridDetails.cypressUrl + '/build';
Expand Down Expand Up @@ -212,7 +207,7 @@ module.exports = function run(args, rawArgs) {

//get the number of spec files
markBlockStart('getNumberOfSpecFiles');
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile);
let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressConfigFile, turboScaleSession);
markBlockEnd('getNumberOfSpecFiles');

bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressConfigFile);
Expand Down Expand Up @@ -325,13 +320,13 @@ module.exports = function run(args, rawArgs) {
logger.debug("Completed polling of build status");

// stop the Local instance
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);
if (!turboScaleSession) await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs, buildReportData);

// waiting for 5 secs for upload to complete (as a safety measure)
await new Promise(resolve => setTimeout(resolve, 5000));

// download build artifacts
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE && !turboScaleSession) {
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
logger.debug("Downloading build artifacts");
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs, buildReportData);
Expand All @@ -343,7 +338,7 @@ module.exports = function run(args, rawArgs) {
markBlockEnd('postBuild');
utils.handleSyncExit(exitCode, data.dashboard_url);
});
} else {
} else if(!turboScaleSession){
let stacktraceUrl = getStackTraceUrl();
downloadBuildStacktrace(stacktraceUrl).then((message) => {
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
Expand All @@ -359,7 +354,7 @@ module.exports = function run(args, rawArgs) {
});
}
});
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads && !turboScaleSession)) {
logger.info(Constants.userMessages.ASYNC_DOWNLOADS.replace('<build-id>', data.build_id));
}

Expand Down
9 changes: 8 additions & 1 deletion bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
return ignoreFiles;
}

exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig, turboScaleSession=false) => {
let defaultSpecFolder
let testFolderPath
let globCypressConfigSpecPatterns = []
Expand Down Expand Up @@ -1147,6 +1147,13 @@ exports.getNumberOfSpecFiles = (bsConfig, args, cypressConfig) => {
}

logger.debug(`${files ? files.length : 0} spec files found`);

if (turboScaleSession) {
// remove unwanted path prefix for turboscale
files = files.map((x) => { return path.join(testFolderPath, x.split(testFolderPath)[1]) })

Check warning

Code scanning / Semgrep

Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal Warning

Detected possible user input going into a path.join or path.resolve function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.

Check warning

Code scanning / Semgrep

Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal Warning

Detected possible user input going into a path.join or path.resolve function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.
// setting specs for turboScale as we don't have patched API for turboscale so we will rely on info from CLI
bsConfig.run_settings.specs = files;
}
return files;
};

Expand Down

0 comments on commit 8ca4324

Please sign in to comment.