From c8622e5e77aa3fbc82f214fa925c198ea41de625 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 19 Jun 2026 23:40:33 +0100 Subject: [PATCH] Harden Raven Muninn remote script runners --- scripts/deploy-raven-muninn-binary.ps1 | 6 +++--- scripts/health-muninn.ps1 | 6 +++--- scripts/restart-muninn.ps1 | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/deploy-raven-muninn-binary.ps1 b/scripts/deploy-raven-muninn-binary.ps1 index dad2761..00e2f93 100644 --- a/scripts/deploy-raven-muninn-binary.ps1 +++ b/scripts/deploy-raven-muninn-binary.ps1 @@ -254,6 +254,7 @@ if (Test-Path -LiteralPath `$target) { Move-Item -LiteralPath `$incoming -Destination `$target -Force `$item = Get-Item -LiteralPath `$target Write-Output ("muninn.exe deployed length={0} path={1}" -f `$item.Length, `$item.FullName) +`$global:LASTEXITCODE = 0 "@ Set-AsciiFile -Path $localRemoteScript -Content $remoteScript @@ -276,16 +277,15 @@ Write-Output ("muninn.exe deployed length={0} path={1}" -f `$item.Length, `$item `$ErrorActionPreference = "Stop" try { & "$remoteScriptPath" - `$code = `$LASTEXITCODE + exit 0 } finally { Remove-Item -LiteralPath "$remoteScriptPath" -Force -ErrorAction SilentlyContinue } -exit `$code "@ $encodedRunner = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteRunner)) $commonArgs = Get-SshCommonArgs $sshTarget = Get-SshTarget -Target $RavenHost - & ssh.exe @commonArgs $sshTarget "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encodedRunner" + & ssh.exe @commonArgs $sshTarget "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -OutputFormat Text -EncodedCommand $encodedRunner" if ($LASTEXITCODE -ne 0) { throw "remote Muninn binary deploy failed with exit code $LASTEXITCODE" } diff --git a/scripts/health-muninn.ps1 b/scripts/health-muninn.ps1 index 579fae5..01246bb 100644 --- a/scripts/health-muninn.ps1 +++ b/scripts/health-muninn.ps1 @@ -71,18 +71,18 @@ function Invoke-RavenUploadedPowerShell { $remoteRunner = @" `$ErrorActionPreference = "Stop" +`$ProgressPreference = "SilentlyContinue" try { & "$remotePsPath" - `$code = `$LASTEXITCODE + exit 0 } finally { Remove-Item -LiteralPath "$remotePsPath" -Force -ErrorAction SilentlyContinue } -exit `$code "@ $encodedRunner = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteRunner)) $commonArgs = Get-SshCommonArgs $sshTarget = Get-SshTarget -Target $RavenHost - & ssh.exe @commonArgs $sshTarget "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encodedRunner" + & ssh.exe @commonArgs $sshTarget "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -OutputFormat Text -EncodedCommand $encodedRunner" } finally { Remove-Item -LiteralPath $localTempRoot -Recurse -Force -ErrorAction SilentlyContinue } diff --git a/scripts/restart-muninn.ps1 b/scripts/restart-muninn.ps1 index 9c4c8e1..05bf908 100644 --- a/scripts/restart-muninn.ps1 +++ b/scripts/restart-muninn.ps1 @@ -230,18 +230,18 @@ function Invoke-RavenUploadedPowerShell { $remoteRunner = @" `$ErrorActionPreference = "Stop" +`$ProgressPreference = "SilentlyContinue" try { & "$remotePsPath" - `$code = `$LASTEXITCODE + exit 0 } finally { Remove-Item -LiteralPath "$remotePsPath" -Force -ErrorAction SilentlyContinue } -exit `$code "@ $encodedRunner = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($remoteRunner)) $commonArgs = Get-SshCommonArgs $sshTarget = Get-SshTarget -Target $RavenHost - & ssh.exe @commonArgs $sshTarget "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encodedRunner" + & ssh.exe @commonArgs $sshTarget "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -OutputFormat Text -EncodedCommand $encodedRunner" } finally { Remove-Item -LiteralPath $localTempRoot -Recurse -Force -ErrorAction SilentlyContinue }