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: Update OpenVEX report to correctly reference OCI IDs #810

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 24 additions & 4 deletions pkg/patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,18 @@
log.Warnf("Image name has no tag or digest, using latest as tag")
imageName = reference.TagNameOnly(imageName)
}
var tag string
taggedName, ok := imageName.(reference.Tagged)
if ok {
var tag string
var digest string
if taggedName, ok := imageName.(reference.Tagged); ok {
tag = taggedName.Tag()
digest, err = FetchImageDigest(taggedName)

Check failure on line 90 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

undefined: FetchImageDigest

Check failure on line 90 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: FetchImageDigest

Check failure on line 90 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

undefined: FetchImageDigest

Check failure on line 90 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

undefined: FetchImageDigest

Check failure on line 90 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / vuln-check

undefined: FetchImageDigest

Check failure on line 90 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Unit Test

undefined: FetchImageDigest
if err != nil {
return err
}
imageName, err = reference.WithDigest(imageName, digest)

Check failure on line 94 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

cannot use digest (variable of type string) as "github.com/opencontainers/go-digest".Digest value in argument to reference.WithDigest

Check failure on line 94 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use digest (variable of type string) as "github.com/opencontainers/go-digest".Digest value in argument to reference.WithDigest

Check failure on line 94 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

cannot use digest (variable of type string) as "github.com/opencontainers/go-digest".Digest value in argument to reference.WithDigest

Check failure on line 94 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

cannot use digest (variable of type string) as "github.com/opencontainers/go-digest".Digest value in argument to reference.WithDigest

Check failure on line 94 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / vuln-check

cannot use digest (variable of type string) as "github.com/opencontainers/go-digest".Digest value in argument to reference.WithDigest

Check failure on line 94 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Unit Test

cannot use digest (variable of type string) as "github.com/opencontainers/go-digest".Digest value in argument to reference.WithDigest
if err != nil {
return err
}
} else {
log.Warnf("Image name has no tag")
}
Expand All @@ -102,7 +110,12 @@
if err != nil {
return fmt.Errorf("%w with patched tag %s", err, patchedTag)
}
patchedImageName := fmt.Sprintf("%s:%s", imageName.Name(), patchedTag)
// Make sure the digest was successfully fetched earlier and is valid
if digest == "" {
return fmt.Errorf("failed to fetch digest for image %s", imageName)
}

patchedImageName := fmt.Sprintf("%s@sha256:%s", imageName.Name(), digest)

// Ensure working folder exists for call to InstallUpdates
if workingFolder == "" {
Expand Down Expand Up @@ -134,6 +147,13 @@
log.Debugf("updates to apply: %v", updates)
}

if updates != nil && len(updates.Updates) > 0 {
if err := vex.TryOutputVexDocument(updates, manager, patchedImageName, format, output); err != nil {

Check failure on line 151 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

undefined: manager

Check failure on line 151 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: manager

Check failure on line 151 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

undefined: manager

Check failure on line 151 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

undefined: manager

Check failure on line 151 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / vuln-check

undefined: manager

Check failure on line 151 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Unit Test

undefined: manager
return err
}
}
return eg.Wait()

Check failure on line 155 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

undefined: eg

Check failure on line 155 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: eg

Check failure on line 155 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

undefined: eg) (typecheck)

Check failure on line 155 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / lint

undefined: eg (typecheck)

Check failure on line 155 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / vuln-check

undefined: eg

Check failure on line 155 in pkg/patch/patch.go

View workflow job for this annotation

GitHub Actions / Unit Test

undefined: eg

bkClient, err := buildkit.NewClient(ctx, bkOpts)
if err != nil {
return err
Expand Down
Loading