Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 40e528c

Browse files
committed
chore: fix ineffassign issues
Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
1 parent 519742d commit 40e528c

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

commands/cmd.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
177177
if err != nil {
178178
return err
179179
}
180-
err = sbom.UploadSbom(sb, workspace, apiKey)
181-
182-
return nil
180+
return sbom.UploadSbom(sb, workspace, apiKey)
183181
},
184182
}
185183
uploadCommandFlags := uploadCommand.Flags()

registry/read.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ func ReadImage(name string, path string) (*ImageCache, error) {
3131
return nil, errors.Wrapf(err, "failed to read manifest index at %s", path)
3232
}
3333
mani, err := index.IndexManifest()
34+
if err != nil {
35+
return nil, errors.Wrapf(err, "failed to read manifest index at %s", path)
36+
}
3437
hash := mani.Manifests[0].Digest
3538
img, _ := index.Image(hash)
3639

sbom/index.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ type ImageIndexResult struct {
4242

4343
func indexImageAsync(wg *sync.WaitGroup, image string, cli command.Cli, resultChan chan<- ImageIndexResult) {
4444
defer wg.Done()
45-
sbom, err := IndexImage(image, cli)
46-
cves, err := query.ForVulnerabilitiesInGraphQL(sbom)
45+
var (
46+
sbom *types.Sbom
47+
cves *types.VulnerabilitiesByPurls
48+
err error
49+
)
50+
sbom, err = IndexImage(image, cli)
4751
if err == nil {
48-
sbom.Vulnerabilities = cves.VulnerabilitiesByPackage
52+
cves, err = query.ForVulnerabilitiesInGraphQL(sbom)
53+
if err == nil {
54+
sbom.Vulnerabilities = cves.VulnerabilitiesByPackage
55+
}
4956
}
5057
resultChan <- ImageIndexResult{
5158
Input: image,
@@ -112,9 +119,12 @@ func indexImage(cache *registry.ImageCache, cli command.Cli) (*types.Sbom, error
112119
}
113120

114121
trivyResult.Packages, err = types.NormalizePackages(trivyResult.Packages)
122+
if err != nil {
123+
return nil, errors.Wrapf(err, "failed to normalize packages: %s", cache.Name)
124+
}
115125
syftResult.Packages, err = types.NormalizePackages(syftResult.Packages)
116126
if err != nil {
117-
return nil, errors.Wrapf(err, "failed to normalize packagess: %s", cache.Name)
127+
return nil, errors.Wrapf(err, "failed to normalize packages: %s", cache.Name)
118128
}
119129

120130
packages := types.MergePackages(syftResult, trivyResult)

0 commit comments

Comments
 (0)