Commit Graph

11 Commits

Author SHA1 Message Date
Miloslav Trmač 8ce59962c9 Add unit tests to ensure manifest Clone doesn't lose data
No non-test code changes, should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-01 19:39:55 +02:00
Miloslav Trmač c729a29fbe Refuse compression to zstd when using schema1
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-21 19:49:20 +01:00
Miloslav Trmač 942cb5c134 Reject unsupported encryption/decryption updates in UpdateLayerInfos
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-09-06 20:08:32 +02:00
Miloslav Trmač 83aee8f797 Reject OCI artifacts in manifest.OCI1.ImageID
... and add tests for the ImageID implementations.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-06-16 20:38:15 +02:00
Miloslav Trmač 7152f888b9 Update users of deprecated io/ioutil
Mostly just name changes that should not change behavior,
apart from ioutil.ReadDir -> os.ReadDir avoiding per-item
lstat(2) in some cases.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-04-13 20:46:48 +02:00
Miloslav Trmač 7bcf9bc8b6 Reject ambiguous manifest formats
Refuse to process manifest / manifest list data
that could possibly be interpreted as two different
manifest formats, because differences in how those
ambiguities are resolved could be used to bypass
image verification or review mechanisms.

Fixes CVE-2021-41190 / GHSA-77vh-xpmg-72qh .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-11-17 21:43:59 +01:00
Miloslav Trmač 7d9cde7252 Update to major version v5
> gomove github.com/containers/image/v4 github.com/containers/image/v5
+ a manual edit of go.mod

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-25 22:27:45 +02:00
Miloslav Trmač e568c94ef3 Correctly use a c/image/v4 module namespace
... so that major-version-aware Go module import
(as opposed to vX.Y.Z+incompatible, which does not allow different
packages to use different versions) works right.

Also requires adding some more GO111MODULE=on options to Makefile.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-03 22:54:27 +02:00
Miloslav Trmač df4847bd66 Add EmptyLayer to manifest.LayerInfo.
This makes the "empty layer" flag available for storageImage.

Also continues to add tests to the manifest subpackage.

A possible alternative was to add this right to types.BlobInfo,
but that exists primarily for copying images around, where
the consumers don't care about the value, and producers
like PutBlob would have to do extra work to preserve the (unused)
value; whether the value is or isn't available in a particular
instance would have to be only documented in text.

This allows us to use the type system to verify availability
of the flag: if you want it, call manifest.LayerInfos explicitly.
(Of course if it turns out to be more widely needed, we can undo this
and move the flag directly to BlobInfo.)

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-07-13 20:55:47 +02:00
Miloslav Trmač 1c41783540 Add manifest.Schema1.ExtractedV1Compatibility
This allows us to simplify consumers of the data, and notably will allow
future LayerInfos to work without having to worry about parsing errors.

manifest.Schema1FromManifest is parsing all of that data anyway in
fixManifestLayers, so this is a net win for those manifests; OTOH
manifest.Schema1FromComponents may do the work unnecessarily.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-07-13 20:55:47 +02:00
Miloslav Trmač c88bbf22ae Add manifest.Schema1.initialize()
This is a shared component of the two constructors, currently only verifying
invariants, but intended primarily to share code to unmarshal the History components
in the future.

Also opportunistically starts adding tests to the manifest subpackage.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-07-13 20:55:47 +02:00