Skip to content

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

Merged
TheWitness merged 8 commits into
Cacti:developfrom
somethingwithproof:hardening/comprehensive
Jul 21, 2026
Merged

hardening: prepared statements, PHP 7.4 idioms, and security fixes#365
TheWitness merged 8 commits into
Cacti:developfrom
somethingwithproof:hardening/comprehensive

Conversation

@somethingwithproof

Copy link
Copy Markdown
Contributor

Consolidated hardening PR:

  • Migrate isset() ternary to null coalescing (??) operator
  • Migrate !isset() assign patterns to ??= operator
  • Parameterize SQL queries with variable interpolation
  • Fix RLIKE/LIKE injection where applicable

4 files changed, 35 insertions(+), 37 deletions(-)

All changes are mechanical transforms with zero behavioral impact. PHP 7.4+ compatible.

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

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

Hardening-focused update for the Intropage plugin, aiming to reduce injection risk and modernize some PHP idioms in panel and admin code paths.

Changes:

  • Added explicit integer casting for SQL-concatenated numeric values (template IDs, LIMIT counts, ports).
  • Replaced isset()-based ternaries with ?? for defaulting values.
  • Introduced a prepared statement for graph_tree_items parent lookups and used ??= for session defaulting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
panellib/busiest.php Casts interpolated numeric values used in SQL query construction (data_template_id, LIMIT).
panellib/analyze.php Casts snmp_port in a host lookup query; uses a prepared statement for tree parent traversal.
include/settings.php Uses null coalescing (??) for injecting default form variables and panel defaults.
include/functions.php Uses null coalescing (??) for panel height defaults; uses ??= for session initialization.

Comment thread include/functions.php
xmacan
xmacan previously approved these changes Apr 9, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Add targeted tests for prepared statement migration, output escaping,
auth guard presence, CSRF token validation, redirect safety, and
PHP 7.4 compatibility. Tests use source-scan patterns that verify
security invariants without requiring the Cacti database.

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 6e5fa70 to 8337113 Compare July 14, 2026 10:47
@TheWitness
TheWitness merged commit 7990123 into Cacti:develop Jul 21, 2026
4 checks passed
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.

4 participants