From 84307a00018dee3e5861e9f74af99c86c1ab42d3 Mon Sep 17 00:00:00 2001 From: Victoria Jeffrey Date: Tue, 19 Sep 2023 16:19:46 -0600 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20ensure=20we=20use=20the=20cr?= =?UTF-8?q?edential=20token=20for=20gitlab=20scan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- motor/discovery/gitlab/gitlab.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/motor/discovery/gitlab/gitlab.go b/motor/discovery/gitlab/gitlab.go index 5183a27784..2843f7045e 100644 --- a/motor/discovery/gitlab/gitlab.go +++ b/motor/discovery/gitlab/gitlab.go @@ -52,6 +52,10 @@ func (r *Resolver) Resolve(ctx context.Context, root *asset.Asset, pCfg *provide if err != nil { return nil, err } + rootToken, err := credsResolver.GetCredential(root.Connections[0].Credentials[0]) + if err == nil && rootToken != nil { + pCfg.Credentials = []*vault.Credential{rootToken} + } defaultName := root.Name list := []*asset.Asset{} From 1d334aa34dd8a9faa5b0e13a6d3be04b5b8e87cf Mon Sep 17 00:00:00 2001 From: Victoria Jeffrey Date: Tue, 19 Sep 2023 18:52:23 -0600 Subject: [PATCH 2/2] add some safeguards --- motor/discovery/gitlab/gitlab.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/motor/discovery/gitlab/gitlab.go b/motor/discovery/gitlab/gitlab.go index 2843f7045e..878aecf484 100644 --- a/motor/discovery/gitlab/gitlab.go +++ b/motor/discovery/gitlab/gitlab.go @@ -52,9 +52,11 @@ func (r *Resolver) Resolve(ctx context.Context, root *asset.Asset, pCfg *provide if err != nil { return nil, err } - rootToken, err := credsResolver.GetCredential(root.Connections[0].Credentials[0]) - if err == nil && rootToken != nil { - pCfg.Credentials = []*vault.Credential{rootToken} + if len(root.Connections) > 0 && root.Connections[0].Credentials != nil && len(root.Connections[0].Credentials) > 0 { + gitlabToken, err := credsResolver.GetCredential(root.Connections[0].Credentials[0]) + if err == nil && gitlabToken != nil { + pCfg.Credentials = []*vault.Credential{gitlabToken} + } } defaultName := root.Name