hardening: migrate gexport SQL helpers to prepared variants#67
hardening: migrate gexport SQL helpers to prepared variants#67somethingwithproof wants to merge 3 commits intoCacti:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the plugin_gexport database access paths by migrating remaining raw SQL helper call sites (db_fetch_*, db_execute) to prepared/parameterized variants to reduce SQL injection risk and standardize query patterns.
Changes:
- Updated
setup.phppoller + upgrade checks to usedb_fetch_*_preparedhelpers. - Converted
gexport.phpexport deletion to a parameterizedIN (...)prepared delete and migrated list/count + running-state queries to prepared fetch helpers. - Added a lightweight regression script to verify prepared helper usage in touched files.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_prepared_statements.php |
Adds regression checks to ensure prepared helper usage is present at key call sites. |
setup.php |
Replaces raw exports query and plugin version lookup with prepared variants. |
gexport.php |
Parameterizes bulk delete, count/list queries, running-state query, and site/tree name aggregation queries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| $setup_contents = file_get_contents(__DIR__ . '/../setup.php'); | ||
| $gexport_contents = file_get_contents(__DIR__ . '/../gexport.php'); | ||
|
|
There was a problem hiding this comment.
Addressed in 2361e7e: added explicit readability assertions for both source files and only then run regex/substring assertions.
|
Incorporated follow-up feedback in |
Summary
plugin_gexportSQL helper call sites to prepared variantsIN (...)prepared deleteTests
php -l gexport.phpphp -l setup.phpphp -l tests/test_prepared_statements.phpphp tests/test_prepared_statements.phpCloses #66