LibraryPanels: Fix folderUid nil pointer dereference (#93400)
This commit is contained in:
@@ -145,7 +145,7 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
|
|||||||
|
|
||||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||||
// folderUID *string will be changed to string
|
// folderUID *string will be changed to string
|
||||||
var folderUID string
|
var folderUID = ""
|
||||||
if cmd.FolderUID != nil {
|
if cmd.FolderUID != nil {
|
||||||
folderUID = *cmd.FolderUID
|
folderUID = *cmd.FolderUID
|
||||||
}
|
}
|
||||||
@@ -172,9 +172,9 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
|
|||||||
|
|
||||||
err = l.SQLStore.WithTransactionalDbSession(c, func(session *db.Session) error {
|
err = l.SQLStore.WithTransactionalDbSession(c, func(session *db.Session) error {
|
||||||
if l.features.IsEnabled(c, featuremgmt.FlagLibraryPanelRBAC) {
|
if l.features.IsEnabled(c, featuremgmt.FlagLibraryPanelRBAC) {
|
||||||
allowed, err := l.AccessControl.Evaluate(c, signedInUser, ac.EvalPermission(ActionLibraryPanelsCreate, dashboards.ScopeFoldersProvider.GetResourceScopeUID(*cmd.FolderUID)))
|
allowed, err := l.AccessControl.Evaluate(c, signedInUser, ac.EvalPermission(ActionLibraryPanelsCreate, dashboards.ScopeFoldersProvider.GetResourceScopeUID(folderUID)))
|
||||||
if !allowed {
|
if !allowed {
|
||||||
return fmt.Errorf("insufficient permissions for creating library panel in folder with UID %s", *cmd.FolderUID)
|
return fmt.Errorf("insufficient permissions for creating library panel in folder with UID %s", folderUID)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user