Prevent moving a k6 folder (#88884)

* iam-716 - prevent a folder move operation when the folder's uid or any of its parents uids begin with k6-app

* fox folder move check and only list non-k6 folders to users

* adding tests for moving

* add a test for listing folders

* fix the other tests

* use method that adds folder parent

---------

Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com>
This commit is contained in:
Aaron Godin
2024-06-10 09:17:51 -05:00
committed by GitHub
co-authored by IevaVasiljeva
parent 89a0bec208
commit 59a6a6513f
5 changed files with 119 additions and 9 deletions
+6
View File
@@ -64,7 +64,13 @@ func (hs *HTTPServer) GetFolders(c *contextmodel.ReqContext) response.Response {
}
hits := make([]dtos.FolderSearchHit, 0)
requesterIsSvcAccount := c.SignedInUser.GetID().Namespace() == identity.NamespaceServiceAccount
for _, f := range folders {
// only list k6 folders when requested by a service account - prevents showing k6 folders in the UI for users
if (f.UID == accesscontrol.K6FolderUID || f.ParentUID == accesscontrol.K6FolderUID) && !requesterIsSvcAccount {
continue
}
hits = append(hits, dtos.FolderSearchHit{
ID: f.ID, // nolint:staticcheck
UID: f.UID,