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

Bug: fix for soft failure #116

Merged
merged 2 commits into from
Nov 24, 2022
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
3 changes: 1 addition & 2 deletions internal/commands/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ func NewScanCommand() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
start := time.Now()
logger.Infof("%v Fetch Starting", emoji.TriangularFlag)

assetsData, supportedChecks, err := clients.FetchClientData(accessToken, repositoryUrl, scmPlatform, branch)
if err != nil {
if assetsData.AuthorizedUser == nil || err != nil {
logger.Error(err, "Failed to fetch client data")
return err
} else {
Expand Down
37 changes: 21 additions & 16 deletions internal/scm-clients/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/aquasecurity/chain-bench/internal/scm-clients/github"
"github.com/aquasecurity/chain-bench/internal/scm-clients/gitlab"
"github.com/aquasecurity/chain-bench/internal/utils"
pipelineModels "github.com/argonsecurity/pipeline-parser/pkg/models"
"github.com/enescakir/emoji"
)

Expand Down Expand Up @@ -47,27 +48,31 @@ func FetchClientData(accessToken string, repoUrl string, scmPlatform string, bra
repo, _ := adapter.GetRepository(orgName, repoName, branch)
logger.FetchingFinished("Repository Settings", emoji.OilDrum)

branchName := utils.GetBranchName(utils.GetValue(repo.DefaultBranch), branch)
var protection *models.Protection
var pipelines []*pipelineModels.Pipeline
var org *models.Organization
var registry *models.PackageRegistry

logger.FetchingFinished("Branch Protection Settings", emoji.Seedling)
protection, _ := adapter.GetBranchProtection(orgName, repo, branchName)
if repo != nil {
branchName := utils.GetBranchName(utils.GetValue(repo.DefaultBranch), branch)

pipelines, _ := adapter.GetPipelines(orgName, repoName, branchName)
logger.FetchingFinished("Pipelines", emoji.Wrench)
logger.FetchingFinished("Branch Protection Settings", emoji.Seedling)
protection, _ = adapter.GetBranchProtection(orgName, repo, branchName)

var org *models.Organization
var registry *models.PackageRegistry
pipelines, _ = adapter.GetPipelines(orgName, repoName, branchName)
logger.FetchingFinished("Pipelines", emoji.Wrench)

if *repo.Owner.Type == "Organization" {
org, _ = adapter.GetOrganization(orgName)
logger.FetchingFinished("Organization Settings", emoji.OfficeBuilding)
if *repo.Owner.Type == "Organization" {
org, _ = adapter.GetOrganization(orgName)
logger.FetchingFinished("Organization Settings", emoji.OfficeBuilding)

registry, _ = adapter.GetRegistry(org)
registry, _ = adapter.GetRegistry(org)

orgMembers, err := adapter.ListOrganizationMembers(orgName)
if err == nil {
org.Members = orgMembers
logger.FetchingFinished("Members", emoji.Emoji(emoji.WomanAndManHoldingHands.Tone()))
orgMembers, err := adapter.ListOrganizationMembers(orgName)
if err == nil {
org.Members = orgMembers
logger.FetchingFinished("Members", emoji.Emoji(emoji.WomanAndManHoldingHands.Tone()))
}
}
}

Expand All @@ -80,7 +85,7 @@ func FetchClientData(accessToken string, repoUrl string, scmPlatform string, bra
BranchProtections: protection,
Pipelines: pipelines,
Registry: registry,
}, checksIds, nil
}, checksIds, err
}

func getRepoInfo(repoFullUrl string) (string, string, string, error) {
Expand Down