From 37b2a5fcaa3a43bad203d0b6bca1d692823c86ab Mon Sep 17 00:00:00 2001 From: James Elliott Date: Wed, 7 Aug 2024 07:32:45 +1000 Subject: [PATCH 1/2] fix(metadata): functional opt sets wrong value This fixes an issue where the functional option sets the wrong value. --- metadata/providers/memory/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata/providers/memory/options.go b/metadata/providers/memory/options.go index 6b8c2a15..87c0b90c 100644 --- a/metadata/providers/memory/options.go +++ b/metadata/providers/memory/options.go @@ -63,7 +63,7 @@ func WithValidateStatus(validate bool) Option { // known types the authenticator can produce. Default is true. func WithValidateAttestationTypes(validate bool) Option { return func(provider *Provider) (err error) { - provider.status = validate + provider.attestation = validate return nil } From cefdfe00d06ce39044da13f988db7a6b1628bc21 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Wed, 7 Aug 2024 08:22:46 +1000 Subject: [PATCH 2/2] fix(metadata): file closed too early This fixes an issue where the metadata provider closed a file that may still be in use. --- metadata/decode.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/metadata/decode.go b/metadata/decode.go index f3c3de7f..24291f2e 100644 --- a/metadata/decode.go +++ b/metadata/decode.go @@ -80,10 +80,8 @@ func (d *Decoder) Parse(payload *PayloadJSON) (metadata *Metadata, err error) { return metadata, nil } -// Decode the blob from an io.ReadCloser. This function will close the io.ReadCloser after completing. -func (d *Decoder) Decode(r io.ReadCloser) (payload *PayloadJSON, err error) { - defer r.Close() - +// Decode the blob from an io.Reader. This function will close the io.ReadCloser after completing. +func (d *Decoder) Decode(r io.Reader) (payload *PayloadJSON, err error) { bytes, err := io.ReadAll(r) if err != nil { return nil, err