From 719076f0e6292f4706b6e680f19f47159fb39e3d Mon Sep 17 00:00:00 2001 From: xiaolang Date: Fri, 11 May 2018 11:04:21 +0800 Subject: [PATCH 1/3] add support for elf --- filetype/types/archive.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/filetype/types/archive.py b/filetype/types/archive.py index 5cde4b3..3d488d8 100644 --- a/filetype/types/archive.py +++ b/filetype/types/archive.py @@ -513,3 +513,25 @@ def match(self, buf): buf[1] == 0x5A and buf[2] == 0x49 and buf[3] == 0x50) + + + +class Elf(Type): + """ + Implements the Elf archive type matcher. + """ + MIME = 'application/x-executable' + EXTENSION = 'elf' + + def __init__(self): + super(Lz, self).__init__( + mime=Elf.MIME, + extension=Elf.EXTENSION + ) + + def match(self, buf): + return (len(buf) > 52 and + buf[0] == 0x7F and + buf[1] == 0x45 and + buf[2] == 0x4C and + buf[3] == 0x46) From ade686ae937b76ab9e5c694621c436ef4e8a57c8 Mon Sep 17 00:00:00 2001 From: xiaolang Date: Fri, 11 May 2018 11:08:45 +0800 Subject: [PATCH 2/3] add support for elf --- filetype/types/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/filetype/types/__init__.py b/filetype/types/__init__.py index af6d89e..341a0df 100644 --- a/filetype/types/__init__.py +++ b/filetype/types/__init__.py @@ -77,6 +77,7 @@ archive.Ar(), archive.Z(), archive.Lz(), + archive.Elf() ) # Expose supported type matchers From 99e8584498c5df302e4bd0c29c47a36437f140d7 Mon Sep 17 00:00:00 2001 From: xiaolang Date: Fri, 11 May 2018 11:10:30 +0800 Subject: [PATCH 3/3] add support for elf --- filetype/types/archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filetype/types/archive.py b/filetype/types/archive.py index 3d488d8..deb46f0 100644 --- a/filetype/types/archive.py +++ b/filetype/types/archive.py @@ -524,7 +524,7 @@ class Elf(Type): EXTENSION = 'elf' def __init__(self): - super(Lz, self).__init__( + super(Elf, self).__init__( mime=Elf.MIME, extension=Elf.EXTENSION )