From 1402a6ffb0cec6bcc473c9fd640b2e99cab921f7 Mon Sep 17 00:00:00 2001 From: freddydk Date: Mon, 18 Nov 2024 13:00:29 +0100 Subject: [PATCH] move --- Actions/Github-Helper.psm1 | 32 ++++++++++++++++++++++ Actions/ReadSecrets/ReadSecretsHelper.psm1 | 31 --------------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Actions/Github-Helper.psm1 b/Actions/Github-Helper.psm1 index 0485754f8..f372fa261 100644 --- a/Actions/Github-Helper.psm1 +++ b/Actions/Github-Helper.psm1 @@ -1,3 +1,35 @@ +$script:escchars = @(' ','!','\"','#','$','%','\u0026','\u0027','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','\u003c','=','\u003e','?','@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_',[char]96,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~') + +function MaskValue { + Param( + [string] $key, + [string] $value + ) + + Write-Host "Masking value for $key" + $value.Split("`n") | ForEach-Object { + Write-Host "::add-mask::$_" + } + + $val2 = "" + $value.ToCharArray() | ForEach-Object { + $chint = [int]$_ + if ($chint -lt 32 -or $chint -gt 126 ) { + $val2 += $_ + } + else { + $val2 += $script:escchars[$chint-32] + } + } + + if ($val2 -ne $value) { + $val2.Split("`n") | ForEach-Object { + Write-Host "::add-mask::$_" + } + } + Write-Host "::add-mask::$([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($value)))" +} + function GetExtendedErrorMessage { [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingEmptyCatchBlock", "", Justification="We want to ignore errors")] Param( diff --git a/Actions/ReadSecrets/ReadSecretsHelper.psm1 b/Actions/ReadSecrets/ReadSecretsHelper.psm1 index 978a11b77..f6b0533da 100644 --- a/Actions/ReadSecrets/ReadSecretsHelper.psm1 +++ b/Actions/ReadSecrets/ReadSecretsHelper.psm1 @@ -4,7 +4,6 @@ Param( ) $script:gitHubSecrets = $_gitHubSecrets | ConvertFrom-Json -$script:escchars = @(' ','!','\"','#','$','%','\u0026','\u0027','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','\u003c','=','\u003e','?','@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_',[char]96,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~') . (Join-Path -Path $PSScriptRoot -ChildPath "..\AL-Go-Helper.ps1" -Resolve) @@ -26,36 +25,6 @@ function GetAzureCredentials { return $null } -function MaskValue { - Param( - [string] $key, - [string] $value - ) - - Write-Host "Masking value for $key" - $value.Split("`n") | ForEach-Object { - Write-Host "::add-mask::$_" - } - - $val2 = "" - $value.ToCharArray() | ForEach-Object { - $chint = [int]$_ - if ($chint -lt 32 -or $chint -gt 126 ) { - $val2 += $_ - } - else { - $val2 += $script:escchars[$chint-32] - } - } - - if ($val2 -ne $value) { - $val2.Split("`n") | ForEach-Object { - Write-Host "::add-mask::$_" - } - } - Write-Host "::add-mask::$([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($value)))" -} - function GetGithubSecret { param ( [string] $secretName,