diff --git a/Tasks/AzureFileCopyV1/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV1/AzureFileCopy.ps1 index 3fe30aa9797c..a8aef3f5d0fd 100644 --- a/Tasks/AzureFileCopyV1/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV1/AzureFileCopy.ps1 @@ -52,7 +52,6 @@ $azCopyLocation = [System.IO.Path]::GetDirectoryName($azCopyExeLocation) # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer Initialize-Azure # Import the loc strings. @@ -76,6 +75,19 @@ if ($enableDetailedLoggingString -ne "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV1" +} + +if ($useSanitizerActivate) { + $additionalArguments = $sanitizedArguments -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -190,7 +202,7 @@ try { -storageAccountName $storageAccount -containerName $containerName -containerSasToken $containerSasToken -blobStorageEndpoint $blobStorageEndpoint -targetPath $targetPath -azCopyLocation $azCopyLocation ` -resourceGroupName $environmentName -azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials ` -cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $useHttpsProtocolOption -skipCACheckOption $skipCACheckOption ` - -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -copyFilesInParallel $copyFilesInParallel -connectionType $connectionType + -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -copyFilesInParallel $copyFilesInParallel -connectionType $connectionType -useSanitizerActivate $useSanitizerActivate } catch { diff --git a/Tasks/AzureFileCopyV1/AzureFileCopyJob.ps1 b/Tasks/AzureFileCopyV1/AzureFileCopyJob.ps1 index c20ee2ce664c..29dbcd42bc81 100644 --- a/Tasks/AzureFileCopyV1/AzureFileCopyJob.ps1 +++ b/Tasks/AzureFileCopyV1/AzureFileCopyJob.ps1 @@ -14,7 +14,8 @@ param ( [string]$httpProtocolOption, [string]$skipCACheckOption, [string]$enableDetailedLogging, - [string]$additionalArguments + [string]$additionalArguments, + [bool]$useSanitizerActivate = $false ) Write-Verbose "fqdn = $fqdn" @@ -51,14 +52,8 @@ param ( $blobStorageURI = $blobStorageEndpoint+$containerName+"/"+$blobPrefix } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV1" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Copy-ToAzureMachines -MachineDnsName $fqdn -StorageAccountName $storageAccount -ContainerName $containerName -SasToken $sasToken -DestinationPath $targetPath -Credential $credential -AzCopyLocation $azCopyLocation -AdditionalArguments $sanitizedArguments -BlobStorageURI $blobStorageURI -WinRMPort $winRMPort $cleanTargetPathOption $skipCACheckOption $httpProtocolOption $enableDetailedLoggingOption } else { [String]$copyToAzureMachinesBlockString = [string]::Empty diff --git a/Tasks/AzureFileCopyV1/Utility.ps1 b/Tasks/AzureFileCopyV1/Utility.ps1 index 88bfef0f1a2f..5fb6206b0a07 100644 --- a/Tasks/AzureFileCopyV1/Utility.ps1 +++ b/Tasks/AzureFileCopyV1/Utility.ps1 @@ -278,17 +278,6 @@ function Upload-FilesToAzureContainer { $blobStorageURI = $blobStorageEndpoint+$containerName+"/"+$blobPrefix } - - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedAdditionalArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV1" - } - - if ($useSanitizerActivate) { - $additionalArguments = $sanitizedAdditionalArguments - } Copy-FilesToAzureBlob -SourcePathLocation $sourcePath -StorageAccountName $storageAccountName -ContainerName $containerName -BlobPrefix $blobPrefix -StorageAccountKey $storageKey -AzCopyLocation $azCopyLocation -AdditionalArguments $additionalArguments -BlobStorageURI $blobStorageURI } @@ -1012,7 +1001,8 @@ function Copy-FilesSequentiallyToAzureVMs [string]$skipCACheckOption, [string][Parameter(Mandatory=$true)]$enableDetailedLoggingString, [string]$additionalArguments, - [string][Parameter(Mandatory=$true)]$connectionType) + [string][Parameter(Mandatory=$true)]$connectionType, + [string][Parameter(Mandatory=$false)]$useSanitizerActivate = $false) foreach ($resource in $azureVMResourcesProperties.Keys) { @@ -1026,7 +1016,7 @@ function Copy-FilesSequentiallyToAzureVMs $deploymentUtilitiesLocation = Get-DeploymentModulePath $copyResponse = Invoke-Command -ScriptBlock $AzureFileCopyJob -ArgumentList ` $deploymentutilitieslocation, $resourceFQDN, $storageAccountName, $containerName, $containerSasToken, $blobStorageEndpoint, $azCopyLocation, $targetPath, $azureVMsCredentials, ` - $cleanTargetBeforeCopy, $resourceWinRMHttpsPort, $communicationProtocol, $skipCACheckOption, $enableDetailedLoggingString, $additionalArguments + $cleanTargetBeforeCopy, $resourceWinRMHttpsPort, $communicationProtocol, $skipCACheckOption, $enableDetailedLoggingString, $additionalArguments, $useSanitizerActivate $status = $copyResponse.Status @@ -1066,7 +1056,8 @@ function Copy-FilesParallellyToAzureVMs [string]$skipCACheckOption, [string][Parameter(Mandatory=$true)]$enableDetailedLoggingString, [string]$additionalArguments, - [string][Parameter(Mandatory=$true)]$connectionType) + [string][Parameter(Mandatory=$true)]$connectionType, + [string][Parameter(Mandatory=$false)]$useSanitizerActivate = $false) [hashtable]$Jobs = @{} $dtlsdkErrors = @() @@ -1082,7 +1073,7 @@ function Copy-FilesParallellyToAzureVMs $job = Start-Job -ScriptBlock $AzureFileCopyJob -ArgumentList ` $deploymentutilitieslocation, $resourceFQDN, $storageAccountName, $containerName, $containerSasToken, $blobStorageEndpoint, $azCopyLocation, $targetPath, $azureVmsCredentials, ` - $cleanTargetBeforeCopy, $resourceWinRMHttpsPort, $communicationProtocol, $skipCACheckOption, $enableDetailedLoggingString, $additionalArguments + $cleanTargetBeforeCopy, $resourceWinRMHttpsPort, $communicationProtocol, $skipCACheckOption, $enableDetailedLoggingString, $additionalArguments, $useSanitizerActivate $Jobs.Add($job.Id, $resourceProperties) } @@ -1155,7 +1146,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string][Parameter(Mandatory=$true)]$enableDetailedLoggingString, [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$copyFilesInParallel, - [string][Parameter(Mandatory=$true)]$connectionType) + [string][Parameter(Mandatory=$true)]$connectionType, + [string][Parameter(Mandatory=$false)]$useSanitizerActivate = $false) # copies files sequentially if ($copyFilesInParallel -eq "false" -or ( $azureVMResourcesProperties.Count -eq 1 )) @@ -1166,7 +1158,7 @@ function Copy-FilesToAzureVMsFromStorageContainer -blobStorageEndpoint $blobStorageEndpoint -targetPath $targetPath -azCopyLocation $azCopyLocation ` -azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials ` -cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $communicationProtocol -skipCACheckOption $skipCACheckOption ` - -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType + -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType -useSanitizerActivate $useSanitizerActivate } # copies files parallelly else @@ -1176,7 +1168,7 @@ function Copy-FilesToAzureVMsFromStorageContainer -blobStorageEndpoint $blobStorageEndpoint -targetPath $targetPath -azCopyLocation $azCopyLocation ` -azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials ` -cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $communicationProtocol -skipCACheckOption $skipCACheckOption ` - -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType + -enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType -useSanitizerActivate $useSanitizerActivate } # if no error thrown, copy successfully succeeded diff --git a/Tasks/AzureFileCopyV1/task.json b/Tasks/AzureFileCopyV1/task.json index 070a41ebbadb..97ff14e588f1 100644 --- a/Tasks/AzureFileCopyV1/task.json +++ b/Tasks/AzureFileCopyV1/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV1/task.loc.json b/Tasks/AzureFileCopyV1/task.loc.json index 1fdd63a23152..4f8616f3984a 100644 --- a/Tasks/AzureFileCopyV1/task.loc.json +++ b/Tasks/AzureFileCopyV1/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 index 6bcdaf8b5bc0..6b64ce4a6c72 100644 --- a/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV2/AzureFileCopy.ps1 @@ -65,7 +65,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer . "$PSScriptRoot\Utility.ps1" $endpoint = Get-Endpoint -connectedServiceName $connectedServiceName @@ -84,6 +83,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV2" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV2" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -183,7 +197,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -azCopyLogFilePath $logFilePath + -azCopyLogFilePath $logFilePath ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -243,7 +258,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/Tasks/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 b/Tasks/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 index 60af347f9c69..38bb9d01aee1 100644 --- a/Tasks/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 +++ b/Tasks/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 @@ -7,7 +7,8 @@ $AzureFileCopyRemoteJob = { [string]$azCopyToolFileNamesString, [string]$azCopyToolFileContentsString, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -118,14 +119,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "/Z:`"$azCopyDestinationPath`" /V:`"$logFilePath`" /S /Y" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & `"$azCopyExeLocation`" /Source:`"$containerURL`" /Dest:`"$targetPath`" /SourceSAS:`"*****`" $sanitizedArguments" & $azCopyExeLocation /Source:$containerURL /Dest:$targetPath /SourceSAS:$containerSasToken $sanitizedArguments } else { diff --git a/Tasks/AzureFileCopyV2/Utility.ps1 b/Tasks/AzureFileCopyV2/Utility.ps1 index 1ccccc93449d..d3f7e3f6776b 100644 --- a/Tasks/AzureFileCopyV2/Utility.ps1 +++ b/Tasks/AzureFileCopyV2/Utility.ps1 @@ -244,7 +244,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string]$azCopyLogFilePath + [string]$azCopyLogFilePath, + [bool]$useSanitizerActivate = $false ) try @@ -277,14 +278,8 @@ function Upload-FilesToAzureContainer ) } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & `"$azCopyExeLocation`" /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /@:`"$responseFile`" $sanitizedArguments" & $azCopyExeLocation /Source:$resolvedSourcePath /Dest:$containerURL /@:$responseFile $sanitizedArguments } else { @@ -1099,7 +1094,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -1119,7 +1115,7 @@ function Copy-FilesToAzureVMsFromStorageContainer $azCopyToolFileContentsString = $azCopyToolFileContents -join ";" # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/Tasks/AzureFileCopyV2/task.json b/Tasks/AzureFileCopyV2/task.json index 120409dedb27..11b2dfbb48eb 100644 --- a/Tasks/AzureFileCopyV2/task.json +++ b/Tasks/AzureFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV2/task.loc.json b/Tasks/AzureFileCopyV2/task.loc.json index 487eaa591969..3985f5dc31b3 100644 --- a/Tasks/AzureFileCopyV2/task.loc.json +++ b/Tasks/AzureFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 index b084666c4080..0e40f983b0cc 100644 --- a/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV3/AzureFileCopy.ps1 @@ -62,7 +62,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer $endpoint = Get-VstsEndpoint -Name $connectedServiceName -Require $vstsEndpoint = Get-VstsEndpoint -Name SystemVssConnection -Require @@ -90,6 +89,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV3" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV3" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -183,7 +197,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -azCopyLogFilePath $logFilePath + -azCopyLogFilePath $logFilePath ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -243,7 +258,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/Tasks/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 b/Tasks/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 index 3781ea7cbca6..38bb9d01aee1 100644 --- a/Tasks/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 +++ b/Tasks/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 @@ -7,7 +7,8 @@ $AzureFileCopyRemoteJob = { [string]$azCopyToolFileNamesString, [string]$azCopyToolFileContentsString, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -118,14 +119,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "/Z:`"$azCopyDestinationPath`" /V:`"$logFilePath`" /S /Y" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall){ - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV3" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & `"$azCopyExeLocation`" /Source:`"$containerURL`" /Dest:`"$targetPath`" /SourceSAS:`"*****`" $sanitizedArguments" & $azCopyExeLocation /Source:$containerURL /Dest:$targetPath /SourceSAS:$containerSasToken $sanitizedArguments } else { diff --git a/Tasks/AzureFileCopyV3/Utility.ps1 b/Tasks/AzureFileCopyV3/Utility.ps1 index 5153316e99b8..9f14113980a7 100644 --- a/Tasks/AzureFileCopyV3/Utility.ps1 +++ b/Tasks/AzureFileCopyV3/Utility.ps1 @@ -127,7 +127,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string]$azCopyLogFilePath + [string]$azCopyLogFilePath, + [bool]$useSanitizerActivate = $false ) try @@ -160,14 +161,8 @@ function Upload-FilesToAzureContainer ) } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV3" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & azcopy /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /@:`"$responseFile`" $sanitizedArguments" & $azCopyExeLocation /Source:$resolvedSourcePath /Dest:$containerURL /@:$responseFile $sanitizedArguments } else { @@ -921,7 +916,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -941,7 +937,7 @@ function Copy-FilesToAzureVMsFromStorageContainer $azCopyToolFileContentsString = $azCopyToolFileContents -join ";" # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/Tasks/AzureFileCopyV3/task.json b/Tasks/AzureFileCopyV3/task.json index 393d7bfb70be..a3c9a63cb217 100644 --- a/Tasks/AzureFileCopyV3/task.json +++ b/Tasks/AzureFileCopyV3/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV3/task.loc.json b/Tasks/AzureFileCopyV3/task.loc.json index be20933f57a6..15e8a64525fc 100644 --- a/Tasks/AzureFileCopyV3/task.loc.json +++ b/Tasks/AzureFileCopyV3/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV4/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV4/AzureFileCopy.ps1 index 6251b99cb2d9..d9f2b32fd209 100644 --- a/Tasks/AzureFileCopyV4/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV4/AzureFileCopy.ps1 @@ -60,7 +60,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer $endpoint = Get-VstsEndpoint -Name $connectedServiceName -Require @@ -91,6 +90,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV4" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV4" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -182,8 +196,6 @@ try { Check-ContainerNameAndArgs -containerName $containerName -additionalArguments $additionalArgumentsForBlobCopy - $useSanitizerActivate = Get-SanitizerActivateStatus - $containerSasToken = "" if ($useSanitizerActivate) { Write-Verbose "Feature flag sanitizer is active (for sas token)" @@ -201,7 +213,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -containerSasToken $containerSasToken + -containerSasToken $containerSasToken ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -257,7 +270,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/Tasks/AzureFileCopyV4/AzureFileCopyRemoteJob.ps1 b/Tasks/AzureFileCopyV4/AzureFileCopyRemoteJob.ps1 index 61f8eb1a2805..cf9f95a7d9e7 100644 --- a/Tasks/AzureFileCopyV4/AzureFileCopyRemoteJob.ps1 +++ b/Tasks/AzureFileCopyV4/AzureFileCopyRemoteJob.ps1 @@ -5,7 +5,8 @@ $AzureFileCopyRemoteJob = { [string]$containerSasToken, [string]$additionalArguments, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -97,14 +98,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "--recursive --log-level=INFO" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV4" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & azcopy copy `"$containerURL*****`" `"$targetPath`" $sanitizedArguments" & azcopy copy $targetPath $containerURL/*$containerSasToken $sanitizedArguments } else { diff --git a/Tasks/AzureFileCopyV4/Utility.ps1 b/Tasks/AzureFileCopyV4/Utility.ps1 index 162053a00532..e9436502f9b1 100644 --- a/Tasks/AzureFileCopyV4/Utility.ps1 +++ b/Tasks/AzureFileCopyV4/Utility.ps1 @@ -167,7 +167,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string][Parameter(Mandatory=$false)]$containerSasToken = "" + [string][Parameter(Mandatory=$false)]$containerSasToken = "", + [bool]$useSanitizerActivate = $false ) try @@ -227,14 +228,8 @@ function Upload-FilesToAzureContainer $containerURL = $containerURL.Replace('$','`$') $azCopyExeLocation = Join-Path -Path $azCopyLocation -ChildPath "AzCopy.exe" - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV4" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & azcopy copy `"$sourcePath`" `"$containerURL`" $sanitizedArguments" & azcopy copy $sourcePath $containerURL$containerSasToken $sanitizedArguments } else { @@ -975,7 +970,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -992,7 +988,7 @@ function Copy-FilesToAzureVMsFromStorageContainer } # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/Tasks/AzureFileCopyV4/task.json b/Tasks/AzureFileCopyV4/task.json index 584385204c53..e3a147d8b6f0 100644 --- a/Tasks/AzureFileCopyV4/task.json +++ b/Tasks/AzureFileCopyV4/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV4/task.loc.json b/Tasks/AzureFileCopyV4/task.loc.json index cb563049ba62..6a736fcd8e55 100644 --- a/Tasks/AzureFileCopyV4/task.loc.json +++ b/Tasks/AzureFileCopyV4/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 4, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV5/AzureFileCopy.ps1 b/Tasks/AzureFileCopyV5/AzureFileCopy.ps1 index fc0f1be99847..be1806e1b934 100644 --- a/Tasks/AzureFileCopyV5/AzureFileCopy.ps1 +++ b/Tasks/AzureFileCopyV5/AzureFileCopy.ps1 @@ -60,7 +60,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer $endpoint = Get-VstsEndpoint -Name $connectedServiceName -Require @@ -93,6 +92,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV5" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV5" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -184,8 +198,6 @@ try { Check-ContainerNameAndArgs -containerName $containerName -additionalArguments $additionalArgumentsForBlobCopy - $useSanitizerActivate = Get-SanitizerActivateStatus - $containerSasToken = "" if ($useSanitizerActivate) { Write-Verbose "Feature flag sanitizer is active (for sas token)" @@ -204,7 +216,8 @@ try { -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` -cleanTargetBeforeCopy $cleanTargetBeforeCopy ` - -containerSasToken $containerSasToken + -containerSasToken $containerSasToken ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -260,7 +273,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/Tasks/AzureFileCopyV5/AzureFileCopyRemoteJob.ps1 b/Tasks/AzureFileCopyV5/AzureFileCopyRemoteJob.ps1 index c7311dc23901..9f69960b555a 100644 --- a/Tasks/AzureFileCopyV5/AzureFileCopyRemoteJob.ps1 +++ b/Tasks/AzureFileCopyV5/AzureFileCopyRemoteJob.ps1 @@ -5,7 +5,8 @@ $AzureFileCopyRemoteJob = { [string]$containerSasToken, [string]$additionalArguments, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -97,14 +98,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "--recursive --log-level=INFO" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV5" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & azcopy copy `"$containerURL*****`" `"$targetPath`" $sanitizedArguments" & azcopy copy $targetPath $containerURL/*$containerSasToken $sanitizedArguments } else { diff --git a/Tasks/AzureFileCopyV5/Utility.ps1 b/Tasks/AzureFileCopyV5/Utility.ps1 index 656bab9a7c7d..47bdb5cee695 100644 --- a/Tasks/AzureFileCopyV5/Utility.ps1 +++ b/Tasks/AzureFileCopyV5/Utility.ps1 @@ -168,7 +168,8 @@ function Upload-FilesToAzureContainer [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, [bool]$cleanTargetBeforeCopy, - [string][Parameter(Mandatory=$false)]$containerSasToken = "" + [string][Parameter(Mandatory=$false)]$containerSasToken = "", + [bool]$useSanitizerActivate = $false ) try @@ -240,14 +241,8 @@ function Upload-FilesToAzureContainer } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV5" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & azcopy copy `"$sourcePath`" `"$containerURL`" $sanitizedArguments" & azcopy copy $sourcePath $containerURL$containerSasToken $sanitizedArguments } else { @@ -988,7 +983,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -1005,7 +1001,7 @@ function Copy-FilesToAzureVMsFromStorageContainer } # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/Tasks/AzureFileCopyV5/task.json b/Tasks/AzureFileCopyV5/task.json index de719a625b12..86ba299c6cd1 100644 --- a/Tasks/AzureFileCopyV5/task.json +++ b/Tasks/AzureFileCopyV5/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 5, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopyV5/task.loc.json b/Tasks/AzureFileCopyV5/task.loc.json index d87955db8b52..fadc91e80dfe 100644 --- a/Tasks/AzureFileCopyV5/task.loc.json +++ b/Tasks/AzureFileCopyV5/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 5, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" diff --git a/Tasks/WindowsMachineFileCopyV1/RoboCopyJob.ps1 b/Tasks/WindowsMachineFileCopyV1/RoboCopyJob.ps1 index 9a7e85cd6dd1..0fc646817fec 100644 --- a/Tasks/WindowsMachineFileCopyV1/RoboCopyJob.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/RoboCopyJob.ps1 @@ -5,7 +5,8 @@ param ( [string]$targetPath, [object]$credential, [string]$cleanTargetBeforeCopy, - [string]$additionalArguments + [string]$additionalArguments, + [bool]$useSanitizerActivate = $false ) $sourcePath = $sourcePath.Trim().TrimEnd('\', '/') @@ -214,15 +215,9 @@ param ( } $robocopyParameters = Get-RoboCopyParameters -additionalArguments $additionalArguments -fileCopy:$isFileCopy -clean:$doCleanUp - - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $robocopyParameters -TaskName "WindowsMachineFileCopyV1" - } if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($robocopyParameters, ' (?=(?:[^"]|"[^"]*")*$)') & robocopy $sourceDirectory $destinationNetworkPath $filesToCopy $sanitizedArguments } else { $command = "robocopy `"$sourceDirectory`" `"$destinationNetworkPath`" `"$filesToCopy`" $robocopyParameters" diff --git a/Tasks/WindowsMachineFileCopyV1/Tests/L0InvalidEnvironmentResource.ps1 b/Tasks/WindowsMachineFileCopyV1/Tests/L0InvalidEnvironmentResource.ps1 index fe54db697967..0048fbada8af 100644 --- a/Tasks/WindowsMachineFileCopyV1/Tests/L0InvalidEnvironmentResource.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/Tests/L0InvalidEnvironmentResource.ps1 @@ -14,6 +14,8 @@ Register-Mock Get-EnvironmentProperty { } Register-Mock Get-EnvironmentResources { throw "No resources found" } -ParametersEvaluator{$EnvironmentName -eq $invalidEnvironmentWithNoResource} Register-Mock Register-Environment { return GetEnvironmentWithStandardProvider $invalidEnvironmentWithNoResource } -ParametersEvaluator{$EnvironmentName -eq $invalidEnvironmentWithNoResource} +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } Assert-Throws { & "$copyFilesToMachinesPath" -environmentName $invalidEnvironmentWithNoResource -machineNames $invalidInputMachineNames -sourcePath $validSourcePackage -targetPath $validApplicationPath -cleanTargetBeforeCopy $true -copyFilesInParallel $false diff --git a/Tasks/WindowsMachineFileCopyV1/Tests/L0ParallelCopyFail.ps1 b/Tasks/WindowsMachineFileCopyV1/Tests/L0ParallelCopyFail.ps1 index 82682cd4b024..c09188b7aa5d 100644 --- a/Tasks/WindowsMachineFileCopyV1/Tests/L0ParallelCopyFail.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/Tests/L0ParallelCopyFail.ps1 @@ -10,6 +10,9 @@ Register-Mock Get-EnvironmentResources { return $validResources } -ParametersEva Register-Mock Get-EnvironmentProperty { return $validMachineName1 } -ParametersEvaluator {$Key -eq $resourceFQDNKeyName -and $ResourceId -eq $validMachineId1} Register-Mock Get-EnvironmentProperty { return $validMachineName2 } -ParametersEvaluator {$Key -eq $resourceFQDNKeyName -and $ResourceId -eq $validMachineId2} +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } + Register-Mock Receive-Job { } -ParametersEvaluator { $Id -eq 1 } Register-Mock Receive-Job { throw "Copy to one or more machines failed." } -ParametersEvaluator { $Id -eq 2 } diff --git a/Tasks/WindowsMachineFileCopyV1/Tests/L0SequentialCopyFail.ps1 b/Tasks/WindowsMachineFileCopyV1/Tests/L0SequentialCopyFail.ps1 index 58c512278f6d..fce17517c17a 100644 --- a/Tasks/WindowsMachineFileCopyV1/Tests/L0SequentialCopyFail.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/Tests/L0SequentialCopyFail.ps1 @@ -10,6 +10,8 @@ $invalidEnvironmentWithNoResource = "invalidEnvironmentWithNoResource" Register-Mock Get-EnvironmentProperty { return $validResources } -ParametersEvaluator {$EnvironmentName -eq $invalidEnvironmentNameForFailCopy} Register-Mock Get-EnvironmentResources { return $resourceFailForCopy } -ParametersEvaluator {$EnvironmentName -eq $invalidEnvironmentNameForFailCopy} +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } Unregister-Mock Invoke-Command Register-Mock Invoke-Command { throw "$FailedCopyError" } diff --git a/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputParallelCopy.ps1 b/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputParallelCopy.ps1 index 2fb6dc1e188a..7891b47e83d6 100644 --- a/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputParallelCopy.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputParallelCopy.ps1 @@ -13,6 +13,9 @@ Register-Mock Register-Environment { return GetEnvironmentWithStandardProvider $ Register-Mock Get-EnvironmentProperty { return $validMachineName1 } -ParametersEvaluator {$Key -eq $resourceFQDNKeyName -and $ResourceId -eq $validMachineId1} Register-Mock Get-EnvironmentProperty { return $validMachineName2 } -ParametersEvaluator {$Key -eq $resourceFQDNKeyName -and $ResourceId -eq $validMachineId2} +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } + #Start-Job Register-Mocks Register-Mock Start-Job { $testJobs.Add($Job1); return $job1} -ParametersEvaluator{$ArgumentList -contains $validResource1.Name } Register-Mock Start-Job { $testJobs.Add($Job2); return $job2} -ParametersEvaluator{$ArgumentList -contains $validResource2.Name } diff --git a/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputSequentialCopy.ps1 b/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputSequentialCopy.ps1 index 5c0ef0f9b0a3..3fb79451fb34 100644 --- a/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputSequentialCopy.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/Tests/L0ValidInputSequentialCopy.ps1 @@ -8,6 +8,8 @@ param() Register-Mock Register-Environment { return GetEnvironmentWithStandardProvider $validEnvironmentName } -ParametersEvaluator {$EnvironmentName -eq $validEnvironmentName} Register-Mock Get-EnvironmentResources { return $validResources } -ParametersEvaluator {$EnvironmentName -eq $validEnvironmentName} Register-Mock Get-EnvironmentProperty { return $validResources } -ParametersEvaluator {$EnvironmentName -eq $validEnvironmentName} +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } & "$copyFilesToMachinesPath" -environmentName $validEnvironmentName -machineNames $validMachineNames -sourcePath $validSourcePackage -targetPath $validApplicationPath -cleanTargetBeforeCopy $true -copyFilesInParallel $false diff --git a/Tasks/WindowsMachineFileCopyV1/Utility.ps1 b/Tasks/WindowsMachineFileCopyV1/Utility.ps1 index 726e5f52cc17..59238f931745 100644 --- a/Tasks/WindowsMachineFileCopyV1/Utility.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/Utility.ps1 @@ -98,9 +98,10 @@ function Copy-OnLocalMachine( [string] $adminUserName, [string] $adminPassword, [string] $cleanTargetBeforeCopy, - [string] $additionalArguments + [string] $additionalArguments, + [bool] $useSanitizerActivate = $false ) { $credential = New-Object 'System.Net.NetworkCredential' -ArgumentList $adminUserName, $adminPassword - Invoke-Command -ScriptBlock $CopyJob -ArgumentList "", $sourcePath, $targetPath, $credential, $cleanTargetBeforeCopy, $additionalArguments + Invoke-Command -ScriptBlock $CopyJob -ArgumentList "", $sourcePath, $targetPath, $credential, $cleanTargetBeforeCopy, $additionalArguments, $useSanitizerActivate } \ No newline at end of file diff --git a/Tasks/WindowsMachineFileCopyV1/WindowsMachineFileCopy.ps1 b/Tasks/WindowsMachineFileCopyV1/WindowsMachineFileCopy.ps1 index 3bc3c73aff1e..cae74a4cc264 100644 --- a/Tasks/WindowsMachineFileCopyV1/WindowsMachineFileCopy.ps1 +++ b/Tasks/WindowsMachineFileCopyV1/WindowsMachineFileCopy.ps1 @@ -23,7 +23,6 @@ Write-Verbose "copyFilesInParallel = $copyFilesInParallel" Write-Verbose "cleanTargetBeforeCopy = $cleanTargetBeforeCopy" Import-Module $PSScriptRoot/ps_modules/VstsTaskSdk -Import-Module $PSScriptRoot/ps_modules/Sanitizer . $PSScriptRoot/RoboCopyJob.ps1 . $PSScriptRoot/Utility.ps1 @@ -33,6 +32,19 @@ import-module "Microsoft.TeamFoundation.DistributedTask.Task.Internal" import-module "Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs" import-module "Microsoft.TeamFoundation.DistributedTask.Task.Deployment.Internal" -ErrorAction Ignore +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "WindowsMachineFileCopyV1" +} + +if ($useSanitizerActivate) { + $additionalArguments = $sanitizedArguments -join " " +} + # keep machineNames parameter name unchanged due to back compatibility $machineFilter = $machineNames $sourcePath = $sourcePath.Trim('"') @@ -52,7 +64,7 @@ if([string]::IsNullOrWhiteSpace($environmentName)) Write-Output (Get-LocalizedString -Key "Copy started for - '{0}'" -ArgumentList $targetPath) Copy-OnLocalMachine -sourcePath $sourcePath -targetPath $targetPath -adminUserName $adminUserName -adminPassword $adminPassword ` - -cleanTargetBeforeCopy $cleanTargetBeforeCopy -additionalArguments $additionalArguments + -cleanTargetBeforeCopy $cleanTargetBeforeCopy -additionalArguments $additionalArguments -useSanitizerActivate $useSanitizerActivate Write-Verbose "Files copied to destination successfully." } else @@ -86,7 +98,7 @@ else Write-Output (Get-LocalizedString -Key "Copy started for - '{0}'" -ArgumentList $machine) - Invoke-Command -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $resourceProperties.credential, $cleanTargetBeforeCopy, $additionalArguments + Invoke-Command -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $resourceProperties.credential, $cleanTargetBeforeCopy, $additionalArguments, $useSanitizerActivate } } else @@ -101,7 +113,7 @@ else Write-Output (Get-LocalizedString -Key "Copy started for - '{0}'" -ArgumentList $machine) - $job = Start-Job -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $resourceProperties.credential, $cleanTargetBeforeCopy, $additionalArguments + $job = Start-Job -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $resourceProperties.credential, $cleanTargetBeforeCopy, $additionalArguments, $useSanitizerActivate $Jobs.Add($job.Id, $resourceProperties) } diff --git a/Tasks/WindowsMachineFileCopyV1/task.json b/Tasks/WindowsMachineFileCopyV1/task.json index dc8b280a5677..de0338548b10 100644 --- a/Tasks/WindowsMachineFileCopyV1/task.json +++ b/Tasks/WindowsMachineFileCopyV1/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "minimumAgentVersion": "1.104.0", "groups": [ diff --git a/Tasks/WindowsMachineFileCopyV1/task.loc.json b/Tasks/WindowsMachineFileCopyV1/task.loc.json index 3499aab47032..0a3a103118ae 100644 --- a/Tasks/WindowsMachineFileCopyV1/task.loc.json +++ b/Tasks/WindowsMachineFileCopyV1/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 1, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "minimumAgentVersion": "1.104.0", "groups": [ diff --git a/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 b/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 index e1c473f24c2c..348840194bca 100644 --- a/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/RoboCopyJob.ps1 @@ -6,7 +6,8 @@ param ( [object]$credential, [string]$cleanTargetBeforeCopy, [string]$additionalArguments, - [string]$scriptRoot + [string]$scriptRoot, + [bool]$useSanitizerActivate = $false ) Import-Module "$scriptRoot\ps_modules\VstsTaskSdk" Import-VstsLocStrings -LiteralPath $scriptRoot/Task.json @@ -237,14 +238,8 @@ param ( { $robocopyParameters = Get-RoboCopyParameters -additionalArguments $additionalArguments -fileCopy:$isFileCopy - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $robocopyParameters -TaskName "WindowsMachineFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($robocopyParameters, ' (?=(?:[^"]|"[^"]*")*$)') & robocopy $sourceDirectory $destinationNetworkPath $filesToCopy $sanitizedArguments } else { $command = "robocopy `"$sourceDirectory`" `"$destinationNetworkPath`" `"$filesToCopy`" $robocopyParameters" diff --git a/Tasks/WindowsMachineFileCopyV2/Tests/L0ParallelCopyFail.ps1 b/Tasks/WindowsMachineFileCopyV2/Tests/L0ParallelCopyFail.ps1 index 43ed4fa83196..819c1779b62f 100644 --- a/Tasks/WindowsMachineFileCopyV2/Tests/L0ParallelCopyFail.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/Tests/L0ParallelCopyFail.ps1 @@ -20,6 +20,9 @@ Register-Mock Get-VstsInput { return $validApplicationPath } -ParametersEvaluato Register-Mock Get-VstsInput { return $false } -ParametersEvaluator{ $Name -eq "CleanTargetBeforeCopy" } Register-Mock Get-VstsInput { return $true } -ParametersEvaluator{ $Name -eq "CopyFilesInParallel" } +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } + Register-Mock Receive-Job { } -ParametersEvaluator { $Id -eq 1 } Register-Mock Receive-Job { throw "Copy to one or more machines failed." } -ParametersEvaluator { $Id -eq 2 } diff --git a/Tasks/WindowsMachineFileCopyV2/Tests/L0SequentialCopyFail.ps1 b/Tasks/WindowsMachineFileCopyV2/Tests/L0SequentialCopyFail.ps1 index c55c862a3ee9..0169c0ad5c60 100644 --- a/Tasks/WindowsMachineFileCopyV2/Tests/L0SequentialCopyFail.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/Tests/L0SequentialCopyFail.ps1 @@ -14,6 +14,9 @@ Register-Mock Get-VstsInput { return $validApplicationPath } -ParametersEvaluato Register-Mock Get-VstsInput { return $true } -ParametersEvaluator{ $Name -eq "CleanTargetBeforeCopy" } Register-Mock Get-VstsInput { return $false } -ParametersEvaluator{ $Name -eq "CopyFilesInParallel" } +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } + $invalidEnvironmentWithNoResource = "invalidEnvironmentWithNoResource" Unregister-Mock Invoke-Command diff --git a/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputParallelCopy.ps1 b/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputParallelCopy.ps1 index 561f63c2d359..11b9fc4f5263 100644 --- a/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputParallelCopy.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputParallelCopy.ps1 @@ -14,6 +14,9 @@ Register-Mock Get-VstsInput { return $validApplicationPath } -ParametersEvaluato Register-Mock Get-VstsInput { return $true } -ParametersEvaluator{ $Name -eq "CleanTargetBeforeCopy" } Register-Mock Get-VstsInput { return $true } -ParametersEvaluator{ $Name -eq "CopyFilesInParallel" } +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } + Register-Mock Get-EnvironmentResources { return $validResources } -ParametersEvaluator {$EnvironmentName -eq $validEnvironmentName} Register-Mock Register-Environment { return GetEnvironmentWithStandardProvider $validEnvironmentName } -ParametersEvaluator{$EnvironmentName -eq $validEnvironmentName} diff --git a/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputSequentialCopy.ps1 b/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputSequentialCopy.ps1 index e00f661b5ad5..926cf739806a 100644 --- a/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputSequentialCopy.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/Tests/L0ValidInputSequentialCopy.ps1 @@ -14,6 +14,9 @@ Register-Mock Get-VstsInput { return $validApplicationPath } -ParametersEvaluato Register-Mock Get-VstsInput { return $true } -ParametersEvaluator{ $Name -eq "CleanTargetBeforeCopy" } Register-Mock Get-VstsInput { return $false } -ParametersEvaluator{ $Name -eq "CopyFilesInParallel" } +Register-Mock Get-SanitizerCallStatus { return $false } +Register-Mock Get-SanitizerActivateStatus { return $false } + & "$copyFilesToMachinesPath" Assert-WasCalled Invoke-Command -Times 1 \ No newline at end of file diff --git a/Tasks/WindowsMachineFileCopyV2/WindowsMachineFileCopy.ps1 b/Tasks/WindowsMachineFileCopyV2/WindowsMachineFileCopy.ps1 index 38016feee531..74fbc93bb4c8 100644 --- a/Tasks/WindowsMachineFileCopyV2/WindowsMachineFileCopy.ps1 +++ b/Tasks/WindowsMachineFileCopyV2/WindowsMachineFileCopy.ps1 @@ -15,11 +15,23 @@ $copyFilesInParallel = Get-VstsInput -Name CopyFilesInParallel # Import the loc strings. Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json -Import-Module $PSScriptRoot\ps_modules\Sanitizer . $PSScriptRoot/RoboCopyJob.ps1 . $PSScriptRoot/Utility.ps1 +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "WindowsMachineFileCopyV2" +} + +if ($useSanitizerActivate) { + $additionalArguments = $sanitizedArguments -join " " +} + try { $sourcePath = $sourcePath.Trim('"') @@ -53,7 +65,7 @@ try Write-Output (Get-VstsLocString -Key "WFC_CopyStartedFor0" -ArgumentList $machine) - Invoke-Command -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $machineCredential, $cleanTargetBeforeCopy, $additionalArguments, $PSScriptRoot + Invoke-Command -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $machineCredential, $cleanTargetBeforeCopy, $additionalArguments, $PSScriptRoot, $useSanitizerActivate } } else @@ -65,7 +77,7 @@ try Write-Output (Get-VstsLocString -Key "WFC_CopyStartedFor0" -ArgumentList $machine) - $job = Start-Job -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $machineCredential, $cleanTargetBeforeCopy, $additionalArguments, $PSScriptRoot + $job = Start-Job -ScriptBlock $CopyJob -ArgumentList $machine, $sourcePath, $targetPath, $machineCredential, $cleanTargetBeforeCopy, $additionalArguments, $PSScriptRoot, $useSanitizerActivate $Jobs.Add($job.Id, $machine) } diff --git a/Tasks/WindowsMachineFileCopyV2/task.json b/Tasks/WindowsMachineFileCopyV2/task.json index 07c476954806..353883a3f2cd 100644 --- a/Tasks/WindowsMachineFileCopyV2/task.json +++ b/Tasks/WindowsMachineFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "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 a1bc54dd6e78..3668cc6158cc 100644 --- a/Tasks/WindowsMachineFileCopyV2/task.loc.json +++ b/Tasks/WindowsMachineFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 1 + "Minor": 228, + "Patch": 0 }, "releaseNotes": "ms-resource:loc.releaseNotes", "minimumAgentVersion": "1.104.0", diff --git a/_generated/AzureFileCopyV2.versionmap.txt b/_generated/AzureFileCopyV2.versionmap.txt index 66fc486249fe..8e7908c336ec 100644 --- a/_generated/AzureFileCopyV2.versionmap.txt +++ b/_generated/AzureFileCopyV2.versionmap.txt @@ -1,2 +1,2 @@ -Default|2.227.5 -Node16-225|2.227.4 +Default|2.228.1 +Node16-225|2.228.0 diff --git a/_generated/AzureFileCopyV2/AzureFileCopy.ps1 b/_generated/AzureFileCopyV2/AzureFileCopy.ps1 index 6bcdaf8b5bc0..6b64ce4a6c72 100644 --- a/_generated/AzureFileCopyV2/AzureFileCopy.ps1 +++ b/_generated/AzureFileCopyV2/AzureFileCopy.ps1 @@ -65,7 +65,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer . "$PSScriptRoot\Utility.ps1" $endpoint = Get-Endpoint -connectedServiceName $connectedServiceName @@ -84,6 +83,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV2" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV2" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -183,7 +197,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -azCopyLogFilePath $logFilePath + -azCopyLogFilePath $logFilePath ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -243,7 +258,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/_generated/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 b/_generated/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 index 60af347f9c69..38bb9d01aee1 100644 --- a/_generated/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 +++ b/_generated/AzureFileCopyV2/AzureFileCopyRemoteJob.ps1 @@ -7,7 +7,8 @@ $AzureFileCopyRemoteJob = { [string]$azCopyToolFileNamesString, [string]$azCopyToolFileContentsString, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -118,14 +119,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "/Z:`"$azCopyDestinationPath`" /V:`"$logFilePath`" /S /Y" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & `"$azCopyExeLocation`" /Source:`"$containerURL`" /Dest:`"$targetPath`" /SourceSAS:`"*****`" $sanitizedArguments" & $azCopyExeLocation /Source:$containerURL /Dest:$targetPath /SourceSAS:$containerSasToken $sanitizedArguments } else { diff --git a/_generated/AzureFileCopyV2/Utility.ps1 b/_generated/AzureFileCopyV2/Utility.ps1 index 1ccccc93449d..d3f7e3f6776b 100644 --- a/_generated/AzureFileCopyV2/Utility.ps1 +++ b/_generated/AzureFileCopyV2/Utility.ps1 @@ -244,7 +244,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string]$azCopyLogFilePath + [string]$azCopyLogFilePath, + [bool]$useSanitizerActivate = $false ) try @@ -277,14 +278,8 @@ function Upload-FilesToAzureContainer ) } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & `"$azCopyExeLocation`" /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /@:`"$responseFile`" $sanitizedArguments" & $azCopyExeLocation /Source:$resolvedSourcePath /Dest:$containerURL /@:$responseFile $sanitizedArguments } else { @@ -1099,7 +1094,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -1119,7 +1115,7 @@ function Copy-FilesToAzureVMsFromStorageContainer $azCopyToolFileContentsString = $azCopyToolFileContents -join ";" # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/_generated/AzureFileCopyV2/task.json b/_generated/AzureFileCopyV2/task.json index 99838de2f132..00cb96d0c882 100644 --- a/_generated/AzureFileCopyV2/task.json +++ b/_generated/AzureFileCopyV2/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "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.227.5", - "Node16-225": "2.227.4" + "Default": "2.228.1", + "Node16-225": "2.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV2/task.loc.json b/_generated/AzureFileCopyV2/task.loc.json index db9cd0eb5b25..ed55fff50173 100644 --- a/_generated/AzureFileCopyV2/task.loc.json +++ b/_generated/AzureFileCopyV2/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "Patch": 1 }, "demands": [ "azureps" @@ -370,7 +370,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "2.227.5", - "Node16-225": "2.227.4" + "Default": "2.228.1", + "Node16-225": "2.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV2_Node16/AzureFileCopy.ps1 b/_generated/AzureFileCopyV2_Node16/AzureFileCopy.ps1 index 6bcdaf8b5bc0..6b64ce4a6c72 100644 --- a/_generated/AzureFileCopyV2_Node16/AzureFileCopy.ps1 +++ b/_generated/AzureFileCopyV2_Node16/AzureFileCopy.ps1 @@ -65,7 +65,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer . "$PSScriptRoot\Utility.ps1" $endpoint = Get-Endpoint -connectedServiceName $connectedServiceName @@ -84,6 +83,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV2" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV2" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -183,7 +197,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -azCopyLogFilePath $logFilePath + -azCopyLogFilePath $logFilePath ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -243,7 +258,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/_generated/AzureFileCopyV2_Node16/AzureFileCopyRemoteJob.ps1 b/_generated/AzureFileCopyV2_Node16/AzureFileCopyRemoteJob.ps1 index 60af347f9c69..38bb9d01aee1 100644 --- a/_generated/AzureFileCopyV2_Node16/AzureFileCopyRemoteJob.ps1 +++ b/_generated/AzureFileCopyV2_Node16/AzureFileCopyRemoteJob.ps1 @@ -7,7 +7,8 @@ $AzureFileCopyRemoteJob = { [string]$azCopyToolFileNamesString, [string]$azCopyToolFileContentsString, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -118,14 +119,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "/Z:`"$azCopyDestinationPath`" /V:`"$logFilePath`" /S /Y" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & `"$azCopyExeLocation`" /Source:`"$containerURL`" /Dest:`"$targetPath`" /SourceSAS:`"*****`" $sanitizedArguments" & $azCopyExeLocation /Source:$containerURL /Dest:$targetPath /SourceSAS:$containerSasToken $sanitizedArguments } else { diff --git a/_generated/AzureFileCopyV2_Node16/Utility.ps1 b/_generated/AzureFileCopyV2_Node16/Utility.ps1 index 1ccccc93449d..d3f7e3f6776b 100644 --- a/_generated/AzureFileCopyV2_Node16/Utility.ps1 +++ b/_generated/AzureFileCopyV2_Node16/Utility.ps1 @@ -244,7 +244,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string]$azCopyLogFilePath + [string]$azCopyLogFilePath, + [bool]$useSanitizerActivate = $false ) try @@ -277,14 +278,8 @@ function Upload-FilesToAzureContainer ) } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV2" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & `"$azCopyExeLocation`" /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /@:`"$responseFile`" $sanitizedArguments" & $azCopyExeLocation /Source:$resolvedSourcePath /Dest:$containerURL /@:$responseFile $sanitizedArguments } else { @@ -1099,7 +1094,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -1119,7 +1115,7 @@ function Copy-FilesToAzureVMsFromStorageContainer $azCopyToolFileContentsString = $azCopyToolFileContents -join ";" # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/_generated/AzureFileCopyV2_Node16/task.json b/_generated/AzureFileCopyV2_Node16/task.json index e6fa1b091cd0..871c5710ac50 100644 --- a/_generated/AzureFileCopyV2_Node16/task.json +++ b/_generated/AzureFileCopyV2_Node16/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 2, - "Minor": 227, - "Patch": 4 + "Minor": 228, + "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.227.5", - "Node16-225": "2.227.4" + "Default": "2.228.1", + "Node16-225": "2.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV2_Node16/task.loc.json b/_generated/AzureFileCopyV2_Node16/task.loc.json index 803ca6a8b68a..c09fdbc15892 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": 227, - "Patch": 4 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" @@ -374,7 +374,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "2.227.5", - "Node16-225": "2.227.4" + "Default": "2.228.1", + "Node16-225": "2.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3.versionmap.txt b/_generated/AzureFileCopyV3.versionmap.txt index cdaad1982f82..b5d5e9d351cc 100644 --- a/_generated/AzureFileCopyV3.versionmap.txt +++ b/_generated/AzureFileCopyV3.versionmap.txt @@ -1,2 +1,2 @@ -Default|3.227.5 -Node16-225|3.227.4 +Default|3.228.1 +Node16-225|3.228.0 diff --git a/_generated/AzureFileCopyV3/AzureFileCopy.ps1 b/_generated/AzureFileCopyV3/AzureFileCopy.ps1 index b084666c4080..0e40f983b0cc 100644 --- a/_generated/AzureFileCopyV3/AzureFileCopy.ps1 +++ b/_generated/AzureFileCopyV3/AzureFileCopy.ps1 @@ -62,7 +62,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer $endpoint = Get-VstsEndpoint -Name $connectedServiceName -Require $vstsEndpoint = Get-VstsEndpoint -Name SystemVssConnection -Require @@ -90,6 +89,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV3" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV3" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -183,7 +197,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -azCopyLogFilePath $logFilePath + -azCopyLogFilePath $logFilePath ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -243,7 +258,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/_generated/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 b/_generated/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 index 3781ea7cbca6..38bb9d01aee1 100644 --- a/_generated/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 +++ b/_generated/AzureFileCopyV3/AzureFileCopyRemoteJob.ps1 @@ -7,7 +7,8 @@ $AzureFileCopyRemoteJob = { [string]$azCopyToolFileNamesString, [string]$azCopyToolFileContentsString, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -118,14 +119,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "/Z:`"$azCopyDestinationPath`" /V:`"$logFilePath`" /S /Y" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall){ - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV3" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & `"$azCopyExeLocation`" /Source:`"$containerURL`" /Dest:`"$targetPath`" /SourceSAS:`"*****`" $sanitizedArguments" & $azCopyExeLocation /Source:$containerURL /Dest:$targetPath /SourceSAS:$containerSasToken $sanitizedArguments } else { diff --git a/_generated/AzureFileCopyV3/Utility.ps1 b/_generated/AzureFileCopyV3/Utility.ps1 index 5153316e99b8..9f14113980a7 100644 --- a/_generated/AzureFileCopyV3/Utility.ps1 +++ b/_generated/AzureFileCopyV3/Utility.ps1 @@ -127,7 +127,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string]$azCopyLogFilePath + [string]$azCopyLogFilePath, + [bool]$useSanitizerActivate = $false ) try @@ -160,14 +161,8 @@ function Upload-FilesToAzureContainer ) } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV3" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & azcopy /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /@:`"$responseFile`" $sanitizedArguments" & $azCopyExeLocation /Source:$resolvedSourcePath /Dest:$containerURL /@:$responseFile $sanitizedArguments } else { @@ -921,7 +916,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -941,7 +937,7 @@ function Copy-FilesToAzureVMsFromStorageContainer $azCopyToolFileContentsString = $azCopyToolFileContents -join ";" # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/_generated/AzureFileCopyV3/task.json b/_generated/AzureFileCopyV3/task.json index 71033c0a6f6e..d7a12cdcfd22 100644 --- a/_generated/AzureFileCopyV3/task.json +++ b/_generated/AzureFileCopyV3/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "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.227.5", - "Node16-225": "3.227.4" + "Default": "3.228.1", + "Node16-225": "3.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3/task.loc.json b/_generated/AzureFileCopyV3/task.loc.json index a5a7fa7694eb..438e5ad09e7f 100644 --- a/_generated/AzureFileCopyV3/task.loc.json +++ b/_generated/AzureFileCopyV3/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 227, - "Patch": 5 + "Minor": 228, + "Patch": 1 }, "demands": [ "azureps" @@ -309,7 +309,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "3.227.5", - "Node16-225": "3.227.4" + "Default": "3.228.1", + "Node16-225": "3.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3_Node16/AzureFileCopy.ps1 b/_generated/AzureFileCopyV3_Node16/AzureFileCopy.ps1 index b084666c4080..0e40f983b0cc 100644 --- a/_generated/AzureFileCopyV3_Node16/AzureFileCopy.ps1 +++ b/_generated/AzureFileCopyV3_Node16/AzureFileCopy.ps1 @@ -62,7 +62,6 @@ Import-Module $PSScriptRoot\ps_modules\RemoteDeployer # Initialize Azure. Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ -Import-Module $PSScriptRoot\ps_modules\Sanitizer $endpoint = Get-VstsEndpoint -Name $connectedServiceName -Require $vstsEndpoint = Get-VstsEndpoint -Name SystemVssConnection -Require @@ -90,6 +89,21 @@ $enableDetailedLogging = ($env:system_debug -eq "true") # Telemetry Import-Module $PSScriptRoot\ps_modules\TelemetryHelper +# Sanitizer +Import-Module $PSScriptRoot\ps_modules\Sanitizer +$useSanitizerCall = Get-SanitizerCallStatus +$useSanitizerActivate = Get-SanitizerActivateStatus + +if ($useSanitizerCall) { + $sanitizedArgumentsForBlobCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForBlobCopy -TaskName "AzureFileCopyV3" + $sanitizedArgumentsForVMCopy = Protect-ScriptArguments -InputArgs $additionalArgumentsForVMCopy -TaskName "AzureFileCopyV3" +} + +if ($useSanitizerActivate) { + $additionalArgumentsForBlobCopy = $sanitizedArgumentsForBlobCopy -join " " + $additionalArgumentsForVMCopy = $sanitizedArgumentsForVMCopy -join " " +} + #### MAIN EXECUTION OF AZURE FILE COPY TASK BEGINS HERE #### try { try @@ -183,7 +197,8 @@ try { -additionalArguments $additionalArgumentsForBlobCopy ` -destinationType $destination ` -useDefaultArguments $useDefaultArgumentsForBlobCopy ` - -azCopyLogFilePath $logFilePath + -azCopyLogFilePath $logFilePath ` + -useSanitizerActivate $useSanitizerActivate # Complete the task if destination is azure blob if ($destination -eq "AzureBlob") @@ -243,7 +258,8 @@ try { -additionalArguments $additionalArgumentsForVMCopy ` -azCopyToolLocation $azCopyLocation ` -fileCopyJobScript $AzureFileCopyRemoteJob ` - -enableDetailedLogging $enableDetailedLogging + -enableDetailedLogging $enableDetailedLogging ` + -useSanitizerActivate $useSanitizerActivate Write-Output (Get-VstsLocString -Key "AFC_CopySuccessful" -ArgumentList $sourcePath, $environmentName) } diff --git a/_generated/AzureFileCopyV3_Node16/AzureFileCopyRemoteJob.ps1 b/_generated/AzureFileCopyV3_Node16/AzureFileCopyRemoteJob.ps1 index 3781ea7cbca6..38bb9d01aee1 100644 --- a/_generated/AzureFileCopyV3_Node16/AzureFileCopyRemoteJob.ps1 +++ b/_generated/AzureFileCopyV3_Node16/AzureFileCopyRemoteJob.ps1 @@ -7,7 +7,8 @@ $AzureFileCopyRemoteJob = { [string]$azCopyToolFileNamesString, [string]$azCopyToolFileContentsString, [switch]$CleanTargetBeforeCopy, - [switch]$EnableDetailedLogging + [switch]$EnableDetailedLogging, + [bool]$useSanitizerActivate = $false ) function Write-DetailLogs @@ -118,14 +119,8 @@ $AzureFileCopyRemoteJob = { $additionalArguments = "/Z:`"$azCopyDestinationPath`" /V:`"$logFilePath`" /S /Y" } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall){ - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV3" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-DetailLogs "##[command] & `"$azCopyExeLocation`" /Source:`"$containerURL`" /Dest:`"$targetPath`" /SourceSAS:`"*****`" $sanitizedArguments" & $azCopyExeLocation /Source:$containerURL /Dest:$targetPath /SourceSAS:$containerSasToken $sanitizedArguments } else { diff --git a/_generated/AzureFileCopyV3_Node16/Utility.ps1 b/_generated/AzureFileCopyV3_Node16/Utility.ps1 index 5153316e99b8..9f14113980a7 100644 --- a/_generated/AzureFileCopyV3_Node16/Utility.ps1 +++ b/_generated/AzureFileCopyV3_Node16/Utility.ps1 @@ -127,7 +127,8 @@ function Upload-FilesToAzureContainer [string]$additionalArguments, [string][Parameter(Mandatory=$true)]$destinationType, [bool]$useDefaultArguments, - [string]$azCopyLogFilePath + [string]$azCopyLogFilePath, + [bool]$useSanitizerActivate = $false ) try @@ -160,14 +161,8 @@ function Upload-FilesToAzureContainer ) } - $useSanitizerCall = Get-SanitizerCallStatus - $useSanitizerActivate = Get-SanitizerActivateStatus - - if ($useSanitizerCall) { - $sanitizedArguments = Protect-ScriptArguments -InputArgs $additionalArguments -TaskName "AzureFileCopyV3" - } - if ($useSanitizerActivate) { + $sanitizedArguments = [regex]::Split($additionalArguments, ' (?=(?:[^"]|"[^"]*")*$)') Write-Output "##[command] & azcopy /Source:`"$resolvedSourcePath`" /Dest:`"$containerURL`" /@:`"$responseFile`" $sanitizedArguments" & $azCopyExeLocation /Source:$resolvedSourcePath /Dest:$containerURL /@:$responseFile $sanitizedArguments } else { @@ -921,7 +916,8 @@ function Copy-FilesToAzureVMsFromStorageContainer [string]$additionalArguments, [string]$azCopyToolLocation, [scriptblock]$fileCopyJobScript, - [bool]$enableDetailedLogging + [bool]$enableDetailedLogging, + [bool]$useSanitizerActivate = $false ) # Generate storage container URL @@ -941,7 +937,7 @@ function Copy-FilesToAzureVMsFromStorageContainer $azCopyToolFileContentsString = $azCopyToolFileContents -join ";" # script block arguments - $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString'" + $scriptBlockArgs = " -containerURL '$containerURL' -targetPath '$targetPath' -containerSasToken '$containerSasToken' -additionalArguments '$additionalArguments' -azCopyToolFileNamesString '$azCopyToolFileNamesString' -azCopyToolFileContentsString '$azCopyToolFileContentsString' -useSanitizerActivate $useSanitizerActivate" if($cleanTargetBeforeCopy) { $scriptBlockArgs += " -CleanTargetBeforeCopy" diff --git a/_generated/AzureFileCopyV3_Node16/task.json b/_generated/AzureFileCopyV3_Node16/task.json index 840bb898c5f8..3127624b5236 100644 --- a/_generated/AzureFileCopyV3_Node16/task.json +++ b/_generated/AzureFileCopyV3_Node16/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 3, - "Minor": 227, - "Patch": 4 + "Minor": 228, + "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.227.5", - "Node16-225": "3.227.4" + "Default": "3.228.1", + "Node16-225": "3.228.0" } } \ No newline at end of file diff --git a/_generated/AzureFileCopyV3_Node16/task.loc.json b/_generated/AzureFileCopyV3_Node16/task.loc.json index 8823cc5d2529..c80bd7b48107 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": 227, - "Patch": 4 + "Minor": 228, + "Patch": 0 }, "demands": [ "azureps" @@ -313,7 +313,7 @@ "ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal" }, "_buildConfigMapping": { - "Default": "3.227.5", - "Node16-225": "3.227.4" + "Default": "3.228.1", + "Node16-225": "3.228.0" } } \ No newline at end of file