From be59b38ac18275e44ab1de52a501426066b08c77 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 25 Apr 2024 12:59:00 +0200 Subject: [PATCH] update: handle ValueError from apkInspector in androguard 4.1 androguard 4.1 uses a new lib called apkInspector instead of zipfile.ZipFile so that it can handle usable but invalid ZIP files. It will also throw ValueError on some things, for example: Traceback (most recent call last): File "/builds/eighthave/fdroidserver/fdroidserver-2.3a0/tests/update.TestCase", line 878, in test_scan_apk_bad_zip fdroidserver.update.scan_apk(apkfile) File "/builds/eighthave/fdroidserver/fdroidserver-2.3a0/fdroidserver/update.py", line 1586, in scan_apk scan_apk_androguard(apk, apk_file) File "/builds/eighthave/fdroidserver/fdroidserver-2.3a0/fdroidserver/update.py", line 1725, in scan_apk_androguard apkobject = common.get_androguard_APK(apkfile) File "/builds/eighthave/fdroidserver/fdroidserver-2.3a0/fdroidserver/common.py", line 2673, in get_androguard_APK return APK(apkfile) File "/usr/local/lib/python3.10/dist-packages/androguard/core/apk/__init__.py", line 273, in __init__ self.zip = ZipEntry.parse(filename, False) File "/usr/local/lib/python3.10/dist-packages/apkInspector/headers.py", line 410, in parse eocd = EndOfCentralDirectoryRecord.parse(apk_file) File "/usr/local/lib/python3.10/dist-packages/apkInspector/headers.py", line 59, in parse raise ValueError("End of central directory record (EOCD) signature not found") ValueError: End of central directory record (EOCD) signature not found --- fdroidserver/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 1c38ff90..2ce07fa5 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1738,7 +1738,7 @@ def scan_apk_androguard(apk, apkfile): logging.error(_("Failed to get APK information, skipping {path}") .format(path=apkfile)) raise BuildException(_("Invalid APK")) - except (FileNotFoundError, zipfile.BadZipFile) as e: + except (FileNotFoundError, ValueError, zipfile.BadZipFile) as e: logging.error(_("Could not open APK {path} for analysis: ").format(path=apkfile) + str(e)) raise BuildException(_("Invalid APK")) from e