From 37c02d796d448c0b56fd6034dba08caa57174d0a Mon Sep 17 00:00:00 2001 From: Kudryavcev Nikolay Date: Tue, 14 Oct 2025 23:39:58 +0300 Subject: [PATCH 1/2] extract zip archive with multiple entries Signed-off-by: Kudryavcev Nikolay --- syft/source/filesource/file_source.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/syft/source/filesource/file_source.go b/syft/source/filesource/file_source.go index aa4b4df4bba..6f3c34a2faa 100644 --- a/syft/source/filesource/file_source.go +++ b/syft/source/filesource/file_source.go @@ -231,11 +231,13 @@ func fileAnalysisPath(path string, skipExtractArchive bool) (string, func() erro // unarchived. envelopedUnarchiver, err := archiver.ByExtension(path) if unarchiver, ok := envelopedUnarchiver.(archiver.Unarchiver); err == nil && ok { - if tar, ok := unarchiver.(*archiver.Tar); ok { - // when tar files are extracted, if there are multiple entries at the same - // location, the last entry wins - // NOTE: this currently does not display any messages if an overwrite happens + // when tar/zip files are extracted, if there are multiple entries at the same + // location, the last entry wins + // NOTE: this currently does not display any messages if an overwrite happens + if tar, tarOk := unarchiver.(*archiver.Tar); tarOk { tar.OverwriteExisting = true + } else if zip, zipOk := unarchiver.(*archiver.Zip); zipOk { + zip.OverwriteExisting = true } analysisPath, cleanupFn, err = unarchiveToTmp(path, unarchiver) From c85e62ff5fd638cbe684b40b47f1ff6e308d773a Mon Sep 17 00:00:00 2001 From: Kudryavcev Nikolay Date: Wed, 15 Oct 2025 00:26:43 +0300 Subject: [PATCH 2/2] set OverwriteExisting by type assertion switch case Signed-off-by: Kudryavcev Nikolay --- syft/source/filesource/file_source.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/syft/source/filesource/file_source.go b/syft/source/filesource/file_source.go index 6f3c34a2faa..f74b0c089c0 100644 --- a/syft/source/filesource/file_source.go +++ b/syft/source/filesource/file_source.go @@ -234,10 +234,11 @@ func fileAnalysisPath(path string, skipExtractArchive bool) (string, func() erro // when tar/zip files are extracted, if there are multiple entries at the same // location, the last entry wins // NOTE: this currently does not display any messages if an overwrite happens - if tar, tarOk := unarchiver.(*archiver.Tar); tarOk { - tar.OverwriteExisting = true - } else if zip, zipOk := unarchiver.(*archiver.Zip); zipOk { - zip.OverwriteExisting = true + switch v := unarchiver.(type) { + case *archiver.Tar: + v.OverwriteExisting = true + case *archiver.Zip: + v.OverwriteExisting = true } analysisPath, cleanupFn, err = unarchiveToTmp(path, unarchiver)