From b25e16a56ce7fb6decc81909263a93e438f2b064 Mon Sep 17 00:00:00 2001 From: Brian Bland Date: Wed, 12 Nov 2014 15:26:35 -0800 Subject: [PATCH] Adds Raw bytes field to ImageManifest This can be used for proper json signature validation --- images.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/images.go b/images.go index 927a4b60..84fe217d 100644 --- a/images.go +++ b/images.go @@ -1,6 +1,7 @@ package registry import ( + "encoding/json" "net/http" "github.com/gorilla/handlers" @@ -24,11 +25,27 @@ type ImageManifest struct { // History is a list of unstructured historical data for v1 compatibility History []ManifestHistory `json:"history"` - // Signature is the JWT with which the image is signed - Signature string `json:"signature,omitempty"` - // SchemaVersion is the image manifest schema that this image follows SchemaVersion int `json:"schemaVersion"` + + // Raw is the byte representation of the ImageManifest, used for signature + // verification + Raw []byte `json:"-"` +} + +// imageManifest is used to avoid recursion in unmarshaling +type imageManifest ImageManifest + +func (m *ImageManifest) UnmarshalJSON(b []byte) error { + var manifest imageManifest + err := json.Unmarshal(b, &manifest) + if err != nil { + return err + } + + *m = ImageManifest(manifest) + m.Raw = b + return nil } // FSLayer is a container struct for BlobSums defined in an image manifest