Skip to content

Conversation

@TheWitness
Copy link
Member

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the maint plugin to address unsafe unserialization when processing selected schedule/device items, along with a version bump and changelog cleanup.

Changes:

  • Replace direct unserialize() usage with sanitize_unserialize_selected_items() for selected_items handling.
  • Add CHANGELOG.md and remove the embedded changelog from README.md.
  • Bump plugin version to 1.3 and update copyright year.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
setup.php Switches selected-items parsing to a sanitized unserialize helper in device actions (but currently contains a variable mismatch bug).
README.md Removes old embedded changelog content and updates copyright year.
INFO Bumps plugin version from 1.2 to 1.3.
CHANGELOG.md Adds a dedicated changelog file for releases (contains a minor typo).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +268 to +272
$selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));

if (is_array($selected)) {
foreach ($selected as $host_id) {
db_execute_prepared('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (1, ?, ?)', array((int)$host_id, (int)$schedule_id));
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$selected_items is assigned from sanitize_unserialize_selected_items(...), but the subsequent is_array()/foreach use $selected, which is undefined. This prevents any devices from being associated with the new schedule (and will raise a PHP notice). Use $selected_items consistently in the is_array check and foreach loop (or match maint.php’s pattern of checking $selected_items != false).

Copilot uses AI. Check for mistakes.
Comment on lines +290 to +294
$selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
if (is_array($selected)) {
foreach ($selected as $host_id) {
db_execute_prepared('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (1, ?, ?)', array((int)$host_id, $schedule_id));
$added++;
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$selected_items is populated, but $selected is used in is_array()/foreach, so no devices will be added to the chosen schedule. Replace $selected with $selected_items here as well.

Copilot uses AI. Check for mistakes.
* issue#15: Fix webseer tab to not show items before schedule is created
* feature#14: Webseer tab functional (webseer plugin update required to use schedule)
* feature#18: Device tab filter
* featuer#29: Add Servcheck
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in changelog entry: "featuer#29" should be "feature#29".

Suggested change
* featuer#29: Add Servcheck
* feature#29: Add Servcheck

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants