Repository navigation
fix(thold): check graph permission on every threshold action - #940
Open
somethingwithproof wants to merge 11 commits into
Open
somethingwithproof wants to merge 11 commits into
somethingwithproof wants to merge 11 commits into
Conversation
The enable and disable actions now require the threshold's graph to be one the user may view (is_thold_allowed()), as the acknowledgment actions already do. Adds a shared is_graph_allowed() test stub and coverage. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
save_thold() checked graph permission only when updating an existing threshold. The same is_thold_allowed_graph() check now applies to a new threshold. The wizard's first save still passes because it carries no graph yet. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
thold_edit() now resolves the threshold's graph (from its data source when the row has none) and redirects with a message when the user may not view it. A threshold that resolves to no graph is refused. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…a source save_thold() now checks an existing threshold against the graph stored on its row, and requires the chosen data source to be on a graph the user may view and that matches any submitted graph. A data source that resolves to no graph is refused. Extends the is_graph_allowed() test stub with a per-graph allow list. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
save_thold() now sets host_id from the checked data source (or its graph) and uses the submitted value only when neither resolves a device. The device is used when alerts are evaluated and notifications are built, so it should come from the data the threshold watches. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…lates thold_create_from_template(), used by autocreate, the device, graph and data source actions and the device and graph creation hooks, now skips a graph the logged in user may not view and raises one "Permission Denied" message. Calls with no logged in user (automation, the poller and the command line) are unchanged. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
is_thold_allowed_graph() now refuses an empty graph id. is_thold_allowed() checks the graph stored on the threshold's row, or the graph of its data source when the row has none, and refuses when neither resolves. The enable, disable, acknowledge, save and bulk actions use it. thold_add_graphs_action_execute() checks the graph before creating thresholds from a template. The edit form for a new threshold checks the requested graph and that the chosen data source is on it, using the same check as the form for an existing threshold. The authorization tests cover each of these and share their request and data source setup through helpers. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ied references Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ource The edit form for a new threshold now also checks that the chosen data source item belongs to the requested data source, which the form describes, as well as being on the checked graph. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Reapplying a template's suggested names checked the graph stored on each threshold row, which is now refused when empty. It now uses is_thold_allowed(), which resolves the graph from the data source when the row has none, so thresholds without a stored graph are renamed again. 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.



Problem
Some threshold actions checked only the page realm, not whether the logged in user may view the threshold's graph, which the rest of the plugin checks with
is_thold_allowed()/is_thold_allowed_graph().Fix
is_thold_allowed_graph()refuses an empty graph id.is_thold_allowed()checks the graph stored on the threshold, or the graph of its data source when the row has none, and refuses when neither resolves. Enable, disable, acknowledge, save and the bulk actions therefore need a graph the user may view.host_idis taken from the checked data source (or its graph); the submitted value is used only when neither resolves a device.thold_create_from_template()(autocreate, the bulk actions, the creation hooks) skips graphs the user may not view with one "Permission Denied" message, and the single-graph template add checks its graph first. With no logged in user (automation, the poller, the command line) nothing changes.Administrators and users with permission on the graph see no change. A threshold whose row has no graph and whose data source is on no graph can no longer be enabled, disabled or edited by anyone; the existing cleanup removes it with its data source. Reapplying a template's suggested names uses the same resolving check. The shared graph lookup lives in
includes/queries.php(thold_resolve_graph_id(),thold_threshold_graph_id(),thold_edit_allowed()).Verification
tests/Unit/ThresholdObjectAuthorizationTest.php(37 tests) covers each check, a device with mixed permissions, thresholds with no stored graph, and the no-session case; the new tests fail without the change.thold.phpruns at load time and is not in the coverage report, so its two edit-form call sites are covered throughthold_edit_allowed()).check-i18n-pot.phppasses;cacti.potgains one string ("You are not authorized to access this Threshold.").Touches
includes/threshold_api.php,thold.php,includes/templates.phpandtests/bootstrap-unit.php, which #922, #923 and #928 also edit; the branch merges cleanly with each of them.cacti.potmay need regenerating after #928, whichever merges second.CHANGELOG line for the release PR:
* issue#939: Check graph permission on every threshold action and take a threshold's device from its data sourceFixes #939