From 25a96f1322c086d92e12f52b023681de51c0fa06 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Thu, 30 Nov 2023 11:27:26 -0800 Subject: [PATCH] Fix SAS token generation (#5215) * Fix token generation * Ordering of steps * Demonstrate proper redaction * Revert "Demonstrate proper redaction" This reverts commit 1e67e0ac3a67c857c5ea0df6abfae89e4a94b63e. * Spelling --- eng/scripts/Set-VcpkgWriteModeCache.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eng/scripts/Set-VcpkgWriteModeCache.ps1 b/eng/scripts/Set-VcpkgWriteModeCache.ps1 index c91eaeb25..a4526ae13 100644 --- a/eng/scripts/Set-VcpkgWriteModeCache.ps1 +++ b/eng/scripts/Set-VcpkgWriteModeCache.ps1 @@ -1,4 +1,5 @@ param( + [string] $StorageAccountName = 'cppvcpkgcache', [string] $StorageAccountKey ) @@ -27,7 +28,7 @@ $env:PSModulePath = $modulePaths -join $moduleSeperator Install-ModuleIfNotInstalled "Az.Storage" "4.3.0" | Import-Module $ctx = New-AzStorageContext ` - -StorageAccountName 'cppvcpkgcache' ` + -StorageAccountName $StorageAccountName ` -StorageAccountKey $StorageAccountKey $token = New-AzStorageAccountSASToken ` -Service Blob ` @@ -35,7 +36,14 @@ $token = New-AzStorageAccountSASToken ` -Permission "rwc" ` -Context $ctx ` -ExpiryTime (Get-Date).AddDays(1) -$vcpkgBinarySourceSas = $token.Substring(1) + +$vcpkgBinarySourceSas = $token +if ($token.StartsWith('?')) { + $vcpkgBinarySourceSas = $token.Substring(1) +} + +Write-Host "Ensure redaction of SAS tokens in logs" +Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SAS_TOKEN;issecret=true;]$vcpkgBinarySourceSas" Write-Host "Setting vcpkg binary cache to read and write" Write-Host "##vso[task.setvariable variable=VCPKG_BINARY_SOURCES_SECRET;issecret=true;]clear;x-azblob,https://cppvcpkgcache.blob.core.windows.net/public-vcpkg-container,$vcpkgBinarySourceSas,readwrite"