Merge pull request #26 from GoodOlClint/fix/f039-f084-quick-fixes

fix: resolve F039 bare catches and F084 session secret exposure
This commit is contained in:
GoodOlClint
2026-03-24 18:41:01 -05:00
committed by GitHub
3 changed files with 66 additions and 3 deletions
+2 -1
View File
@@ -550,8 +550,9 @@ namespace PSProxmoxVE.Core.Services
client.PostAsync($"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/agent/ping").GetAwaiter().GetResult();
return true;
}
catch
catch (PSProxmoxVE.Core.Exceptions.PveApiException)
{
// Treat API-level failures for this endpoint as "guest agent not responding".
return false;
}
finally
@@ -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,10 @@ namespace PSProxmoxVE.Cmdlets.Vms
var vm = vmService.GetVm(session, Node, vmId);
WriteObject(vm);
}
catch
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
{
VmId = vmId,
+59
View File
@@ -1356,5 +1356,64 @@
</TableControl>
</View>
<!-- PSProxmoxVE.Core.Authentication.PveSession -->
<!-- Hides sensitive properties (Ticket, ApiToken, CsrfToken) from default output -->
<View>
<Name>PSProxmoxVE.Core.Authentication.PveSession</Name>
<ViewSelectedBy>
<TypeName>PSProxmoxVE.Core.Authentication.PveSession</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Hostname</Label>
<Width>25</Width>
<Alignment>Left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Port</Label>
<Width>6</Width>
<Alignment>Right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>AuthMode</Label>
<Width>10</Width>
<Alignment>Left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Expired</Label>
<Width>8</Width>
<Alignment>Left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Version</Label>
<Width>15</Width>
<Alignment>Left</Alignment>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Hostname</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Port</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>AuthMode</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>if ($_.IsExpired) { 'Yes' } else { 'No' }</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>if ($_.ServerVersion) { $_.ServerVersion.ToString() } else { 'Unknown' }</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>