Skip to content

Commit

Permalink
Limit size of manifest (#1711)
Browse files Browse the repository at this point in the history
Signed-off-by: AdamKorcz <adam@adalogics.com>
  • Loading branch information
AdamKorcz committed May 22, 2023
1 parent e61c519 commit 5fe7f2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/v1/remote/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ import (
"github.com/google/go-containerregistry/pkg/v1/types"
)

const (
kib = 1024
mib = 1024 * kib
manifestLimit = 100 * mib
)

// fetcher implements methods for reading from a registry.
type fetcher struct {
target resource
Expand Down Expand Up @@ -130,7 +136,7 @@ func (f *fetcher) fetchManifest(ctx context.Context, ref name.Reference, accepta
return nil, nil, err
}

manifest, err := io.ReadAll(resp.Body)
manifest, err := io.ReadAll(io.LimitReader(resp.Body, manifestLimit))
if err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 5fe7f2e

Please sign in to comment.