From aa4459e2b5ac74487ea153cfb60f9ae1b5e030bc Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Wed, 27 Sep 2023 05:15:55 +0400 Subject: [PATCH 01/12] Update err handling --- make-util.js | 62 ++++++++++++++++++++++++++++++---------------------- make.js | 33 ++++++++++++++-------------- 2 files changed, 52 insertions(+), 43 deletions(-) diff --git a/make-util.js b/make-util.js index 9f49a24f5a06..d55c10610b51 100644 --- a/make-util.js +++ b/make-util.js @@ -14,6 +14,8 @@ var syncRequest = require('sync-request'); var repoPath = __dirname; var downloadPath = path.join(repoPath, '_download'); +const isNoColor = process.env['NO_COLOR'] ? process.env['NO_COLOR'].toLowerCase() == 'true' : false; + // list of .NET culture names var cultureNames = ['cs', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'pl', 'pt-BR', 'ru', 'tr', 'zh-Hans', 'zh-Hant']; @@ -109,8 +111,7 @@ var rp = function (relPath) { exports.rp = rp; var fail = function (message) { - console.error('ERROR: ' + message); - process.exit(1); + throw Error(message); } exports.fail = fail; @@ -129,6 +130,22 @@ var pathExists = function (checkPath) { } exports.pathExists = pathExists; +function log(message, type) { + switch (type) { + case 'error': + case 'err': + if (!isNoColor) { + message = '\x1b[31m' + message + '\x1b[0m'; + } + console.error(message); + break; + + default: + console.log(message); + } +} +exports.log = log; + /** * Given a module path, gets the info used for generating a pack file */ @@ -297,10 +314,10 @@ var run = function (cl, inheritStreams, noHeader) { } catch (err) { if (!inheritStreams) { - console.error(err.output ? err.output.toString() : err.message); + log(err.output ? err.output.toString() : err.message, 'error'); } - process.exit(1); + fail(err); } return (output || '').toString().trim(); @@ -331,28 +348,21 @@ var ensureTool = function (name, versionArgs, validate) { exports.ensureTool = ensureTool; var installNode = function (nodeVersion) { - switch (nodeVersion || '') { - case '20': - nodeVersion = 'v20.3.1'; - break; - case '16': - nodeVersion = 'v16.17.1'; - break; - case '14': - nodeVersion = 'v14.10.1'; - break; - case '10': - nodeVersion = 'v10.24.1'; - break; - case '6': - case '': - nodeVersion = 'v6.10.3'; - break; - case '5': - nodeVersion = 'v5.10.1'; - break; - default: - fail(`Unexpected node version '${nodeVersion}'. Supported versions: 5, 6, 10, 14, 16, 20`); + if (!nodeVersion) { + nodeVersion = 'v6.10.3'; + } else { + const versions = { + 20: 'v20.3.1', + 16: 'v16.17.1', + 14: 'v14.10.1', + 10: 'v10.24.1', + 6: 'v6.10.3', + 5: 'v5.10.1', + }; + if (!versions[nodeVersion]) { + fail(`Unexpected node version '${nodeVersion}'. Supported versions: ${Object.keys(versions).join(', ')}`); + }; + nodeVersion = versions[nodeVersion]; } if (nodeVersion === run('node -v')) { diff --git a/make.js b/make.js index 35dae645fa34..4f9837b8993b 100644 --- a/make.js +++ b/make.js @@ -60,6 +60,11 @@ var genTaskCommonPath = path.join(__dirname, '_generated', 'Common'); var CLI = {}; +process.on('uncaughtException', err => { + util.log(err, 'err'); + process.exit(1); +}) + // node min version var minNodeVer = '6.10.3'; if (semver.lt(process.versions.node, minNodeVer)) { @@ -513,24 +518,18 @@ CLI.test = function(/** @type {{ suite: string; node: string; task: string }} */ } nodeVersions.forEach(function (nodeVersion) { - try { - nodeVersion = String(nodeVersion); - banner('Run Mocha Suits for node ' + nodeVersion); - // setup the version of node to run the tests - util.installNode(nodeVersion); - + nodeVersion = String(nodeVersion); + banner('Run Mocha Suits for node ' + nodeVersion); + // setup the version of node to run the tests + util.installNode(nodeVersion); - if (isNodeTask && !isReportWasFormed && nodeVersion >= 10) { - run('nyc --all -n ' + taskPath + ' --report-dir ' + coverageTasksPath + ' mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); - util.renameCodeCoverageOutput(coverageTasksPath, taskName); - isReportWasFormed = true; - } - else { - run('mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); - } - } catch (e) { - console.error(e); - process.exit(1); + if (isNodeTask && !isReportWasFormed && nodeVersion >= 10) { + run('nyc --all -n ' + taskPath + ' --report-dir ' + coverageTasksPath + ' mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); + util.renameCodeCoverageOutput(coverageTasksPath, taskName); + isReportWasFormed = true; + } + else { + run('mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); } }); } From f7b39683bf821ae1e7f762e8323426cb7f172fd0 Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Wed, 27 Sep 2023 19:35:14 +0400 Subject: [PATCH 02/12] Fix sanitizer regex + remove extra regex call --- Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 b/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 index b24c43d8ad2b..829448ef28b3 100644 --- a/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 +++ b/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 @@ -60,7 +60,7 @@ function Get-SanitizedArguments([string]$inputArgs) { # regex rule for removing symbols and telemetry. # '? Date: Wed, 27 Sep 2023 19:38:00 +0400 Subject: [PATCH 03/12] Update tests --- Tasks/Common/Sanitizer/Tests/L0.ts | 2 +- ...anitizedArgumentsArray.DoesNotBreakExistingBashFormats.ps1 | 4 ++-- ...SanitizedArgumentsArray.DoesNotBreakExistingCmdFormats.ps1 | 2 +- ...edArgumentsArray.DoesNotBreakExistingPowerShellFormats.ps1 | 2 +- ...et-SanitizedArgumentsArray.ReplacesForbiddenCharacters.ps1 | 4 ++-- Tasks/Common/Sanitizer/Tests/L0Split-Arguments.ps1 | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Tasks/Common/Sanitizer/Tests/L0.ts b/Tasks/Common/Sanitizer/Tests/L0.ts index 194fdf836a7c..0022d3dcf45a 100644 --- a/Tasks/Common/Sanitizer/Tests/L0.ts +++ b/Tasks/Common/Sanitizer/Tests/L0.ts @@ -6,7 +6,7 @@ import Q = require('q'); import assert = require('assert'); import path = require('path'); -var psm = require('../../../Tests/lib/psRunner'); +var psm = require('../../../../Tests/lib/psRunner'); var psr = null; describe('Security Suite', function () { diff --git a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingBashFormats.ps1 b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingBashFormats.ps1 index 01af752bc279..76bdd2bd0523 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingBashFormats.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingBashFormats.ps1 @@ -21,5 +21,5 @@ foreach ($argument in $bashArgumentsFormats) { $sanitizedArguments = Get-SanitizedArguments -InputArgs $argument # Assert - Assert-AreEqual $sanitizedArguments $argument -} \ No newline at end of file + Assert-AreEqual -Actual $sanitizedArguments -Expected $argument +} diff --git a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingCmdFormats.ps1 b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingCmdFormats.ps1 index 070d9568ac1d..5ff8bccecb54 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingCmdFormats.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingCmdFormats.ps1 @@ -20,5 +20,5 @@ foreach ($argument in $cmdArgumentsFormats) { $sanitizedArguments = Get-SanitizedArguments -InputArgs $argument # Assert - Assert-AreEqual $sanitizedArguments $argument + Assert-AreEqual -Actual $sanitizedArguments -Expected $argument } \ No newline at end of file diff --git a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingPowerShellFormats.ps1 b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingPowerShellFormats.ps1 index 22cdef70006f..5c7f2a783e19 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingPowerShellFormats.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.DoesNotBreakExistingPowerShellFormats.ps1 @@ -21,5 +21,5 @@ foreach ($argument in $powershellArgumentsFormats) { $sanitizedArguments = Get-SanitizedArguments -InputArgs $argument # Assert - Assert-AreEqual $sanitizedArguments $argument + Assert-AreEqual -Actual $sanitizedArguments -Expected $argument } \ No newline at end of file diff --git a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.ReplacesForbiddenCharacters.ps1 b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.ReplacesForbiddenCharacters.ps1 index a71fe62afd93..214311c898a9 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.ReplacesForbiddenCharacters.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Get-SanitizedArgumentsArray.ReplacesForbiddenCharacters.ps1 @@ -14,5 +14,5 @@ $sanitizedArguments = Get-SanitizedArguments -InputArgs $arguments # Assert -# We need to use $sanitizedArguments[1] because $sanitizedArguments contains buffer with Write-Output message from the function execution. -Assert-AreEqual $sanitizedArguments[1] "start notepad.exe _#removed#_ echo 'hello' _#removed#_ calc.exe" \ No newline at end of file +# We need to use $sanitizedArguments[1] because $sanitizedArguments contains buffer with Write-Output message from the function execution. +Assert-AreEqual -Expected "start notepad.exe _#removed#_ echo 'hello' _#removed#_ calc.exe" -Actual $sanitizedArguments diff --git a/Tasks/Common/Sanitizer/Tests/L0Split-Arguments.ps1 b/Tasks/Common/Sanitizer/Tests/L0Split-Arguments.ps1 index 3a4f829057f6..9a4f45a7db2d 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Split-Arguments.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Split-Arguments.ps1 @@ -33,5 +33,5 @@ for ($i = 0; $i -lt $argumentsFormats.Length; $i++) { [string[]]$splitArguments = Split-Arguments -arguments $argumentsFormats[$i] # Assert - Assert-AreEqual $splitArguments $expectedOutputs[$i] -} \ No newline at end of file + Assert-AreEqual -Expected $splitArguments -Actual $expectedOutputs[$i] +} From 528163ead32ce75f7a98ee2d3806a20686bf057e Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Wed, 27 Sep 2023 22:24:51 +0400 Subject: [PATCH 04/12] Add tests --- Tasks/Common/Sanitizer/Tests/L0.ts | 17 +++-- .../L0Protect-ScriptArguments.Passes.ps1 | 40 +++++++++++ .../L0Protect-ScriptArguments.Throws.ps1 | 21 ++++++ Tasks/Common/Sanitizer/runTests.ps1 | 12 ++++ make.js | 69 +++++++++++++++++-- 5 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 create mode 100644 Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 create mode 100644 Tasks/Common/Sanitizer/runTests.ps1 diff --git a/Tasks/Common/Sanitizer/Tests/L0.ts b/Tasks/Common/Sanitizer/Tests/L0.ts index 0022d3dcf45a..a770c846853e 100644 --- a/Tasks/Common/Sanitizer/Tests/L0.ts +++ b/Tasks/Common/Sanitizer/Tests/L0.ts @@ -1,9 +1,6 @@ /// /// -/// -import Q = require('q'); -import assert = require('assert'); import path = require('path'); var psm = require('../../../../Tests/lib/psRunner'); @@ -49,4 +46,16 @@ describe('Security Suite', function () { psr.run(path.join(__dirname, 'L0Get-SanitizedArgumentsArray.DoesNotBreakExistingBashFormats.ps1'), done); }); } -}); \ No newline at end of file + + if (psm.testSupported()) { + it('Protect-ScriptArguments should pass correctly', (done) => { + psr.run(path.join(__dirname, 'L0Protect-ScriptArguments.Passes.ps1'), done); + }); + } + + if (psm.testSupported()) { + it('Protect-ScriptArguments should throw', (done) => { + psr.run(path.join(__dirname, 'L0Protect-ScriptArguments.Throws.ps1'), done); + }); + } +}); diff --git a/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 new file mode 100644 index 000000000000..62df9c057b98 --- /dev/null +++ b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 @@ -0,0 +1,40 @@ +[CmdletBinding()] +param() + +Set-Item -Path env:AZP_75787_ENABLE_NEW_LOGIC -Value 'true' + +. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 +. $PSScriptRoot\..\ArgumentsSanitizer.ps1 + +$inputArgsSuites = @( + "/parameter", # Traditional way to pass parameters in CMD + "-parameter", # Modern applications accept parameters with a hyphen + "--parameter", # Many modern applications accept parameters with double hyphen + "parameter=value", # Format for passing values to parameters + "parameter value.txt", # Argument with dot in the middle + "-parameter", # Single hyphen followed by a single letter or digit (POSIX style) + "-parameter value", # When the parameter needs a value + "--parameter", # Double hyphen followed by a word (GNU style) + "--parameter=value", # Value directly attached to the parameter with an equals sign + "parameter=value", # Used to pass environment variables to a command + "parameter value.txt", # Argument with dot in the middle + "-Parameter Value", # Most common form + "-Parameter:Value", # Colon connects the parameter and its value + "/p:Parameter=Value", # Specific syntax for tools like MSBuild or NuGet + "--Parameter Value", # Used by cmdlets or scripts for cross-platform compatibility + "--Parameter=Value", # Used by cross-platform tools + "parameter value.txt" # Argument with dot in the middle + 'a A 1 \ ` _ '' " - = / : . * , + ~ ? %', # Just each allowed symbol + '', + 'test 1', + 'test `; whoami `&`& echo test' +) + +foreach ($inputArgs in $inputArgsSuites) { + try { + Protect-ScriptArguments $inputArgs + } + catch { + throw "Error occured with '$inputArgs' input args: $($_.Exception.Message)" + } +} diff --git a/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 new file mode 100644 index 000000000000..74774fcda282 --- /dev/null +++ b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 @@ -0,0 +1,21 @@ +[CmdletBinding()] +param() + +Set-Item -Path env:AZP_75787_ENABLE_NEW_LOGIC -Value 'true' + +. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 +. $PSScriptRoot\..\ArgumentsSanitizer.ps1 + +$inputArgsSuites = @( + 'test; whoami', + 'test && whoami', + 'echo "$(rm ./somedir)"' +) + +$expectedMsg = Get-VstsLocString -Key 'PS_ScriptArgsSanitized' + +foreach ($inputArgs in $inputArgsSuites) { + Assert-Throws { + Protect-ScriptArguments $inputArgs + } -MessagePattern $expectedMsg +} diff --git a/Tasks/Common/Sanitizer/runTests.ps1 b/Tasks/Common/Sanitizer/runTests.ps1 new file mode 100644 index 000000000000..869fccf8eb3e --- /dev/null +++ b/Tasks/Common/Sanitizer/runTests.ps1 @@ -0,0 +1,12 @@ +$startLoc = Get-Location + +Set-Location $PSScriptRoot/../../.. + +try { + Remove-Item .\_build\Tasks\Common\Sanitizer -Recurse -Force -ErrorAction SilentlyContinue + node make build --task AzureFileCopyV5 + node make test --task Common/Sanitizer +} +finally { + Set-Location $startLoc +} diff --git a/make.js b/make.js index 4f9837b8993b..196988ad547e 100644 --- a/make.js +++ b/make.js @@ -57,6 +57,7 @@ var coverageTasksPath = path.join(buildPath, 'coverage'); var baseConfigToolPath = path.join(__dirname, 'BuildConfigGen'); var genTaskPath = path.join(__dirname, '_generated'); var genTaskCommonPath = path.join(__dirname, '_generated', 'Common'); +var rootTsConfigPath = path.join(__dirname, 'tsconfig.json'); var CLI = {}; @@ -99,8 +100,9 @@ if (argv.task) { }); } - if (!taskList.length) { - fail('Unable to find any tasks matching pattern ' + argv.task); + // 'Common/' needs to allow to run tests for common modules separately. + if (!taskList.length && !argv.task.startsWith('Common/')) { + fail(`Unable to find any tasks matching pattern '${argv.task}'`); } } else { // load the default list @@ -544,9 +546,28 @@ CLI.test = function(/** @type {{ suite: string; node: string; task: string }} */ } }); - if (!argv.task) { + if (!argv.task || argv.task.startsWith('Common')) { + var commonBuildPath = path.join(buildTasksPath, 'Common'); + var commonLibPattern = path.join(commonBuildPath, '*', 'Tests', suiteType + '.js'); + if (argv.task.startsWith('Common/')) { + var commonModuleName = argv.task.split('/')[1]; + var commonModuleBuildPath = path.join(buildTasksPath, 'Common', commonModuleName); + if (fs.existsSync(commonModuleBuildPath)){ + commonLibPattern = path.join(commonModuleBuildPath, 'Tests', suiteType + '.js'); + } else { + util.log(`Common module ${commonModuleName} does not exist. Skipping it.`); + } + } + banner('Pre-duilding L0.ts files'); + cp('-f', rootTsConfigPath, commonBuildPath); + try { + run(`tsc -p "${commonBuildPath}"`); + } + catch (e) { + console.log('Error while prebuilding L0.ts common tests files. Skipping them temporarily.') + } + banner('Running common library tests'); - var commonLibPattern = path.join(buildTasksPath, 'Common', '*', 'Tests', suiteType + '.js'); var specs = []; if (matchFind(commonLibPattern, buildTasksPath).length > 0) { specs.push(commonLibPattern); @@ -1056,3 +1077,43 @@ if (typeof CLI[command] !== 'function') { } CLI[command](argv); + +function buildCommonModules() { + var commonsPath = path.join(tasksPath, 'Common'); + var modOutDir = path.join(buildTasksCommonPath, modName); + + var commonModules = fs.readdirSync(commonsPath); + + rm('-Rf', modOutDir); + mkdir('-p', modOutDir); + + for (const cmod of commonModules) { + const modPath = path.join(commonsPath, cmod); + cp('-Rf', path.join(modPath), modOutDir); + + // create loc files + var modJsonPath = path.join(modPath, 'module.json'); + if (test('-f', modJsonPath)) { + createResjson(fileToJson(modJsonPath), modPath); + } + + if (cmod === 'coveragepublisher') { + buildNodeTask(modPath, modOutDir); + } + + + // copy default resources and any additional resources defined in the module's make.json + util.log(); + util.log('> copying module resources'); + const modMakePath = path.join(modPath, 'make.json'); + const modMake = test('-f', modMakePath) ? fileToJson(modMakePath) : {}; + copyTaskResources(modMake, modPath, modOutDir); + + util.log('get externals'); + if (modMake.hasOwnProperty('externals')) { + util.log(''); + util.log('> getting module externals'); + getExternals(modMake.externals, modOutDir); + } + } +} From 633cbe6870bbc6f09e9769606aa4a68faafe364f Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Wed, 27 Sep 2023 22:39:50 +0400 Subject: [PATCH 05/12] Bump tasks versions --- Tasks/AzureFileCopyV1/task.json | 4 ++-- Tasks/AzureFileCopyV1/task.loc.json | 4 ++-- Tasks/AzureFileCopyV2/task.json | 4 ++-- Tasks/AzureFileCopyV2/task.loc.json | 4 ++-- Tasks/AzureFileCopyV3/task.json | 4 ++-- Tasks/AzureFileCopyV3/task.loc.json | 4 ++-- Tasks/AzureFileCopyV4/task.json | 4 ++-- Tasks/AzureFileCopyV4/task.loc.json | 4 ++-- Tasks/AzureFileCopyV5/task.json | 4 ++-- Tasks/AzureFileCopyV5/task.loc.json | 4 ++-- Tasks/WindowsMachineFileCopyV1/task.json | 4 ++-- Tasks/WindowsMachineFileCopyV1/task.loc.json | 4 ++-- Tasks/WindowsMachineFileCopyV2/task.json | 4 ++-- Tasks/WindowsMachineFileCopyV2/task.loc.json | 4 ++-- _generated/AzureFileCopyV2.versionmap.txt | 4 ++-- _generated/AzureFileCopyV2/task.json | 8 ++++---- _generated/AzureFileCopyV2/task.loc.json | 8 ++++---- _generated/AzureFileCopyV2_Node16/task.json | 8 ++++---- _generated/AzureFileCopyV2_Node16/task.loc.json | 8 ++++---- _generated/AzureFileCopyV3.versionmap.txt | 4 ++-- _generated/AzureFileCopyV3/task.json | 8 ++++---- _generated/AzureFileCopyV3/task.loc.json | 8 ++++---- _generated/AzureFileCopyV3_Node16/task.json | 8 ++++---- _generated/AzureFileCopyV3_Node16/task.loc.json | 8 ++++---- 24 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Tasks/AzureFileCopyV1/task.json b/Tasks/AzureFileCopyV1/task.json index 9bb56cbdfe83..595c8c59b5c3 100644 --- a/Tasks/AzureFileCopyV1/task.json +++ b/Tasks/AzureFileCopyV1/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV1/task.loc.json b/Tasks/AzureFileCopyV1/task.loc.json index a4d630058ba9..73b961a715bd 100644 --- a/Tasks/AzureFileCopyV1/task.loc.json +++ b/Tasks/AzureFileCopyV1/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV2/task.json b/Tasks/AzureFileCopyV2/task.json index 47c6e36df442..a5b4bebafbca 100644 --- a/Tasks/AzureFileCopyV2/task.json +++ b/Tasks/AzureFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV2/task.loc.json b/Tasks/AzureFileCopyV2/task.loc.json index b696bf87b1e6..91151f606b03 100644 --- a/Tasks/AzureFileCopyV2/task.loc.json +++ b/Tasks/AzureFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV3/task.json b/Tasks/AzureFileCopyV3/task.json index fb7f3d74624f..a8ec7031a4b2 100644 --- a/Tasks/AzureFileCopyV3/task.json +++ b/Tasks/AzureFileCopyV3/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV3/task.loc.json b/Tasks/AzureFileCopyV3/task.loc.json index ead8e26c59fe..2ecbb68aa959 100644 --- a/Tasks/AzureFileCopyV3/task.loc.json +++ b/Tasks/AzureFileCopyV3/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV4/task.json b/Tasks/AzureFileCopyV4/task.json index 386d286b229b..cbd3cade94ef 100644 --- a/Tasks/AzureFileCopyV4/task.json +++ b/Tasks/AzureFileCopyV4/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV4/task.loc.json b/Tasks/AzureFileCopyV4/task.loc.json index e72473ee44af..71d7251afdee 100644 --- a/Tasks/AzureFileCopyV4/task.loc.json +++ b/Tasks/AzureFileCopyV4/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV5/task.json b/Tasks/AzureFileCopyV5/task.json index 859c80a3c441..cbbbc2a16c69 100644 --- a/Tasks/AzureFileCopyV5/task.json +++ b/Tasks/AzureFileCopyV5/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 5, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV5/task.loc.json b/Tasks/AzureFileCopyV5/task.loc.json index fb08976e78a4..908c39781595 100644 --- a/Tasks/AzureFileCopyV5/task.loc.json +++ b/Tasks/AzureFileCopyV5/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 5, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/WindowsMachineFileCopyV1/task.json b/Tasks/WindowsMachineFileCopyV1/task.json index 00b4475d427c..fa7f85a8eb9a 100644 --- a/Tasks/WindowsMachineFileCopyV1/task.json +++ b/Tasks/WindowsMachineFileCopyV1/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "minimumAgentVersion": "1.104.0", "groups": [ diff --git a/Tasks/WindowsMachineFileCopyV1/task.loc.json b/Tasks/WindowsMachineFileCopyV1/task.loc.json index 44379705517d..0097802eae87 100644 --- a/Tasks/WindowsMachineFileCopyV1/task.loc.json +++ b/Tasks/WindowsMachineFileCopyV1/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "minimumAgentVersion": "1.104.0", "groups": [ diff --git a/Tasks/WindowsMachineFileCopyV2/task.json b/Tasks/WindowsMachineFileCopyV2/task.json index 8c233bcd7c16..521a03f8d2b3 100644 --- a/Tasks/WindowsMachineFileCopyV2/task.json +++ b/Tasks/WindowsMachineFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "releaseNotes": "What's new in Version 2.0:
  Proxy support is being added.
   Removed support of legacy DTL machines.", "minimumAgentVersion": "1.104.0", diff --git a/Tasks/WindowsMachineFileCopyV2/task.loc.json b/Tasks/WindowsMachineFileCopyV2/task.loc.json index 487ec998eb7e..f08cea906997 100644 --- a/Tasks/WindowsMachineFileCopyV2/task.loc.json +++ b/Tasks/WindowsMachineFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 1 + "Minor": 229, + "Patch": 0 }, "releaseNotes": "ms-resource:loc.releaseNotes", "minimumAgentVersion": "1.104.0", diff --git a/_generated/AzureFileCopyV2.versionmap.txt b/_generated/AzureFileCopyV2.versionmap.txt index 9fb4bb3f0531..2c7e4b9b7b2e 100644 --- a/_generated/AzureFileCopyV2.versionmap.txt +++ b/_generated/AzureFileCopyV2.versionmap.txt @@ -1,2 +1,2 @@ -Default|2.228.3 -Node16-225|2.228.2 +Default|2.229.1 +Node16-225|2.229.0 diff --git a/_generated/AzureFileCopyV2/task.json b/_generated/AzureFileCopyV2/task.json index ae516a1fad72..157db5fbff48 100644 --- a/_generated/AzureFileCopyV2/task.json +++ b/_generated/AzureFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" @@ -370,7 +370,7 @@ "ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired." }, "_buildConfigMapping": { - "Default": "2.228.3", - "Node16-225": "2.228.2" + "Default": "2.229.1", + "Node16-225": "2.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV2/task.loc.json b/_generated/AzureFileCopyV2/task.loc.json index 8cf39a150ad5..6856b77c8117 100644 --- a/_generated/AzureFileCopyV2/task.loc.json +++ b/_generated/AzureFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" @@ -370,7 +370,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "2.228.3", - "Node16-225": "2.228.2" + "Default": "2.229.1", + "Node16-225": "2.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV2_Node16/task.json b/_generated/AzureFileCopyV2_Node16/task.json index 79e27d267e5e..d8ef9df787e8 100644 --- a/_generated/AzureFileCopyV2_Node16/task.json +++ b/_generated/AzureFileCopyV2_Node16/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 2 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" @@ -374,7 +374,7 @@ "ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired." }, "_buildConfigMapping": { - "Default": "2.228.3", - "Node16-225": "2.228.2" + "Default": "2.229.1", + "Node16-225": "2.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV2_Node16/task.loc.json b/_generated/AzureFileCopyV2_Node16/task.loc.json index de25bf781e6c..d6626535e97e 100644 --- a/_generated/AzureFileCopyV2_Node16/task.loc.json +++ b/_generated/AzureFileCopyV2_Node16/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 228, - "Patch": 2 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" @@ -374,7 +374,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "2.228.3", - "Node16-225": "2.228.2" + "Default": "2.229.1", + "Node16-225": "2.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3.versionmap.txt b/_generated/AzureFileCopyV3.versionmap.txt index 8836c45ae4b0..b436e8595ba0 100644 --- a/_generated/AzureFileCopyV3.versionmap.txt +++ b/_generated/AzureFileCopyV3.versionmap.txt @@ -1,2 +1,2 @@ -Default|3.228.3 -Node16-225|3.228.2 +Default|3.229.1 +Node16-225|3.229.0 diff --git a/_generated/AzureFileCopyV3/task.json b/_generated/AzureFileCopyV3/task.json index ed8257cb1557..46f3052b38be 100644 --- a/_generated/AzureFileCopyV3/task.json +++ b/_generated/AzureFileCopyV3/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" @@ -309,7 +309,7 @@ "ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired." }, "_buildConfigMapping": { - "Default": "3.228.3", - "Node16-225": "3.228.2" + "Default": "3.229.1", + "Node16-225": "3.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3/task.loc.json b/_generated/AzureFileCopyV3/task.loc.json index 3855298e433c..8396fd8b4cd0 100644 --- a/_generated/AzureFileCopyV3/task.loc.json +++ b/_generated/AzureFileCopyV3/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 228, - "Patch": 3 + "Minor": 229, + "Patch": 1 }, "demands": [ "azureps" @@ -309,7 +309,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "3.228.3", - "Node16-225": "3.228.2" + "Default": "3.229.1", + "Node16-225": "3.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3_Node16/task.json b/_generated/AzureFileCopyV3_Node16/task.json index c9151e7f3298..ace538401b07 100644 --- a/_generated/AzureFileCopyV3_Node16/task.json +++ b/_generated/AzureFileCopyV3_Node16/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 228, - "Patch": 2 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" @@ -313,7 +313,7 @@ "ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired." }, "_buildConfigMapping": { - "Default": "3.228.3", - "Node16-225": "3.228.2" + "Default": "3.229.1", + "Node16-225": "3.229.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3_Node16/task.loc.json b/_generated/AzureFileCopyV3_Node16/task.loc.json index 7ba95f7af78e..7dfaef358763 100644 --- a/_generated/AzureFileCopyV3_Node16/task.loc.json +++ b/_generated/AzureFileCopyV3_Node16/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 228, - "Patch": 2 + "Minor": 229, + "Patch": 0 }, "demands": [ "azureps" @@ -313,7 +313,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "3.228.3", - "Node16-225": "3.228.2" + "Default": "3.229.1", + "Node16-225": "3.229.0" } } \ No newline at end of file From c0bc72866c400ccf6add54c661f8bd14d9e23844 Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Wed, 27 Sep 2023 23:10:00 +0400 Subject: [PATCH 06/12] Revert installNode changes --- make-util.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/make-util.js b/make-util.js index d55c10610b51..6f1eec27cf6a 100644 --- a/make-util.js +++ b/make-util.js @@ -348,21 +348,28 @@ var ensureTool = function (name, versionArgs, validate) { exports.ensureTool = ensureTool; var installNode = function (nodeVersion) { - if (!nodeVersion) { - nodeVersion = 'v6.10.3'; - } else { - const versions = { - 20: 'v20.3.1', - 16: 'v16.17.1', - 14: 'v14.10.1', - 10: 'v10.24.1', - 6: 'v6.10.3', - 5: 'v5.10.1', - }; - if (!versions[nodeVersion]) { - fail(`Unexpected node version '${nodeVersion}'. Supported versions: ${Object.keys(versions).join(', ')}`); - }; - nodeVersion = versions[nodeVersion]; + switch (nodeVersion || '') { + case '20': + nodeVersion = 'v20.3.1'; + break; + case '16': + nodeVersion = 'v16.17.1'; + break; + case '14': + nodeVersion = 'v14.10.1'; + break; + case '10': + nodeVersion = 'v10.24.1'; + break; + case '6': + case '': + nodeVersion = 'v6.10.3'; + break; + case '5': + nodeVersion = 'v5.10.1'; + break; + default: + fail(`Unexpected node version '${nodeVersion}'. Supported versions: 5, 6, 10, 14, 16, 20`); } if (nodeVersion === run('node -v')) { From a3174687579668d1ac743e155f7ea7d0e0f4f102 Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Thu, 28 Sep 2023 04:17:11 +0400 Subject: [PATCH 07/12] Remove <> from url --- Tasks/Common/Sanitizer/module.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/Common/Sanitizer/module.json b/Tasks/Common/Sanitizer/module.json index b00eb9eb736a..52d6c692b701 100644 --- a/Tasks/Common/Sanitizer/module.json +++ b/Tasks/Common/Sanitizer/module.json @@ -1,6 +1,6 @@ { "messages": { - "PS_ScriptArgsSanitized": "Detected characters in arguments that may not be executed correctly by the shell. Please escape special characters using backtick (`). More information is available here: ", + "PS_ScriptArgsSanitized": "Detected characters in arguments that may not be executed correctly by the shell. Please escape special characters using backtick (`). More information is available here: https://aka.ms/ado/75787", "PS_ScriptArgsNotSanitized": "Arguments passed sanitization without change." } } \ No newline at end of file From 168f5f9276a65701afe17802eba165571032048a Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Thu, 28 Sep 2023 13:58:56 +0400 Subject: [PATCH 08/12] Fix make.js conditions --- make.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/make.js b/make.js index 196988ad547e..0cde241a176c 100644 --- a/make.js +++ b/make.js @@ -546,12 +546,12 @@ CLI.test = function(/** @type {{ suite: string; node: string; task: string }} */ } }); - if (!argv.task || argv.task.startsWith('Common')) { - var commonBuildPath = path.join(buildTasksPath, 'Common'); - var commonLibPattern = path.join(commonBuildPath, '*', 'Tests', suiteType + '.js'); - if (argv.task.startsWith('Common/')) { - var commonModuleName = argv.task.split('/')[1]; - var commonModuleBuildPath = path.join(buildTasksPath, 'Common', commonModuleName); + if (!argv.task || (argv.task && argv.task.startsWith('Common'))) { + let commonBuildPath = path.join(buildTasksPath, 'Common'); + let commonLibPattern = path.join(commonBuildPath, '*', 'Tests', suiteType + '.js'); + if (argv.task && argv.task.startsWith('Common/')) { + const commonModuleName = argv.task.split('/')[1]; + const commonModuleBuildPath = path.join(buildTasksPath, 'Common', commonModuleName); if (fs.existsSync(commonModuleBuildPath)){ commonLibPattern = path.join(commonModuleBuildPath, 'Tests', suiteType + '.js'); } else { From 61077accf61479fbac85f9a1edee3f47ff4c1da3 Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Thu, 28 Sep 2023 17:22:01 +0400 Subject: [PATCH 09/12] Add whitespace to allowlist --- Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 | 2 +- .../Strings/resources.resjson/en-US/resources.resjson | 2 +- .../Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 b/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 index 829448ef28b3..160e1a2c1aa8 100644 --- a/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 +++ b/Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1 @@ -60,7 +60,7 @@ function Get-SanitizedArguments([string]$inputArgs) { # regex rule for removing symbols and telemetry. # '?", + "loc.messages.PS_ScriptArgsSanitized": "Detected characters in arguments that may not be executed correctly by the shell. Please escape special characters using backtick (`). More information is available here: https://aka.ms/ado/75787", "loc.messages.PS_ScriptArgsNotSanitized": "Arguments passed sanitization without change." } \ No newline at end of file diff --git a/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 index 62df9c057b98..d872d20d6e83 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Passes.ps1 @@ -27,7 +27,8 @@ $inputArgsSuites = @( 'a A 1 \ ` _ '' " - = / : . * , + ~ ? %', # Just each allowed symbol '', 'test 1', - 'test `; whoami `&`& echo test' + 'test `; whoami `&`& echo test', + "line 1 `n line 2" ) foreach ($inputArgs in $inputArgsSuites) { From 90fcd62fe97630e5ec903a3d564bb7d80c11961d Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov <52399739+KonstantinTyukalov@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:40:06 +0400 Subject: [PATCH 10/12] Apply sanitize case from linux Co-authored-by: Vladyslav Horbachov <50652041+LeftTwixWand@users.noreply.github.com> --- .../Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 index 74774fcda282..2b8f65262d77 100644 --- a/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 +++ b/Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.Throws.ps1 @@ -9,7 +9,8 @@ Set-Item -Path env:AZP_75787_ENABLE_NEW_LOGIC -Value 'true' $inputArgsSuites = @( 'test; whoami', 'test && whoami', - 'echo "$(rm ./somedir)"' + 'echo "$(rm ./somedir)"', + 'test | whoami' ) $expectedMsg = Get-VstsLocString -Key 'PS_ScriptArgsSanitized' From 018187fcaea0fd570ee980caf1e0911f9b96124b Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Mon, 2 Oct 2023 18:25:20 +0400 Subject: [PATCH 11/12] Revert make.js changes --- make-util.js | 25 ++----------- make.js | 102 +++++++++++---------------------------------------- 2 files changed, 25 insertions(+), 102 deletions(-) diff --git a/make-util.js b/make-util.js index af0f4db5ec80..76036df43ad4 100644 --- a/make-util.js +++ b/make-util.js @@ -14,8 +14,6 @@ var syncRequest = require('sync-request'); var repoPath = __dirname; var downloadPath = path.join(repoPath, '_download'); -const isNoColor = process.env['NO_COLOR'] ? process.env['NO_COLOR'].toLowerCase() == 'true' : false; - // list of .NET culture names var cultureNames = ['cs', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'pl', 'pt-BR', 'ru', 'tr', 'zh-Hans', 'zh-Hant']; @@ -111,7 +109,8 @@ var rp = function (relPath) { exports.rp = rp; var fail = function (message) { - throw Error(message); + console.error('ERROR: ' + message); + process.exit(1); } exports.fail = fail; @@ -130,22 +129,6 @@ var pathExists = function (checkPath) { } exports.pathExists = pathExists; -function log(message, type) { - switch (type) { - case 'error': - case 'err': - if (!isNoColor) { - message = '\x1b[31m' + message + '\x1b[0m'; - } - console.error(message); - break; - - default: - console.log(message); - } -} -exports.log = log; - /** * Given a module path, gets the info used for generating a pack file */ @@ -314,10 +297,10 @@ var run = function (cl, inheritStreams, noHeader) { } catch (err) { if (!inheritStreams) { - log(err.output ? err.output.toString() : err.message, 'error'); + console.error(err.output ? err.output.toString() : err.message); } - fail(err); + process.exit(1); } return (output || '').toString().trim(); diff --git a/make.js b/make.js index 0cde241a176c..35dae645fa34 100644 --- a/make.js +++ b/make.js @@ -57,15 +57,9 @@ var coverageTasksPath = path.join(buildPath, 'coverage'); var baseConfigToolPath = path.join(__dirname, 'BuildConfigGen'); var genTaskPath = path.join(__dirname, '_generated'); var genTaskCommonPath = path.join(__dirname, '_generated', 'Common'); -var rootTsConfigPath = path.join(__dirname, 'tsconfig.json'); var CLI = {}; -process.on('uncaughtException', err => { - util.log(err, 'err'); - process.exit(1); -}) - // node min version var minNodeVer = '6.10.3'; if (semver.lt(process.versions.node, minNodeVer)) { @@ -100,9 +94,8 @@ if (argv.task) { }); } - // 'Common/' needs to allow to run tests for common modules separately. - if (!taskList.length && !argv.task.startsWith('Common/')) { - fail(`Unable to find any tasks matching pattern '${argv.task}'`); + if (!taskList.length) { + fail('Unable to find any tasks matching pattern ' + argv.task); } } else { // load the default list @@ -520,18 +513,24 @@ CLI.test = function(/** @type {{ suite: string; node: string; task: string }} */ } nodeVersions.forEach(function (nodeVersion) { - nodeVersion = String(nodeVersion); - banner('Run Mocha Suits for node ' + nodeVersion); - // setup the version of node to run the tests - util.installNode(nodeVersion); + try { + nodeVersion = String(nodeVersion); + banner('Run Mocha Suits for node ' + nodeVersion); + // setup the version of node to run the tests + util.installNode(nodeVersion); - if (isNodeTask && !isReportWasFormed && nodeVersion >= 10) { - run('nyc --all -n ' + taskPath + ' --report-dir ' + coverageTasksPath + ' mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); - util.renameCodeCoverageOutput(coverageTasksPath, taskName); - isReportWasFormed = true; - } - else { - run('mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); + + if (isNodeTask && !isReportWasFormed && nodeVersion >= 10) { + run('nyc --all -n ' + taskPath + ' --report-dir ' + coverageTasksPath + ' mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); + util.renameCodeCoverageOutput(coverageTasksPath, taskName); + isReportWasFormed = true; + } + else { + run('mocha ' + testsSpec.join(' '), /*inheritStreams:*/true); + } + } catch (e) { + console.error(e); + process.exit(1); } }); } @@ -546,28 +545,9 @@ CLI.test = function(/** @type {{ suite: string; node: string; task: string }} */ } }); - if (!argv.task || (argv.task && argv.task.startsWith('Common'))) { - let commonBuildPath = path.join(buildTasksPath, 'Common'); - let commonLibPattern = path.join(commonBuildPath, '*', 'Tests', suiteType + '.js'); - if (argv.task && argv.task.startsWith('Common/')) { - const commonModuleName = argv.task.split('/')[1]; - const commonModuleBuildPath = path.join(buildTasksPath, 'Common', commonModuleName); - if (fs.existsSync(commonModuleBuildPath)){ - commonLibPattern = path.join(commonModuleBuildPath, 'Tests', suiteType + '.js'); - } else { - util.log(`Common module ${commonModuleName} does not exist. Skipping it.`); - } - } - banner('Pre-duilding L0.ts files'); - cp('-f', rootTsConfigPath, commonBuildPath); - try { - run(`tsc -p "${commonBuildPath}"`); - } - catch (e) { - console.log('Error while prebuilding L0.ts common tests files. Skipping them temporarily.') - } - + if (!argv.task) { banner('Running common library tests'); + var commonLibPattern = path.join(buildTasksPath, 'Common', '*', 'Tests', suiteType + '.js'); var specs = []; if (matchFind(commonLibPattern, buildTasksPath).length > 0) { specs.push(commonLibPattern); @@ -1077,43 +1057,3 @@ if (typeof CLI[command] !== 'function') { } CLI[command](argv); - -function buildCommonModules() { - var commonsPath = path.join(tasksPath, 'Common'); - var modOutDir = path.join(buildTasksCommonPath, modName); - - var commonModules = fs.readdirSync(commonsPath); - - rm('-Rf', modOutDir); - mkdir('-p', modOutDir); - - for (const cmod of commonModules) { - const modPath = path.join(commonsPath, cmod); - cp('-Rf', path.join(modPath), modOutDir); - - // create loc files - var modJsonPath = path.join(modPath, 'module.json'); - if (test('-f', modJsonPath)) { - createResjson(fileToJson(modJsonPath), modPath); - } - - if (cmod === 'coveragepublisher') { - buildNodeTask(modPath, modOutDir); - } - - - // copy default resources and any additional resources defined in the module's make.json - util.log(); - util.log('> copying module resources'); - const modMakePath = path.join(modPath, 'make.json'); - const modMake = test('-f', modMakePath) ? fileToJson(modMakePath) : {}; - copyTaskResources(modMake, modPath, modOutDir); - - util.log('get externals'); - if (modMake.hasOwnProperty('externals')) { - util.log(''); - util.log('> getting module externals'); - getExternals(modMake.externals, modOutDir); - } - } -} From 5c2b6d8457bd3b63cf363e47dfa6b72bda189372 Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov Date: Mon, 2 Oct 2023 19:13:42 +0400 Subject: [PATCH 12/12] Remove runTests.ps1 --- Tasks/Common/Sanitizer/runTests.ps1 | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Tasks/Common/Sanitizer/runTests.ps1 diff --git a/Tasks/Common/Sanitizer/runTests.ps1 b/Tasks/Common/Sanitizer/runTests.ps1 deleted file mode 100644 index 869fccf8eb3e..000000000000 --- a/Tasks/Common/Sanitizer/runTests.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -$startLoc = Get-Location - -Set-Location $PSScriptRoot/../../.. - -try { - Remove-Item .\_build\Tasks\Common\Sanitizer -Recurse -Force -ErrorAction SilentlyContinue - node make build --task AzureFileCopyV5 - node make test --task Common/Sanitizer -} -finally { - Set-Location $startLoc -}