mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-20 13:50:12 +01:00
Find blobs by magic numbers
This commit is contained in:
parent
99510de07a
commit
779476e6f4
@ -138,6 +138,8 @@ Vagrant (gem install vagrant)
|
||||
Paramiko (debian package python-paramiko)
|
||||
@item
|
||||
Imaging (debian package python-imaging)
|
||||
@item
|
||||
Filemagic (pip install filemagic)
|
||||
@end itemize
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ import subprocess
|
||||
import time
|
||||
import operator
|
||||
import cgi
|
||||
import magic
|
||||
|
||||
def getvcs(vcstype, remote, local, sdk_path):
|
||||
if vcstype == 'git':
|
||||
@ -1590,6 +1591,7 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||
ignore = []
|
||||
|
||||
# Iterate through all files in the source code...
|
||||
with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m:
|
||||
for r,d,f in os.walk(build_dir):
|
||||
for curfile in f:
|
||||
|
||||
@ -1610,26 +1612,21 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||
|
||||
for suspect in usual_suspects:
|
||||
if suspect in curfile.lower():
|
||||
msg = 'Found probable non-free blob ' + fp
|
||||
problems.append(msg)
|
||||
problems.append('Found probable non-free blob ' + fp)
|
||||
|
||||
if curfile.endswith('.apk'):
|
||||
msg = 'Found apk file, which should not be in the source - ' + fp
|
||||
problems.append(msg)
|
||||
|
||||
elif curfile.endswith('.elf'):
|
||||
msg = 'Found .elf at ' + fp
|
||||
problems.append(msg)
|
||||
|
||||
elif curfile.endswith('.so'):
|
||||
msg = 'Found .so at ' + fp
|
||||
problems.append(msg)
|
||||
mime = m.id_filename(fp)
|
||||
if mime == 'application/x-sharedlib':
|
||||
problems.append('Found shared library at ' + fp)
|
||||
elif mime == 'application/octet-stream':
|
||||
problems.append('Found binary at ' + fp)
|
||||
elif mime == 'application/vnd.android.package-archive' or fp.endswith('.apk'):
|
||||
problems.append('Found apk at ' + fp)
|
||||
|
||||
elif curfile.endswith('.java'):
|
||||
for line in file(fp):
|
||||
if 'DexClassLoader' in line:
|
||||
msg = 'Found DexClassLoader in ' + fp
|
||||
problems.append(msg)
|
||||
problems.append('Found DexClassLoader in ' + fp)
|
||||
break
|
||||
|
||||
# Presence of a jni directory without buildjni=yes might
|
||||
# indicate a problem... (if it's not a problem, explicitly use
|
||||
|
Loading…
Reference in New Issue
Block a user