Repository navigation
schema: validate rootfs.diff_ids as digests - #1340
arpitjain099 wants to merge 1 commit into
Conversation
config.md says a layer DiffID is "the digest over the layer's uncompressed tar archive and serialized in the descriptor digest format", and every other digest-shaped field in the schema set refs defs-descriptor.json#/definitions/digest. rootfs.diff_ids items are typed as a bare string, so an empty entry, a sentence, or a relative path all validate. Point the items at the same definition the rest of the schemas use. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Do you maintain a project that's using this code? Is there an upstream issue this would resolve? |
|
No on both counts, and I should say that plainly rather than imply otherwise. I do not maintain a project consuming this schema, and there is no upstream issue behind it. What prompted it was reading the schema files against each other: If the looseness there is deliberate, or you would rather this started as an issue and a discussion than a patch, I am happy to close it. No objection either way. |
|
My goal was to get an understanding of who is using those files, because they often get out of sync with the spec and I'm not sure there is anyone that depends on them for anything more than a theoretical use case. It sounds like we're still batting a zero there. |
|
Understood. Closing this PR. Thanks for the context. |
config.md:28is explicit about the format:but
config-schema.jsontypes the items as a bare string:It is the one digest-shaped field in the schema set that does not
$ref defs-descriptor.json#/definitions/digest.content-descriptor.json:17andimage-index-schema.json:46both do.Driving
schema.ValidatorMediaTypeImageConfig.Validateonmain, with a well formed digest first so the harness is provably discriminating:After pointing the items at the shared definition, the three bad values are rejected and the good one still passes.
Verification
Four cases added to
TestConfig, three expecting failure and one expecting success. The success case is there so the other three are shown to fail on thediff_idsvalue rather than on something else in the document. Three of the four fail onmain.go test ./...passes in both modules, includingTestBackwardsCompatibilityConfig, whose corpus is real Docker 1.10.3 and 1.12.1 configs, so the tightened pattern does not reject anything the project already treats as valid.gofmt -lis clean.