Skip to content
Closed
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
12 changes: 11 additions & 1 deletion image/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,22 @@ func findManifest(w walker, d *descriptor) (*manifest, error) {
}

func (m *manifest) validate(w walker) error {
mediatype := v1.MediaTypeImageLayer
if err := m.Config.validate(w, []string{v1.MediaTypeImageConfig}); err != nil {
return errors.Wrap(err, "config validation failed")
}

for _, d := range m.Layers {
if err := d.validate(w, []string{v1.MediaTypeImageLayer}); err != nil {
switch d.MediaType {
case v1.MediaTypeImageLayerGzip:
mediatype = v1.MediaTypeImageLayerGzip
case v1.MediaTypeImageLayerNonDistributable:
mediatype = v1.MediaTypeImageLayerNonDistributable
case v1.MediaTypeImageLayerNonDistributableGzip:
mediatype = v1.MediaTypeImageLayerNonDistributableGzip
}

if err := d.validate(w, []string{mediatype}); err != nil {
Copy link
Member

@runcom runcom Feb 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you just pass d.MediaType here? The rest seems redundant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh,Why do you think so?d.mediatype is the layer mediatype, according to the different mediatype to verify different, what is the problem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I meant the actual media types as slice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this code is wrong -- it will ignore invalid images.

I'd recommend closing this for #111.

return errors.Wrap(err, "layer validation failed")
}
}
Expand Down