You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# TODO "crane validate" is definitely interesting here -- it essentially validates all the descriptors recursively, including diff_ids, but it only supports "remote" or "tarball" (which refers to the *old* "docker save" tarball format), so isn't useful here, but we need to do basically that exact work
140
-
141
138
# now that "index.json" represents the exact index we want to push, let's push it down into a blob and make a new appropriate "index.json" for "crane push"
142
139
# TODO we probably want/need some "traverse/manipulate an OCI layout" helpers 😭
# given an OCI image layout (https://github.com/opencontainers/image-spec/blob/v1.1.1/image-layout.md), verifies all descriptors as much as possible (digest matches content, size, some media types, layer diff_ids, etc)
4
+
# given an OCI image layout (https://github.com/opencontainers/image-spec/blob/v1.1.1/image-layout.md), verifies all descriptors as much as possible (digest matches content, size, media types, layer diff_ids, etc)
# TODO *technically* we could get clever here and pass `base64 -d` to something like `tee >(wc --bytes) >(dig="$(sha256sum | cut -d' ' -f1)" && echo "sha256:$dig" && false) > /dev/null` to avoid parsing the base64 twice, but then failure cases are less likely to be caught, so it's safer to simply redecode (and we can't decode into a variable because this might be binary data *and* bash will do newline munging in both directions)
# TODO technically, this would pass if one file is empty and another file has two documents in it (since it is counting the total), so that is not great, but probably is not a real problem
# TODO pass descriptor values down so we can validate that they match (.mediaType, .artifactType, .platform across *two* levels index->manifest->config), similar to .data
# TODO technically, this would pass if one file is empty and another file has two documents in it (since it is counting the total), so that is not great, but probably is not a real problem
validate(.annotations; type=="object"; "if present, annotations must be an object")
177
178
|validate(.annotations[]; type=="string"; "annotation values must be strings")
179
+
# TODO validate that keys are not bare words (reverse DNS or vendor/bar)
178
180
else.end
179
181
;
180
182
@@ -191,7 +193,11 @@ def validate_oci_descriptor:
191
193
|validate(.size; .==floor; "size must be whole")
192
194
|validate(.size; .==ceil; "size must be whole")
193
195
194
-
# TODO urls?
196
+
|ifhas("urls") then
197
+
validate(.urls; type=="array")
198
+
|validate(.urls[]; type=="string")
199
+
|validate_length(.urls; 0) # TODO this intentionally contradicts the above lines -- are there cases where we should allow urls?
200
+
else.end
195
201
196
202
|validate_oci_annotations_haver
197
203
@@ -205,7 +211,9 @@ def validate_oci_descriptor:
205
211
# someday, maybe we can validate that .data matches .digest here (needs more jq functionality, including and especially the ability to deal with non-UTF8 binary data from base64 and perform sha256 over it)
|validate_IN(.mediaType; media_types_index) # TODO allow "null" here too? (https://github.com/opencontainers/image-spec/security/advisories/GHSA-77vh-xpmg-72qh)
247
-
# TODO artifactType?
254
+
|validate_IN(.mediaType; media_types_index)
255
+
|ifhas("artifactType") then
256
+
validate(.artifactType; type=="string")
257
+
|validate_IN(.artifactType; null) # TODO acceptable values? (this check intentionally contradicts the one above so artifactType generates an error)
|validate_IN(.mediaType; media_types_image) # TODO allow "null" here too? (https://github.com/opencontainers/image-spec/security/advisories/GHSA-77vh-xpmg-72qh)
265
-
# TODO artifactType (but only selectively / certain values)
# TODO validate digest, size of blobs (*somewhere*, probably not here - this is all "cheap" validations / version+ordering+format assumption validations)
285
-
# TODO if .data, validate that somehow too (size, digest); https://github.com/jqlang/jq/issues/1116#issuecomment-2515814615
286
-
# TODO also we should validate that the length of every/any manifest is <= 4MiB (https://github.com/opencontainers/distribution-spec/pull/293#issuecomment-1452780554)
0 commit comments