From 6cff279fe4abc903e90968140529eef3d27e4dc1 Mon Sep 17 00:00:00 2001 From: Jasper Lievisse Adriaanse Date: Fri, 13 Jan 2023 21:38:57 +0100 Subject: [PATCH] Not all ELF files are for Linux. This stops tagging all ELF files as 'runnable:linux' and instead sets attempts to determine the most appropriate 'platform' and uses 'elf' as the extension. --- karton/classifier/classifier.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/karton/classifier/classifier.py b/karton/classifier/classifier.py index 724d6e4..133c25c 100644 --- a/karton/classifier/classifier.py +++ b/karton/classifier/classifier.py @@ -240,8 +240,22 @@ def zip_has_file(path: str) -> bool: return sample_class # Is ELF file? + elf_assoc = { + "linux": "(GNU/Linux)", + "freebsd": "(FreeBSD)", + "netbsd": "(NetBSD)", + "openbsd": "(SYSV)", + "solaris": "(Solaris)", + } if magic.startswith("ELF"): - sample_class.update({"kind": "runnable", "platform": "linux"}) + for platform, platform_full in elf_assoc.items(): + if platform_full in magic: + sample_class.update( + {"kind": "runnable", "platform": platform, "extension": "elf"} + ) + return sample_class + + sample_class.update({"kind": "runnable", "extension": "elf"}) return sample_class # Is PKG file?