Skip to content

hardening: prepared statements, PHP 7.4 idioms, and security fixes - #90

Open
somethingwithproof wants to merge 5 commits into
Cacti:developfrom
somethingwithproof:hardening/comprehensive
Open

somethingwithproof wants to merge 5 commits into
Cacti:developfrom
somethingwithproof:hardening/comprehensive

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Apr 9, 2026

Copy link
Copy Markdown
Member

Hardens and modernizes Mikrotik for PHP 7.4+.

  • Replace legacy isset() ternaries and assignment patterns with null coalescing operators.
  • Deserialize bulk-action selections without permitting classes, reject malformed payloads, and avoid warning noise.
  • Use a prepared DELETE with placeholders derived from the selected-device count.
  • Treat an empty selection as a no-op instead of issuing an empty IN-list query.

Validation:

  • PHP syntax check passes for mikrotik_users.php.

Copilot AI review requested due to automatic review settings April 9, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to harden MikroTik/Cacti plugin code by modernizing PHP 7.4+ idioms and reducing injection risk in request handling and SQL operations.

Changes:

  • Replaced isset(...) ? ... : ... patterns with ?? in multiple parsing/collection paths.
  • Hardened request deserialization by restricting unserialize() to disallow classes and defaulting invalid input to an empty array.
  • Switched a DELETE ... IN (...) query to use a prepared statement with dynamic placeholders.

Reviewed changes

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

File Description
RouterOS/routeros_api.class.php Uses null coalescing for parsed response values to simplify defaults.
poller_mikrotik.php Replaces isset ternaries with ?? for multiple RouterOS response fields.
mikrotik_users.php Hardens unserialize() usage and parameterizes a bulk delete query using placeholders.

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

Comment thread poller_mikrotik.php Outdated
Comment thread mikrotik_users.php Outdated
Comment thread mikrotik_users.php
@somethingwithproof
somethingwithproof force-pushed the hardening/comprehensive branch from d064f17 to a1d3d9b Compare April 9, 2026 09:00
somethingwithproof added a commit to somethingwithproof/plugin_mikrotik that referenced this pull request Jul 29, 2026
No workflow file existed on this branch, so pull_request CI never
triggered (checks showed as NONE). Copy the workflow already proven
on PR Cacti#90 so this branch gets real CI signal.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
somethingwithproof added a commit to somethingwithproof/plugin_mikrotik that referenced this pull request Jul 29, 2026
No workflow file existed on this branch, so pull_request CI never
triggered (checks showed as NONE). Copy the workflow already proven
on PR Cacti#90 so this branch gets real CI signal.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the hardening/comprehensive branch from 996ee1b to fd14578 Compare July 29, 2026 05:37
TheWitness pushed a commit that referenced this pull request Sep 18, 2026
* chore: add enterprise Dependabot configuration

* chore: standardize enterprise Dependabot configuration

* ci: add plugin integration test workflow

No workflow file existed on this branch, so pull_request CI never
triggered (checks showed as NONE). Copy the workflow already proven
on PR #90 so this branch gets real CI signal.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* chore: keep Dependabot PR scoped

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
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.

3 participants