Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Improve error logging and continue when there are insufficient permissions (#315)
Dustin Deckerba6ea9d42f37
diff --git a/pkg/sources/gitlab/gitlab.go b/pkg/sources/gitlab/gitlab.goindex 179de6d4b..2571c9e85 100644--- a/pkg/sources/gitlab/gitlab.go+++ b/pkg/sources/gitlab/gitlab.go@@ -160,7 +160,7 @@ func (s *Source) newClient() (*gitlab.Client, error) {func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, error) {// projects without repo will get user projects, groups projects, and subgroup projects.user, _, err := apiClient.Users.CurrentUser()- //TODO what happens if the user is anonymous+if err != nil {return nil, errors.Errorf("unable to authenticate using: %s", s.authMethod)}@@ -173,7 +173,7 @@ func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, erfor {userProjects, res, err := apiClient.Projects.ListUserProjects(user.ID, projectQueryOptions)if err != nil {- return nil, errors.Errorf("received error on listing projects: %s\n", err)+ return nil, errors.Errorf("received error on listing user projects: %s\n", err)}for _, prj := range userProjects {projects[prj.ID] = prj@@ -197,7 +197,7 @@ func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, erfor {groupList, res, err := apiClient.Groups.ListGroups(&listGroupsOptions)if err != nil {- return nil, errors.Errorf("received error on listing projects: %s\n", err)+ return nil, errors.Errorf("received error on listing groups, you probably don't have permissions to do that: %s\n", err)}groups = append(groups, groupList...)listGroupsOptions.Page = res.NextPage@@ -214,7 +214,8 @@ func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, erfor {grpPrjs, res, err := apiClient.Groups.ListGroupProjects(group.ID, listGroupProjectOptions)if err != nil {- return nil, errors.Errorf("received error on listing projects: %s\n", err)+ log.WithError(err).WithField("group", group.FullPath).Warn("received error on listing group projects, you probably don't have permissions to do that")+ break}for _, prj := range grpPrjs {projects[prj.ID] = prj