Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all ELF files are for Linux #55

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion karton/classifier/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
5 changes: 3 additions & 2 deletions tests/test_classifier_runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def test_process_runnable_linux(self):
"quality": "high",
"kind": "runnable",
"mime": "application/x-executable",
"platform": "linux",
"extension": "elf",
"platform": "openbsd",
},
payload={
"sample": resource,
"tags": ["runnable:linux"],
"tags": ["runnable:openbsd:elf"],
"magic": magic,
},
)
Expand Down