Skip to content

Commit f490cb6

Browse files
committed
Add support for is_executable_binary querysets
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 01f63b6 commit f490cb6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scanpipe/models.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,36 @@ def elfs(self):
20082008
| Q(file_type__icontains="shared object")
20092009
)
20102010
)
2011+
2012+
def win_exes(self):
2013+
"""
2014+
Resources that are ``files`` and their filetype contains "for ms windows" or
2015+
starts with "pe32".
2016+
Keep sync with the content type implementation at ``typecode.contenttype``.
2017+
"""
2018+
return (
2019+
self.files()
2020+
.filter(
2021+
Q(file_type__icontains="for ms windows") | Q(filetype_file__istartswith='pe32')
2022+
)
2023+
)
2024+
2025+
def mach_os(self):
2026+
"""
2027+
Resources that are ``files`` and their filetype contains "for ms mach-o" or
2028+
contains "application/x-mach-binary".
2029+
Keep sync with the content type implementation at ``typecode.contenttype``.
2030+
"""
2031+
return (
2032+
self.files()
2033+
.filter(
2034+
models.Q(filetype__icontains="mach-o") |
2035+
models.Q(mimetype__icontains="application/x-mach-binary")
2036+
)
2037+
)
2038+
2039+
def is_executable_binary(self):
2040+
return self.elfs().union(self.win_exes(), self.mach_os())
20112041

20122042

20132043
class ScanFieldsModelMixin(models.Model):

0 commit comments

Comments
 (0)