hardening: prepared statements, PHP 7.4 idioms, and security fixes - #40
Open
somethingwithproof wants to merge 9 commits into
Open
hardening: prepared statements, PHP 7.4 idioms, and security fixes#40somethingwithproof wants to merge 9 commits into
somethingwithproof wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR consolidates several PHP 7.4+ mechanical hardening changes (null coalescing operators, some shell escaping, and minor query hardening) across the HMIB plugin and SNMP helper code.
Changes:
- Replace
isset()ternaries /!isset()assignments with??/??=in multiple files. - Add additional shell-escaping / numeric casting for CLI invocations.
- Tighten one SQL update by casting an ID to integer.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
snmp.php |
Uses ??= for global defaults and adds numeric casting before invoking snmpget. |
poller_hmib.php |
Replaces isset() ternary with null coalescing for date parsing. |
poller_graphs.php |
Escapes configured PHP binary path and base path used in CLI commands. |
hmib.php |
Uses ??= for session-cached graph template/host lists. |
hmib_types.php |
Casts host_type update ID to int and uses ?? when injecting form variables. |
Comments suppressed due to low confidence (1)
hmib_types.php:396
- This UPDATE query still concatenates $known['sysObjectID'] and $known['sysDescrMatch'] directly into LIKE/RLIKE expressions without quoting/escaping, which leaves a SQL injection vector if those fields contain quotes (these values are user-controlled via the Host Types UI/import). Use db_execute_prepared with placeholders (building the LIKE patterns in parameters) and ensure the RLIKE patterns are passed as parameters/escaped appropriately.
db_execute('UPDATE plugin_hmib_hrSystem SET host_type=' . (int) $known['id'] . "
WHERE host_type=0 AND (sysObjectID LIKE '%" . $known['sysObjectID'] . "%' AND
sysDescr LIKE '%" . $known['sysDescrMatch'] . "%')
OR (sysObjectID RLIKE '" . $known['sysObjectID'] . "' AND
sysDescr RLIKE '" . $known['sysDescrMatch'] . "')");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
somethingwithproof
force-pushed
the
hardening/comprehensive
branch
from
April 9, 2026 09:00
454e566 to
11ffc52
Compare
This was referenced Apr 11, 2026
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
force-pushed
the
hardening/comprehensive
branch
from
July 29, 2026 05:37
c6a53a5 to
096873d
Compare
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidated hardening PR:
5 files changed, 13 insertions(+), 14 deletions(-)
All changes are mechanical transforms with zero behavioral impact. PHP 7.4+ compatible.