diff --git a/motor/discovery/gitlab/gitlab.go b/motor/discovery/gitlab/gitlab.go index 2d95ee6ee3..4a9dda03c8 100644 --- a/motor/discovery/gitlab/gitlab.go +++ b/motor/discovery/gitlab/gitlab.go @@ -131,8 +131,6 @@ func (r *Resolver) Resolve(ctx context.Context, root *asset.Asset, pCfg *provide }) if pCfg.IncludesOneOfDiscoveryTarget(common.DiscoveryAuto, common.DiscoveryAll, DiscoveryProject) { - p.Client().Projects.ListProjects(&gitlab.ListProjectsOptions{}) - for _, project := range grp.Projects { clonedConfig := pCfg.Clone() if clonedConfig.Options == nil { diff --git a/resources/packs/gitlab/gitlab.go b/resources/packs/gitlab/gitlab.go index 8ecf319e17..65e52cbcaa 100644 --- a/resources/packs/gitlab/gitlab.go +++ b/resources/packs/gitlab/gitlab.go @@ -2,9 +2,9 @@ package gitlab import ( "errors" - "net/url" "strconv" + "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/motor/providers" provider "go.mondoo.com/cnquery/motor/providers/gitlab" "go.mondoo.com/cnquery/resources" @@ -111,18 +111,28 @@ func (g *mqlGitlabProject) init(args *resources.Args) (*resources.Args, GitlabPr if err != nil { return nil, nil, err } - - project, _, err := gt.Client().Projects.GetProject(url.QueryEscape(gt.GroupPath)+"/"+url.QueryEscape(gt.ProjectPath), nil) + obj, err := g.MotorRuntime.CreateResource("gitlab.group") if err != nil { return nil, nil, err } + gr := obj.(*mqlGitlabGroup) - (*args)["id"] = int64(project.ID) - (*args)["name"] = project.Name - (*args)["path"] = project.Path - (*args)["namespace"] = project.Namespace.Name - (*args)["description"] = project.Description - (*args)["visibility"] = string(project.Visibility) + rawResources, err := gr.Projects() + if err != nil { + return nil, nil, err + } + matcher := gt.ProjectPath + for i := range rawResources { + proj := rawResources[i].(*mqlGitlabProject) + mqlPath, err := proj.Path() + if err != nil { + log.Error().Err(err).Msg("project is not initialized") + return nil, nil, err + } + if mqlPath == matcher { + return args, proj, nil + } + } return args, nil, nil }