1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-17 10:40:12 +02:00

Support more file types in get_embedded_classes

Closes: #999
This commit is contained in:
Jochen Sprickerhof 2022-05-10 14:54:32 +02:00 committed by Hans-Christoph Steiner
parent 6a4b7ba4c1
commit 4197455436

View File

@ -136,7 +136,7 @@ def get_embedded_classes(apkfile, depth=0):
if depth > 10: # zipbomb protection
return {_('Max recursion depth in ZIP file reached: %s') % apkfile}
apk_regex = re.compile(r'.*\.apk')
archive_regex = re.compile(r'.*\.(aab|aar|apk|apks|jar|war|xapk|zip)$')
class_regex = re.compile(r'classes.*\.dex')
classes = set()
@ -144,7 +144,7 @@ def get_embedded_classes(apkfile, depth=0):
with TemporaryDirectory() as tmp_dir, zipfile.ZipFile(apkfile, 'r') as apk_zip:
for info in apk_zip.infolist():
# apk files can contain apk files, again
if apk_regex.search(info.filename):
if archive_regex.search(info.filename):
with apk_zip.open(info) as apk_fp:
classes = classes.union(get_embedded_classes(apk_fp, depth + 1))