-
Notifications
You must be signed in to change notification settings - Fork 764
descriptor: size int64 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
because docker/distribution uses int64 - and I didn't want to move that far there. Obviously uint64 would be better as long as sizes aren't negative :)
done |
On Thu, Jun 16, 2016 at 02:40:29PM -0700, Antonio Murdaca wrote:
I think that if we're going to get picky about how many bits we're
int64 isn't a native type, you have to $ref it like 1. |
I personally like being picky about types because it wasn't obvious to me if the image-spec defines an int but in reality it's at least an int64 and since it's a spec I expect this pickyness (and since I defined types in Go as well.). I also think we have an int64 defined for some reason..... BTW I'll leave this decision to the maintainers and I'll either close or update this PR |
Are int64's represented by json numbers? A reference to the docker distribution value would be helpful for tracking. |
On Thu, Jun 16, 2016 at 02:52:36PM -0700, Antonio Murdaca wrote:
I'd been interpreting this like JSON which does not specify a maximum "size": 9223372036854776001 Signedness, on the other hand, is something that we should be able to |
fwiw we already have something defined as int64 also https://github.com/runcom/image-spec/blob/fce87bead2bbbad896c6208b8518c29d78687255/schema/defs-config.json#L11 |
Signed-off-by: Antonio Murdaca <[email protected]>
signedness shouldn't be used for data validation. And a negative size is also a very clear way of saying the size is unknown, albeit inadvisable. I'm not really sure if we need to be picky, other than that the parser should error out if the value overflows the field on whatever platform is consuming the data. |
On Wed, Jul 06, 2016 at 12:06:35PM -0700, Stephen Day wrote:
The spec REQUIRES size 1, so I think:
Agreed, and that^ sounds like a JSON-parser issue to me, and not |
I'm sorry, but using unsigned integers for data validation is bad practice. It makes underflow detection challenging and complicates offset declaration when working with binary storage formats. In general, this is a good addition. Throughout "the stack", 64-bit integers are sufficient for declaring offsets and size for large binary objects. The only area where I see this being a problem is with javascript, where it doesn't have a 64-bit integer, so making a requirement to support at least 64 bits, is problematic. @runcom Was this PR a matter of hygiene or did you encounter a specific problem? |
On Wed, Jul 06, 2016 at 02:14:45PM -0700, Stephen Day wrote:
Isn't underflow just a floating point thing 1? When I try to json: cannot unmarshal number -1 into Go value of type uint64 The same is true of uint and *uint, although the error message ends I don't see how a signed size helps with offset declaration. Do you
I'm not sure why Go would choose to use a signed integer for a |
When I said "underflow", I mean, negative numbers. Let's say we have to ask the question "Can it fit?". The use case of negative binary offsets is to declare blocks relative to some known point. Let's say we add binary blob storage metadata to the end of a file. We can say that the block is
The point of an unsigned integer is not to provide a number that can't go negative. The point is to define a field with specific overflow behavior. When working with sizes and offsets, we ignore the behavior of that field and operate as if they are integers, which is true when operating within the bounds of the field. When doing arithmetic operations on size, we want to believe it is an integer, not a field with overflow. This is all beside the point: the question being asked here is, should we validate the size as positive (Yes, probably) and should we have a minimum range requirement on the field value for size? |
On Wed, Jul 06, 2016 at 02:53:27PM -0700, Stephen Day wrote:
And ‘space >= size’ answers it for all integers, signed or not.
And also to give you an extra bit's worth of positive-number space.
I agree here.
And I'd rather punt to JSON here 1. |
I am fine with int64 and saying it MUST be positive. |
On Wed, Jul 27, 2016 at 05:05:13PM -0700, Brandon Philips wrote:
And putting a cap on the value in the JSON Schema, or would you leave |
@wking If we can express greater than 0 and less than 9223372036854775807 (9223 Petabytes) then I think that would be great. Hopefully this won't be my 640k is enough for anyone moment :-P But I think 9,223 Petabytes is enough for anyone. :) |
On Wed, Aug 03, 2016 at 10:50:10AM -0700, Brandon Philips wrote:
I don't see a reason to specify a max cap, but I agree that I'm |
If we wanted to support unknown size wouldn't we just make the Anyways, 9 years later, I would like to know: is I introduced this problem apparently with youki-dev/oci-spec-rs#203 (my bad for not digging through the history of this spec). But I don't want to just change it back to int64 without having some guidance for why I'm doing that. (And if I were to do so...because in Rust we have |
In umoci we support |
In my own code, a -1 would always fail the size check, and I wouldn't ever expect to see that in a descriptor. In what scenario would the digest be known, but not the size? |
@stevvooe You are conflating the types with specific programming language semantics. For example in Rust, there's explicit saturating methods on integers. (Actually this gets into a different issue with the spec that afaics "int64" is not defined anywhere - i.e. the mapping of that type to JSON though its definition is pretty obvious; anyways that sub-thread was mostly covered above)
But yes exactly (or often I think people would write the inverse i.e.
Anyways...it turns out that this issue was not directly related to this spec. It happens in the https://github.com/containers/container-libs codebase when the remote registry doesn't return a Obviously we do know the size up front because we're following the manifest, and it turns out that all callers of this internal API basically just ignore it - except in my Rust bindings I try to pervasively use So again, not directly related to this spec issue, but I'm sure influenced by it. |
The internal API in containers/image returns a size...which is an `int64` in the source probably because OCI Descriptor type have it be an int64 too for bad historical reasons; xref opencontainers/image-spec#153 Anyways, the `GetBlob` wrapper API returns `-1` when the remote registry doesn't emit `Content-Length`: https://github.com/containers/container-libs/blob/3af9abd27f3b875122b9fedd88953e8c840d6958/image/docker/docker_client.go#L1068 And this apparently happens with at least the Quay mirror registry. We also noticed this problem when adding `GetRawBlob` in containers/skopeo#2601 which simply doesn't return a size to the client at all. Signed-off-by: Colin Walters <[email protected]>
The internal API in containers/image returns a size...which is an `int64` in the source probably because OCI Descriptor type have it be an int64 too for bad historical reasons; xref opencontainers/image-spec#153 Anyways, the `GetBlob` wrapper API returns `-1` when the remote registry doesn't emit `Content-Length`: https://github.com/containers/container-libs/blob/3af9abd27f3b875122b9fedd88953e8c840d6958/image/docker/docker_client.go#L1068 And this apparently happens with at least the Quay mirror registry. We also noticed this problem when adding `GetRawBlob` in containers/skopeo#2601 which simply doesn't return a size to the client at all. Signed-off-by: Colin Walters <[email protected]>
I'd treat the descriptor and the registry There are scenarios in interacting with the registry where the size isn't known in advance (chunked or streaming blob push), but in those cases the digest isn't known yet and you don't have the descriptor yet, they become available at the end of the blob push. |
So maybe we need a PR that adds this clarification in the markdown? |
I've raised #1285 for this. |
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was based on a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. Signed-off-by: Aleksa Sarai <[email protected]>
This was implicitly allowed by VerifiedReadCloser, and while we have closed that hole it's probably best to provide a more helpful error message. Not blocking this earlier was mostly due to a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them (especially for descriptors where it makes little sense to have an unknown size) seems like a bad idea in general. Ref: opencontainers/image-spec#1285 Signed-off-by: Aleksa Sarai <[email protected]>
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was added partially because a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 (which was finally clarified in opencontainers/image-spec#1285), but was also necessary for some users of VerifiedReadCloser that did not really know the proper blob size. We have now adjusted all of those callers, so there is no longer any reason to continue supporting this. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. We might need to adjust this if/when umoci grows OCI distribution-spec support, but for now it isn't needed. Signed-off-by: Aleksa Sarai <[email protected]>
This was implicitly allowed by VerifiedReadCloser, and while we have closed that hole it's probably best to provide a more helpful error message. Not blocking this earlier was mostly due to a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them (especially for descriptors where it makes little sense to have an unknown size) seems like a bad idea in general. Ref: opencontainers/image-spec#1285 Signed-off-by: Aleksa Sarai <[email protected]>
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was added partially because a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 (which was finally clarified in opencontainers/image-spec#1285), but was also necessary for some users of VerifiedReadCloser that did not really know the proper blob size. We have now adjusted all of those callers, so there is no longer any reason to continue supporting this. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. We might need to adjust this if/when umoci grows OCI distribution-spec support, but for now it isn't needed. Signed-off-by: Aleksa Sarai <[email protected]>
This was implicitly allowed by VerifiedReadCloser, and while we have closed that hole it's probably best to provide a more helpful error message. Not blocking this earlier was mostly due to a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them (especially for descriptors where it makes little sense to have an unknown size) seems like a bad idea in general. Ref: opencontainers/image-spec#1285 Signed-off-by: Aleksa Sarai <[email protected]>
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was added partially because a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 (which was finally clarified in opencontainers/image-spec#1285), but was also necessary for some users of VerifiedReadCloser that did not really know the proper blob size. We have now adjusted all of those callers, so there is no longer any reason to continue supporting this. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. We might need to adjust this if/when umoci grows OCI distribution-spec support, but for now it isn't needed. Signed-off-by: Aleksa Sarai <[email protected]>
This was implicitly allowed by VerifiedReadCloser, and while we have closed that hole it's probably best to provide a more helpful error message. Not blocking this earlier was mostly due to a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them (especially for descriptors where it makes little sense to have an unknown size) seems like a bad idea in general. Ref: opencontainers/image-spec#1285 Signed-off-by: Aleksa Sarai <[email protected]>
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was added partially because a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 (which was finally clarified in opencontainers/image-spec#1285), but was also necessary for some users of VerifiedReadCloser that did not really know the proper blob size. We have now adjusted all of those callers, so there is no longer any reason to continue supporting this. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. We might need to adjust this if/when umoci grows OCI distribution-spec support, but for now it isn't needed. Signed-off-by: Aleksa Sarai <[email protected]>
This was implicitly allowed by VerifiedReadCloser, and while we have closed that hole it's probably best to provide a more helpful error message. Not blocking this earlier was mostly due to a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them (especially for descriptors where it makes little sense to have an unknown size) seems like a bad idea in general. Ref: opencontainers/image-spec#1285 Signed-off-by: Aleksa Sarai <[email protected]>
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was added partially because a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 (which was finally clarified in opencontainers/image-spec#1285), but was also necessary for some users of VerifiedReadCloser that did not really know the proper blob size. We have now adjusted all of those callers, so there is no longer any reason to continue supporting this. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. We might need to adjust this if/when umoci grows OCI distribution-spec support, but for now it isn't needed. Signed-off-by: Aleksa Sarai <[email protected]>
This was implicitly allowed by VerifiedReadCloser, and while we have closed that hole it's probably best to provide a more helpful error message. Not blocking this earlier was mostly due to a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 which was finally clarified in opencontainers/image-spec#1285. Unknown sizes are a classic DoS vector, so allowing them (especially for descriptors where it makes little sense to have an unknown size) seems like a bad idea in general. Ref: opencontainers/image-spec#1285 Signed-off-by: Aleksa Sarai <[email protected]>
VerifiedReadCloser previously would allow for negative ExpectedSize to disable the size checking features added in commit ad66299 ("pkg: hardening: expand to verify descriptor length"). This was added partially because a somewhat overly-permissive reading of the discussion in opencontainers/image-spec#153 (which was finally clarified in opencontainers/image-spec#1285), but was also necessary for some users of VerifiedReadCloser that did not really know the proper blob size. We have now adjusted all of those callers, so there is no longer any reason to continue supporting this. Unknown sizes are a classic DoS vector, so allowing them seems like a bad idea in general. We might need to adjust this if/when umoci grows OCI distribution-spec support, but for now it isn't needed. Signed-off-by: Aleksa Sarai <[email protected]>
Signed-off-by: Antonio Murdaca [email protected]