From 113c535124407cf176fd053469ea68ddee5e2f8b Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Sat, 17 Feb 2024 01:41:51 +0100 Subject: [PATCH] fix github scans Signed-off-by: Ivan Milchev --- providers/github/provider/provider.go | 8 +------- providers/github/resources/discovery.go | 17 +++++------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/providers/github/provider/provider.go b/providers/github/provider/provider.go index 0d71304965..a0e8fdfc5e 100644 --- a/providers/github/provider/provider.go +++ b/providers/github/provider/provider.go @@ -143,7 +143,7 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } } - asset.Connections[0].Id = conn.ID() + asset.Connections[0].Id = connId return plugin.NewRuntime( conn, callback, @@ -181,12 +181,6 @@ func (s *Service) detect(asset *inventory.Asset, conn *connection.GithubConnecti } asset.Platform = platform - - id, err := conn.Identifier() - if err != nil { - return err - } - asset.PlatformIds = []string{id} return nil } diff --git a/providers/github/resources/discovery.go b/providers/github/resources/discovery.go index 74b1fa8156..415bca3671 100644 --- a/providers/github/resources/discovery.go +++ b/providers/github/resources/discovery.go @@ -81,13 +81,6 @@ func discover(runtime *plugin.Runtime, targets []string) ([]*inventory.Asset, er return assetList, nil } -func cloneInventoryConf(invConf *inventory.Config) *inventory.Config { - invConfClone := invConf.Clone() - // We do not want to run discovery again for the already discovered assets - invConfClone.Discover = &inventory.Discovery{} - return invConfClone -} - func org(runtime *plugin.Runtime, orgName string, conn *connection.GithubConnection, targets []string) ([]*inventory.Asset, error) { assetList := []*inventory.Asset{} org, err := getMqlGithubOrg(runtime, orgName) @@ -99,7 +92,7 @@ func org(runtime *plugin.Runtime, orgName string, conn *connection.GithubConnect Name: org.Name.Data, Platform: connection.GithubOrgPlatform, Labels: map[string]string{}, - Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)}, + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithoutDiscovery(), inventory.WithParentConnectionId(conn.ID()))}, }) if stringx.Contains(targets, connection.DiscoveryRepos) || stringx.Contains(targets, connection.DiscoveryRepository) || stringx.Contains(targets, connection.DiscoveryAll) || stringx.Contains(targets, connection.DiscoveryAuto) { if stringx.Contains(targets, connection.DiscoveryRepos) || stringx.Contains(targets, connection.DiscoveryRepository) { @@ -112,7 +105,7 @@ func org(runtime *plugin.Runtime, orgName string, conn *connection.GithubConnect Name: org.Login.Data + "/" + repo.Name.Data, Platform: connection.GithubRepoPlatform, Labels: make(map[string]string), - Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)}, + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithParentConnectionId(conn.ID()))}, }) } } @@ -128,7 +121,7 @@ func org(runtime *plugin.Runtime, orgName string, conn *connection.GithubConnect Name: user.Name.Data, Platform: connection.GithubUserPlatform, Labels: make(map[string]string), - Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)}, + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithParentConnectionId(conn.ID()))}, }) } } @@ -156,7 +149,7 @@ func repo(runtime *plugin.Runtime, repoName string, owner string, conn *connecti Name: owner + "/" + repo.Name.Data, Platform: connection.GithubRepoPlatform, Labels: make(map[string]string), - Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)}, + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithParentConnectionId(conn.ID()))}, }) return assetList, nil @@ -183,7 +176,7 @@ func user(runtime *plugin.Runtime, userName string, conn *connection.GithubConne Name: user.Name.Data, Platform: connection.GithubUserPlatform, Labels: make(map[string]string), - Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)}, + Connections: []*inventory.Config{conn.Conf.Clone(inventory.WithParentConnectionId(conn.ID()))}, }) return assetList, nil }