From c0a37d5ef3253b0e16519f8edaba6936c5539884 Mon Sep 17 00:00:00 2001 From: Clint Branham Date: Tue, 24 Mar 2026 18:18:56 -0500 Subject: [PATCH 1/3] fix: resolve F039 bare catches and F084 session secret exposure F039 (regressed): Replace bare catch blocks with filtered catches that exclude OutOfMemoryException and StackOverflowException, per D004. - VmService.PingGuestAgent: catch now filters fatal exceptions - ImportPveOvaCmdlet: catch now filters fatal exceptions + WriteVerbose F084 (new): Add PveSession format view to PSProxmoxVE.format.ps1xml that shows only Hostname, Port, AuthMode, IsExpired, and ServerVersion in default table output. Sensitive properties (Ticket, ApiToken, CsrfToken) are hidden from default display but remain accessible via Select-Object * or direct property access. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/PSProxmoxVE.Core/Services/VmService.cs | 2 +- .../Cmdlets/Vms/ImportPveOvaCmdlet.cs | 3 +- src/PSProxmoxVE/PSProxmoxVE.format.ps1xml | 59 +++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/PSProxmoxVE.Core/Services/VmService.cs b/src/PSProxmoxVE.Core/Services/VmService.cs index ff6a47e..412e1ab 100644 --- a/src/PSProxmoxVE.Core/Services/VmService.cs +++ b/src/PSProxmoxVE.Core/Services/VmService.cs @@ -550,7 +550,7 @@ namespace PSProxmoxVE.Core.Services client.PostAsync($"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/agent/ping").GetAwaiter().GetResult(); return true; } - catch + catch (Exception ex) when (ex is not OutOfMemoryException and not StackOverflowException) { return false; } diff --git a/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs b/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs index a834c66..dd00cee 100644 --- a/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs +++ b/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs @@ -274,9 +274,10 @@ namespace PSProxmoxVE.Cmdlets.Vms var vm = vmService.GetVm(session, Node, vmId); WriteObject(vm); } - catch + catch (Exception ex) when (ex is not OutOfMemoryException and not StackOverflowException) { // If the VM isn't queryable yet (e.g. disk import still running), return basic info + WriteVerbose($"VM retrieval failed, returning basic info: {ex.Message}"); WriteObject(new PveVm { VmId = vmId, diff --git a/src/PSProxmoxVE/PSProxmoxVE.format.ps1xml b/src/PSProxmoxVE/PSProxmoxVE.format.ps1xml index 39d60c8..9cbb8a5 100644 --- a/src/PSProxmoxVE/PSProxmoxVE.format.ps1xml +++ b/src/PSProxmoxVE/PSProxmoxVE.format.ps1xml @@ -1356,5 +1356,64 @@ + + + + PSProxmoxVE.Core.Authentication.PveSession + + PSProxmoxVE.Core.Authentication.PveSession + + + + + + 25 + Left + + + + 6 + Right + + + + 10 + Left + + + + 8 + Left + + + + 15 + Left + + + + + + + Hostname + + + Port + + + AuthMode + + + if ($_.IsExpired) { 'Yes' } else { 'No' } + + + if ($_.ServerVersion) { $_.ServerVersion.ToString() } else { 'Unknown' } + + + + + + + From d91c93aca29cfa7a315f97495e3580a2c182c31c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 23:31:32 +0000 Subject: [PATCH 2/3] Initial plan From f400336803947e12464dcb82febb3df526f49c07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 23:35:27 +0000 Subject: [PATCH 3/3] fix: narrow exception catches in PingGuestAgent and ImportPveOvaCmdlet Co-authored-by: GoodOlClint <151449+GoodOlClint@users.noreply.github.com> Agent-Logs-Url: https://github.com/GoodOlClint/PSProxmoxVE/sessions/e7930807-5536-4c55-96f8-0712aee44e00 --- src/PSProxmoxVE.Core/Services/VmService.cs | 3 ++- src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PSProxmoxVE.Core/Services/VmService.cs b/src/PSProxmoxVE.Core/Services/VmService.cs index 412e1ab..2f4aae0 100644 --- a/src/PSProxmoxVE.Core/Services/VmService.cs +++ b/src/PSProxmoxVE.Core/Services/VmService.cs @@ -550,8 +550,9 @@ namespace PSProxmoxVE.Core.Services client.PostAsync($"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/agent/ping").GetAwaiter().GetResult(); return true; } - catch (Exception ex) when (ex is not OutOfMemoryException and not StackOverflowException) + catch (PSProxmoxVE.Core.Exceptions.PveApiException) { + // Treat API-level failures for this endpoint as "guest agent not responding". return false; } finally diff --git a/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs b/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs index dd00cee..1766a9c 100644 --- a/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs +++ b/src/PSProxmoxVE/Cmdlets/Vms/ImportPveOvaCmdlet.cs @@ -2,8 +2,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Management.Automation; +using System.Net; using Newtonsoft.Json.Linq; using PSProxmoxVE.Core.Client; +using PSProxmoxVE.Core.Exceptions; using PSProxmoxVE.Core.Models.Vms; using PSProxmoxVE.Core.Services; @@ -274,9 +276,9 @@ namespace PSProxmoxVE.Cmdlets.Vms var vm = vmService.GetVm(session, Node, vmId); WriteObject(vm); } - catch (Exception ex) when (ex is not OutOfMemoryException and not StackOverflowException) + catch (PveApiException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { - // If the VM isn't queryable yet (e.g. disk import still running), return basic info + // VM not yet queryable (e.g. disk import still in progress); return basic info WriteVerbose($"VM retrieval failed, returning basic info: {ex.Message}"); WriteObject(new PveVm {