diff --git a/syft/source/file_type.go b/syft/source/file_type.go index 3718b12c4..f0dd33bc1 100644 --- a/syft/source/file_type.go +++ b/syft/source/file_type.go @@ -1,33 +1,35 @@ package source +import "archive/tar" + const ( - UnknownFileType FileType = "unknownFileType" - RegularFile FileType = "regularFile" - HardLink FileType = "hardLink" - SymbolicLink FileType = "symbolicLink" - CharacterDevice FileType = "characterDevice" - BlockDevice FileType = "blockDevice" - Directory FileType = "directory" - FIFONode FileType = "fifoNode" + UnknownFileType FileType = "UnknownFileType" + RegularFile FileType = "RegularFile" + HardLink FileType = "HardLink" + SymbolicLink FileType = "SymbolicLink" + CharacterDevice FileType = "CharacterDevice" + BlockDevice FileType = "BlockDevice" + Directory FileType = "Directory" + FIFONode FileType = "FIFONode" ) type FileType string func newFileTypeFromTarHeaderTypeFlag(flag byte) FileType { switch flag { - case '0', '\x00': + case tar.TypeReg, tar.TypeRegA: return RegularFile - case '1': + case tar.TypeLink: return HardLink - case '2': + case tar.TypeSymlink: return SymbolicLink - case '3': + case tar.TypeChar: return CharacterDevice - case '4': + case tar.TypeBlock: return BlockDevice - case '5': + case tar.TypeDir: return Directory - case '6': + case tar.TypeFifo: return FIFONode } return UnknownFileType diff --git a/test/cli/power_user_cmd_test.go b/test/cli/power_user_cmd_test.go index 603c1a18d..5bc16a759 100644 --- a/test/cli/power_user_cmd_test.go +++ b/test/cli/power_user_cmd_test.go @@ -26,7 +26,7 @@ func TestPowerUserCmdFlags(t *testing.T) { args: []string{"power-user", request}, assertions: []traitAssertion{ assertNotInOutput(" command is deprecated"), // only the root command should be deprecated - assertInOutput(`"type": "regularFile"`), // proof of file-metadata data + assertInOutput(`"type": "RegularFile"`), // proof of file-metadata data assertInOutput(`"algorithm": "sha256"`), // proof of file-metadata default digest algorithm of sha256 assertInOutput(`"metadataType": "ApkMetadata"`), // proof of package artifacts data assertSuccessfulReturnCode,