diff --git a/commands/audit/scarunner.go b/commands/audit/scarunner.go index 7d521912..eb8789ed 100644 --- a/commands/audit/scarunner.go +++ b/commands/audit/scarunner.go @@ -268,16 +268,27 @@ func SetResolutionRepoIfExists(params xrayutils.AuditParams, tech coreutils.Tech log.Debug("Using resolver config from", configFilePath) repoConfig, err := project.ReadResolutionOnlyConfiguration(configFilePath) if err != nil { - err = fmt.Errorf("failed while reading %s.yaml config file: %s", tech.String(), err.Error()) - return + var missingResolverErr *project.MissingResolverErr + if !errors.As(err, &missingResolverErr) { + err = fmt.Errorf("failed while reading %s.yaml config file: %s", tech.String(), err.Error()) + return + } + // When the resolver repository is absent from the configuration file, ReadResolutionOnlyConfiguration throws an error. + // However, this situation isn't considered an error here as the resolver repository isn't mandatory for constructing the dependencies tree. + err = nil } - details, err := repoConfig.ServerDetails() - if err != nil { - err = fmt.Errorf("failed getting server details: %s", err.Error()) - return + + // If the resolver repository doesn't exist and triggers a MissingResolverErr in ReadResolutionOnlyConfiguration, the repoConfig becomes nil. In this scenario, there is no depsRepo to set, nor is there a necessity to do so. + if repoConfig != nil { + log.Debug("Using resolver config from", configFilePath) + details, e := repoConfig.ServerDetails() + if e != nil { + err = fmt.Errorf("failed getting server details: %s", e.Error()) + } else { + params.SetServerDetails(details) + params.SetDepsRepo(repoConfig.TargetRepo()) + } } - params.SetServerDetails(details) - params.SetDepsRepo(repoConfig.TargetRepo()) return } diff --git a/go.mod b/go.mod index 861be4ea..daa746cd 100644 --- a/go.mod +++ b/go.mod @@ -98,6 +98,6 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect ) -replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240124134548-78e293fce02b +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240125111519-f3cdb35159a2 replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240122091504-cd958f60aef7 diff --git a/go.sum b/go.sum index 2c06ca55..fc312ccc 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer5 github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240125111519-f3cdb35159a2 h1:JEeyfjTpxmffq4ZTRybqYZxeYkmcZKnEkyNnbGWqjSU= +github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240125111519-f3cdb35159a2/go.mod h1:RVn4pIkR5fPUnr8gFXt61ou3pCNrrDdRQUpcolP4lhw= github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= @@ -93,8 +95,6 @@ github.com/jfrog/gofrog v1.5.1 h1:2AXL8hHu1jJFMIoCqTp2OyRUfEqEp4nC7J8fwn6KtwE= github.com/jfrog/gofrog v1.5.1/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg= github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY= github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240124134548-78e293fce02b h1:dUZOuqsa/3jLZ01B1xJeh2vTHchW7O+MbWn+VEp/Qj4= -github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240124134548-78e293fce02b/go.mod h1:RVn4pIkR5fPUnr8gFXt61ou3pCNrrDdRQUpcolP4lhw= github.com/jfrog/jfrog-client-go v1.28.1-0.20240122091504-cd958f60aef7 h1:+6FMON+6D2ojqR+bKewlahVcQGXLifFH76hXITg9p6k= github.com/jfrog/jfrog-client-go v1.28.1-0.20240122091504-cd958f60aef7/go.mod h1:V+XKC27k6GA5OcWIAItpnxZAZnCigg8xCkpXKP905Fk= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=