Alerting: Disallow invalid rule namespace UIDs in provisioning API (#83938)
* Disallow invalid rule namespace UIDs in provisioning Reject requests with rules that reference a nonexistent folder or have an empty folder uid
This commit is contained in:
@@ -85,9 +85,9 @@ func (prov *defaultAlertRuleProvisioner) provisionRule(
|
||||
return err
|
||||
} else if err != nil {
|
||||
prov.logger.Debug("creating rule", "uid", rule.UID, "org", rule.OrgID)
|
||||
// 0 is passed as userID as then the quota logic will only check for
|
||||
// the organization quota, as we don't have any user scope here.
|
||||
_, err = prov.ruleService.CreateAlertRule(ctx, rule, alert_models.ProvenanceFile, 0)
|
||||
// a nil user is passed in as then the quota logic will only check for
|
||||
// the organization quota since we don't have any user scope here.
|
||||
_, err = prov.ruleService.CreateAlertRule(ctx, nil, rule, alert_models.ProvenanceFile)
|
||||
} else {
|
||||
prov.logger.Debug("updating rule", "uid", rule.UID, "org", rule.OrgID)
|
||||
_, err = prov.ruleService.UpdateAlertRule(ctx, rule, alert_models.ProvenanceFile)
|
||||
|
||||
@@ -275,6 +275,7 @@ func (ps *ProvisioningServiceImpl) ProvisionAlerting(ctx context.Context) error
|
||||
ruleService := provisioning.NewAlertRuleService(
|
||||
st,
|
||||
st,
|
||||
ps.folderService,
|
||||
ps.dashboardService,
|
||||
ps.quotaService,
|
||||
ps.SQLStore,
|
||||
|
||||
Reference in New Issue
Block a user