From 7ad63904a3ae548c01a24f9c53869f48c996c056 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Sun, 15 Mar 2026 16:07:43 -0700 Subject: [PATCH 1/3] security: migrate maint SQL helpers to prepared variants --- maint.php | 15 ++++---- setup.php | 5 +-- tests/test_prepared_statements.php | 58 ++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 tests/test_prepared_statements.php diff --git a/maint.php b/maint.php index af10520..583223c 100644 --- a/maint.php +++ b/maint.php @@ -924,9 +924,10 @@ function changemaintType () { function schedules(): void { global $actions, $maint_types, $maint_intervals, $yesno; - $schedules = db_fetch_assoc('SELECT * + $schedules = db_fetch_assoc_prepared('SELECT * FROM plugin_maint_schedules - ORDER BY name'); + ORDER BY name', + array()); form_start('maint.php', 'chk'); @@ -1134,10 +1135,11 @@ function clearFilter() { "; diff --git a/tests/test_prepared_statements.php b/tests/test_prepared_statements.php new file mode 100644 index 0000000..7bf98d8 --- /dev/null +++ b/tests/test_prepared_statements.php @@ -0,0 +1,58 @@ + 0 ? 1 : 0); From 80dd24783991af9a6defe83e2820625debff883a Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Sun, 15 Mar 2026 17:16:33 -0700 Subject: [PATCH 2/3] fix: address prepared migration review feedback --- maint.php | 6 +++--- setup.php | 2 +- tests/test_prepared_statements.php | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/maint.php b/maint.php index 583223c..3c1f5a0 100644 --- a/maint.php +++ b/maint.php @@ -927,7 +927,7 @@ function schedules(): void { $schedules = db_fetch_assoc_prepared('SELECT * FROM plugin_maint_schedules ORDER BY name', - array()); + []); form_start('maint.php', 'chk'); @@ -1139,7 +1139,7 @@ function clearFilter() { FROM sites WHERE id IN (SELECT site_id FROM host) ORDER BY name', - array()); + []); if (cacti_sizeof($sites)) { foreach ($sites as $site) { @@ -1163,7 +1163,7 @@ function clearFilter() { $pollers = db_fetch_assoc_prepared('SELECT id, name FROM poller ORDER BY name', - array()); + []); if (cacti_sizeof($pollers)) { foreach ($pollers as $poller) { diff --git a/setup.php b/setup.php index 0253125..e56978a 100644 --- a/setup.php +++ b/setup.php @@ -301,7 +301,7 @@ function maint_device_action_prepare(array $save): array { $schedules = db_fetch_assoc_prepared('SELECT id, name, enabled, mtype, stime, etime, minterval FROM plugin_maint_schedules ORDER BY name', - array()); + []); $select = "