Alerting: Make silence authz service check rule group permissions #86470
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.
What is this feature?
This PR updates silence authorization service to tighten up the security and check if user can read rules for which it tries to read or write a silence.
To check that permission, the service has to fetch all rules in the group and check the user's permissions.
Why do we need this feature?
Silences are protected by folder UID scope only. Rules are protected by intersection of folder UID and Data source UID. Therefore, in GE there is a possibility that a user can see and manage silences for rules that it cannot see due to lack of data source permissions.
Who is this feature for?
Grafana Enterprise users
Special notes for your reviewer:
The pattern I chose is similar to what we do elsewhere (e.g. folders): I gather the list of rule UIDs and then resolve them to rule groups. Performance-wise it's ok because we have an index that meets the filter requirement. However, the weak spot here is that with a big number of rule-specific silences, this could exceed limits on SQL queries.
Please check that: