Add a separate script for injecting values into scripts

This commit is contained in:
Manuel Thalmann 2024-07-31 14:55:00 +02:00
parent 3f24abdb89
commit 73dbb502ba
2 changed files with 20 additions and 7 deletions

View file

@ -1,5 +1,8 @@
#!/bin/pwsh
. "$PSScriptRoot/../Scripts/Scripting.ps1";
function Start-Setup {
. "$PSScriptRoot/../Scripts/Scripting.ps1";
$Global:InformationPreference = "Continue";
$Global:ErrorActionPreference = "Inquire";
$null = $env:WIN_COMPUTER_NAME;
@ -52,15 +55,9 @@ function Start-Setup {
$relativePath = [System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $path);
Join-Path $env:REMOTE_PROJECT_PATH $relativePath;
}
function Get-Injection($value) {
"([System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String('$(
[System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($value))
)')))"
}
function Get-PathInjection($path) {
"(Join-Path `$env:SystemDrive $(Get-Injection $path))"
"(Join-Path `$env:SystemDrive $(ConvertTo-Injection $path))"
}
function Get-ScriptPathInjection($path) {

View file

@ -0,0 +1,16 @@
<#
.SYNOPSIS
Converts the specified value into a form to safle inject it into a script.
.PARAMETER value
The value to convert for injection.
#>
function ConvertTo-Injection {
param(
$Value
)
"([System.Text.Encoding]::Default.GetString([System.Convert]::FromBase64String('$(
[System.Convert]::ToBase64String([System.Text.Encoding]::Default.GetBytes($value))
)')))"
}