From 7a9efbd02e292217ab9126c1cb47bd8ed8bae36d Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Sun, 12 Feb 2023 08:45:58 -0500 Subject: [PATCH 1/2] manifest schema: add the missing `subject` field Fixes: #1018 This seems to have been missed through the WG PR. Signed-off-by: Vincent Batts --- schema/image-manifest-schema.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schema/image-manifest-schema.json b/schema/image-manifest-schema.json index 8286376eb..171ecbf2f 100644 --- a/schema/image-manifest-schema.json +++ b/schema/image-manifest-schema.json @@ -18,6 +18,9 @@ "config": { "$ref": "content-descriptor.json" }, + "subject": { + "$ref": "content-descriptor.json" + }, "layers": { "type": "array", "minItems": 1, From 31de01337887e96f3f25216a9b8d85efa4ba6e83 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Sun, 12 Feb 2023 11:35:50 -0500 Subject: [PATCH 2/2] manifest schema: add tests for the subject field Signed-off-by: Vincent Batts --- schema/manifest_test.go | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/schema/manifest_test.go b/schema/manifest_test.go index cfc43e973..5071e2d24 100644 --- a/schema/manifest_test.go +++ b/schema/manifest_test.go @@ -215,6 +215,58 @@ func TestManifest(t *testing.T) { `, }, + // expected success: subject field with a valid descriptor + { + manifest: ` +{ + "schemaVersion": 2, + "mediaType" : "application/vnd.oci.image.manifest.v1+json", + "subject" : { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "size": 1234, + "digest": "sha256:220a60ecd4a3c32c282622a625a54db9ba0ff55b5ba9c29c7064a2bc358b6a3e" + }, + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "size": 1470, + "digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b" + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "size": 1470, + "digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b" + } + ] +} +`, + fail: false, + }, + + // expected failure: subject field with invalid value (something that is not a descriptor) + { + manifest: ` +{ + "schemaVersion": 2, + "mediaType" : "application/vnd.oci.image.manifest.v1+json", + "subject" : ".nope", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "size": 1470, + "digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b" + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "size": 1470, + "digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b" + } + ] +} +`, + fail: true, + }, + // expected failure: push bounds of algorithm field in digest too far. { manifest: `