Repository navigation
fix: use core SQL, shell and escaping APIs in the Databases, Filters and CLI scripts - #322
Open
somethingwithproof wants to merge 7 commits into
Open
somethingwithproof wants to merge 7 commits into
somethingwithproof wants to merge 7 commits into
Conversation
The registry details lookup on the Databases page built its WHERE clause from the keys of the row id sent by the browser. Column names can not be bound, so only columns of the table are now accepted and any other key returns no row. The Disable, Enable and Delete actions of the Filters page and the poller's query for due schedules now bind their values instead of concatenating them. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The Databases page printed registry, DNS cache and ARIN values, and the source options of its filters, without escaping. The Filters page did the same with the listener name in the list and the Filter names in the action confirmation. Escape them with html_escape(). Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
flowview_bulkarin.php passed the whois path, provider and CIDR to the shell unescaped. Escape them with cacti_escapeshellcmd() and cacti_escapeshellarg(), as core does for external commands. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The upgrade script wrote plugin_flowview_version straight into the settings table. set_config_option() performs the same REPLACE and keeps Cacti's settings handling in one place. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
A unit test runs flowview_get_item_details() against the unit doubles and checks that only table columns reach the query. End-to-end tests log in to a served Cacti and check the details lookup, its realm check, the escaped Databases and Filters output and Filter deletion, and run the bulk ARIN loader and the poller as subprocesses. The end-to-end tests skip unless FLOWVIEW_E2E_* is set. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Serve the installed Cacti with PHP's built-in server and run tests/Integration after the unit tests, with the database and host settings in FLOWVIEW_E2E_*. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
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.



Fixes #321
Intent: replace hand-built SQL, shell commands and HTML output with the Cacti core API in files that #297 does not touch.
Scope:
flowview_databases.php(details lookup accepts only table columns; registry, DNS cache and Source values escaped),flowview_filters.php(Filter and listener names escaped; actions use prepared statements),flowview_process.php(bound schedule query),flowview_bulkarin.php(escaped whois arguments),flowview_upgrade.php(set_config_option()). New tests and two CI steps. Findings in #297's files are listed in the issue, deferred. No CHANGELOG entry, as #297 edits CHANGELOG.md.Risk: low. Valid requests behave as before; a details request whose keys are not columns of the table now returns no row.
Verification (local, PHP 8.5, MariaDB 11.8, Cacti 1.2.x): existing suite 410 passed; new unit test 4 passed; new end-to-end tests 10 passed (logged-in HTTP through
php -S, a user without the realm, and the bulk ARIN loader and poller run as subprocesses). Reverting each escaping, allow-list and shell fix makes at least one test fail. Hosted CI not yet run.