Skip to content

Commit 15d8c03

Browse files
committed
schema1: reject ambiguous documents
Signed-off-by: Samuel Karp <[email protected]> (cherry picked from commit 70c88f5) Signed-off-by: Samuel Karp <[email protected]>
1 parent 833407f commit 15d8c03

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

remotes/docker/schema1/converter.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ func (c *Converter) fetchManifest(ctx context.Context, desc ocispec.Descriptor)
256256
if err := json.Unmarshal(b, &m); err != nil {
257257
return err
258258
}
259+
if len(m.Manifests) != 0 || len(m.Layers) != 0 {
260+
return errors.New("converter: expected schema1 document but found extra keys")
261+
}
259262
c.pulledManifest = &m
260263

261264
return nil
@@ -472,8 +475,10 @@ type history struct {
472475
}
473476

474477
type manifest struct {
475-
FSLayers []fsLayer `json:"fsLayers"`
476-
History []history `json:"history"`
478+
FSLayers []fsLayer `json:"fsLayers"`
479+
History []history `json:"history"`
480+
Layers json.RawMessage `json:"layers,omitempty"` // OCI manifest
481+
Manifests json.RawMessage `json:"manifests,omitempty"` // OCI index
477482
}
478483

479484
type v1History struct {

0 commit comments

Comments
 (0)