fix: compressedLayerExtracterStore+isCompressedLayer - allow tar.gzip suffixes (#26355)

Signed-off-by: erin liman <erin.liman@tiktokusds.com>
This commit is contained in:
erin
2026-02-10 07:18:50 -08:00
committed by GitHub
parent 9cfcd2d261
commit 8f9ee6d1da
2 changed files with 27 additions and 2 deletions

View File

@@ -518,7 +518,7 @@ func isContentLayer(mediaType string) bool {
func isCompressedLayer(mediaType string) bool {
// TODO: Is zstd something which is used in the wild? For now let's stick to these suffixes
return strings.HasSuffix(mediaType, "tar+gzip") || strings.HasSuffix(mediaType, "tar")
return strings.HasSuffix(mediaType, "tar+gzip") || strings.HasSuffix(mediaType, "tar.gzip") || strings.HasSuffix(mediaType, "tar")
}
func createTarFile(from, to string) error {
@@ -625,7 +625,7 @@ func (s *compressedLayerExtracterStore) Push(ctx context.Context, desc imagev1.D
}
defer os.RemoveAll(srcDir)
if strings.HasSuffix(desc.MediaType, "tar+gzip") {
if strings.HasSuffix(desc.MediaType, "tar+gzip") || strings.HasSuffix(desc.MediaType, "tar.gzip") {
err = files.Untgz(srcDir, content, s.maxSize, false)
} else {
err = files.Untar(srcDir, content, s.maxSize, false)

View File

@@ -259,6 +259,31 @@ func Test_nativeOCIClient_Extract(t *testing.T) {
disableManifestMaxExtractedSize: false,
},
},
{
name: "extraction with docker rootfs tar.gzip layer",
fields: fields{
allowedMediaTypes: []string{"application/vnd.docker.image.rootfs.diff.tar.gzip"},
},
args: args{
digestFunc: func(store *memory.Store) string {
layerBlob := createGzippedTarWithContent(t, "foo.yaml", "some content")
return generateManifest(t, store, layerConf{content.NewDescriptorFromBytes("application/vnd.docker.image.rootfs.diff.tar.gzip", layerBlob), layerBlob})
},
postValidationFunc: func(_, path string, _ Client, _ fields, _ args) {
manifestDir, err := os.ReadDir(path)
require.NoError(t, err)
require.Len(t, manifestDir, 1)
require.Equal(t, "foo.yaml", manifestDir[0].Name())
f, err := os.Open(filepath.Join(path, manifestDir[0].Name()))
require.NoError(t, err)
contents, err := io.ReadAll(f)
require.NoError(t, err)
require.Equal(t, "some content", string(contents))
},
manifestMaxExtractedSize: 1000,
disableManifestMaxExtractedSize: false,
},
},
{
name: "extraction with standard gzip layer using cache",
fields: fields{