Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix github scans #3343

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions providers/github/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

Expand Down
17 changes: 5 additions & 12 deletions providers/github/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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()))},
})
}
}
Expand All @@ -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()))},
})
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
Loading