Skip to content

Commit 4dd9e6b

Browse files
committed
add authentication to remote descriptor retrieval in fetchAttestationsForReference
Signed-off-by: rafi <refaei.shikho@hotmail.com>
1 parent bd7a7e6 commit 4dd9e6b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/devguard-scanner/scanner/discover.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"encoding/json"
2222
"fmt"
2323

24+
"github.com/google/go-containerregistry/pkg/authn"
2425
"github.com/google/go-containerregistry/pkg/name"
2526
"github.com/google/go-containerregistry/pkg/v1/remote"
2627
"github.com/pkg/errors"
@@ -34,7 +35,7 @@ type AttestationFileLine struct {
3435
}
3536

3637
func fetchAttestationsForReference(ctx context.Context, ref name.Reference) ([]oci.Signature, error) {
37-
desc, err := remote.Get(ref, remote.WithContext(ctx))
38+
desc, err := remote.Get(ref, remote.WithContext(ctx), remote.WithAuthFromKeychain(authn.DefaultKeychain))
3839
if err != nil {
3940
return nil, errors.Wrap(err, "failed to get remote descriptor")
4041
}
@@ -63,6 +64,7 @@ func fetchAttestationsForReference(ctx context.Context, ref name.Reference) ([]o
6364
sigsPerPlatform, err := ociremote.Signatures(attRef,
6465
ociremote.WithRemoteOptions(
6566
remote.WithContext(ctx),
67+
remote.WithAuthFromKeychain(authn.DefaultKeychain),
6668
),
6769
)
6870
if err != nil {
@@ -83,6 +85,7 @@ func fetchAttestationsForReference(ctx context.Context, ref name.Reference) ([]o
8385
sigsSingle, err := ociremote.Signatures(attRef,
8486
ociremote.WithRemoteOptions(
8587
remote.WithContext(ctx),
88+
remote.WithAuthFromKeychain(authn.DefaultKeychain),
8689
),
8790
)
8891
if err != nil {

0 commit comments

Comments
 (0)