Enhance Proxmox components with input validation, error handling, and UI improvements
This commit is contained in:
@@ -224,7 +224,8 @@ class System extends Component
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
// Reject unknown/unrecognised values to prevent arbitrary strings reaching the API
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function fetchCpuOptions(): array
|
||||
@@ -333,8 +334,10 @@ class System extends Component
|
||||
$resolvedCpu .= ',flags=' . $flags;
|
||||
}
|
||||
|
||||
$resolvedMachine = $this->machineType !== '' ? $this->resolveMachineValue($this->machineType) : null;
|
||||
|
||||
$payload = array_filter([
|
||||
'machine' => $this->machineType !== '' ? $this->resolveMachineValue($this->machineType) : null,
|
||||
'machine' => $resolvedMachine !== '' ? $resolvedMachine : null,
|
||||
'bios' => $this->biosType !== '' ? $this->biosType : null,
|
||||
'cpu' => $resolvedCpu,
|
||||
'kvm' => $this->kvmEnabled ? 1 : 0,
|
||||
@@ -434,6 +437,15 @@ class System extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
// Only allow removal of EFI disk and TPM devices via this method
|
||||
$isAllowed = (str_starts_with($deviceKey, 'efidisk') && isset($this->efiDisks[$deviceKey]))
|
||||
|| (str_starts_with($deviceKey, 'tpmstate') && isset($this->tpmDevices[$deviceKey]));
|
||||
|
||||
if (!$isAllowed) {
|
||||
$this->notify('Only EFI disk and TPM devices can be removed here.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check VM status - must be stopped to remove EFI/TPM devices
|
||||
if (!$this->status || $this->status->status !== 'stopped') {
|
||||
$this->notify('VM must be stopped to remove system devices.', 'error');
|
||||
|
||||
Reference in New Issue
Block a user