fix: replace shell_exec/exec with Process facade for security

This commit is contained in:
root
2026-05-23 17:14:38 +02:00
parent 14a40b9bb2
commit 2d5f018ff1
2 changed files with 6 additions and 7 deletions
@@ -1406,9 +1406,9 @@ final class AlertSettings extends Page implements HasForms
{
try {
$load = sys_getloadavg();
$cpuCount = (int) shell_exec('nproc 2>/dev/null') ?: 1;
$memoryUsage = shell_exec("free -m | awk '/Mem:/ {printf \"%d%% (%dMB / %dMB)\", $3/$2*100, $3, $2}'");
$diskUsage = shell_exec("df -h / | awk 'NR==2 {print $5 \" used\"}'");
$cpuCount = (int) Process::run('nproc 2>/dev/null')->output() ?: 1;
$memoryUsage = Process::run("free -m | awk '/Mem:/ {printf \"%d%% (%dMB / %dMB)\", $3/$2*100, $3, $2}'")->output();
$diskUsage = Process::run("df -h / | awk 'NR==2 {print $5 \" used\"}'")->output();
$html = '<div class="text-sm space-y-1">';
$html .= '<div><span class="text-gray-400">CPU Load:</span> <span class="text-green-400">' . $load[0] . '</span> (' . $cpuCount . ' cores)</div>';