From 6c3a594a14ff27fcc963c93ec796c3ccde087778 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sat, 12 Sep 2026 18:56:00 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20review=20GATE=20A=20=E2=80=94=20reemplaz?= =?UTF-8?q?o=20de=20contrasenas=20sin=203er=20operando=20y=20ANSI=205.1-co?= =?UTF-8?q?mpat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wordpress/deploy.ps1: -replace no acepta tercer operando (count) en ninguna version de PS; bucle linea a linea (1a = root, 2a = MYSQL_PASSWORD) - los 4 deploy.ps1: escape ANSI con [char]27 en vez de backtick-e (incompatible con Windows PowerShell 5.1); guard solo con NO_COLOR --- hermes/deploy.ps1 | 6 ++++-- openclaw/deploy.ps1 | 6 ++++-- openwebui/deploy.ps1 | 6 ++++-- wordpress/deploy.ps1 | 27 ++++++++++++++++++++------- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/hermes/deploy.ps1 b/hermes/deploy.ps1 index f73b58f..cffe780 100644 --- a/hermes/deploy.ps1 +++ b/hermes/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } diff --git a/openclaw/deploy.ps1 b/openclaw/deploy.ps1 index 55a055f..809efe0 100644 --- a/openclaw/deploy.ps1 +++ b/openclaw/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } diff --git a/openwebui/deploy.ps1 b/openwebui/deploy.ps1 index 2e0bd08..0e9854f 100644 --- a/openwebui/deploy.ps1 +++ b/openwebui/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } diff --git a/wordpress/deploy.ps1 b/wordpress/deploy.ps1 index b10a17e..2ab7d4c 100644 --- a/wordpress/deploy.ps1 +++ b/wordpress/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } @@ -92,11 +94,22 @@ if (-not (Test-Path $EnvFile)) { $rng.GetBytes($Bytes); $WpPass = ($Bytes | ForEach-Object { $_.ToString('x2') }) -join '' $rng.Dispose() - # La 1a coincidencia es MYSQL_ROOT_PASSWORD, la 2a MYSQL_PASSWORD (orden del .env.example) - $Content = Get-Content $EnvFile -Raw - $Content = $Content -replace 'change-me-to-a-strong-password', $RootPass, 1 - $Content = $Content -replace 'change-me-to-a-strong-password', $WpPass, 1 - Set-Content $EnvFile -Value $Content -NoNewline + # 1a coincidencia en el fichero = MYSQL_ROOT_PASSWORD, 2a = MYSQL_PASSWORD. + # -replace no acepta tercer operando (count) en ninguna version de PS, + # asi que se recorre linea a linea. + $Lines = Get-Content $EnvFile + $Replaced = 0 + for ($i = 0; $i -lt $Lines.Count; $i++) { + if ($Lines[$i] -like '*change-me-to-a-strong-password*') { + if ($Replaced -eq 0) { + $Lines[$i] = $Lines[$i] -replace 'change-me-to-a-strong-password', $RootPass + } else { + $Lines[$i] = $Lines[$i] -replace 'change-me-to-a-strong-password', $WpPass + } + $Replaced++ + } + } + Set-Content $EnvFile -Value $Lines Info "Contrasenas generadas en $EnvFile" }