From 3450eefacfd3db1a71144816a81fd9b396b3b83d Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 19 Apr 2021 14:43:16 -0700 Subject: [PATCH] Use underscore-prefixed variable name when setting sub config values as secrets (#20507) Co-authored-by: Ben Broderick Phillips --- .../TestResources/build-test-resource-config.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eng/common/TestResources/build-test-resource-config.yml b/eng/common/TestResources/build-test-resource-config.yml index 98cdd96f5ad6..9aeaca918df6 100644 --- a/eng/common/TestResources/build-test-resource-config.yml +++ b/eng/common/TestResources/build-test-resource-config.yml @@ -16,10 +16,13 @@ steps: foreach($pair in $config.GetEnumerator()) { if ($pair.Value -is [Hashtable]) { foreach($nestedPair in $pair.Value.GetEnumerator()) { - Write-Host "##vso[task.setvariable variable=$($nestedPair.Name);issecret=true;]$($nestedPair.Value)" + # Mark values as secret so we don't print json blobs containing secrets in the logs. + # Prepend underscore to the variable name, so we can still access the variable names via environment + # variables if they get set subsequently. + Write-Host "##vso[task.setvariable variable=_$($nestedPair.Name);issecret=true;]$($nestedPair.Value)" } } else { - Write-Host "##vso[task.setvariable variable=$($pair.Name);issecret=true;]$($pair.Value)" + Write-Host "##vso[task.setvariable variable=_$($pair.Name);issecret=true;]$($pair.Value)" } } @@ -49,11 +52,14 @@ steps: $config[$pair.Name] = @{} } foreach($nestedPair in $pair.Value.GetEnumerator()) { - Write-Host "##vso[task.setvariable variable=$($nestedPair.Name);issecret=true;]$($nestedPair.Value)" + # Mark values as secret so we don't print json blobs containing secrets in the logs. + # Prepend underscore to the variable name, so we can still access the variable names via environment + # variables if they get set subsequently. + Write-Host "##vso[task.setvariable variable=_$($nestedPair.Name);issecret=true;]$($nestedPair.Value)" $config[$pair.Name][$nestedPair.Name] = $nestedPair.Value } } else { - Write-Host "##vso[task.setvariable variable=$($pair.Name);issecret=true;]$($pair.Value)" + Write-Host "##vso[task.setvariable variable=_$($pair.Name);issecret=true;]$($pair.Value)" $config[$pair.Name] = $pair.Value } }