scanner: should not exit with error when apkanalyzer fails

apkanalyzer produces useful output when it can run, but it does not
support all recent JDK versions, and also some DEX versions, so this
cannot count on it to always produce useful output or even to run
without exiting with an error.

211dd65ff0 was based on false
assumptions that apkanalyzer can always produce output.

fdroiddata!8585
fdroiddata!8584
This commit is contained in:
Hans-Christoph Steiner 2021-03-15 10:10:09 +01:00
parent fc368dc291
commit 78842e9cc2

View file

@ -103,12 +103,20 @@ def get_gradle_compile_commands(build):
def scan_binary(apkfile): def scan_binary(apkfile):
logging.info("Scanning APK for known non-free classes.") """Scan output of apkanalyzer for known non-free classes
apkanalyzer produces useful output when it can run, but it does
not support all recent JDK versions, and also some DEX versions,
so this cannot count on it to always produce useful output or even
to run without exiting with an error.
"""
logging.info(_('Scanning APK with apkanalyzer for known non-free classes.'))
result = common.SdkToolsPopen(["apkanalyzer", "dex", "packages", "--defined-only", apkfile], output=False) result = common.SdkToolsPopen(["apkanalyzer", "dex", "packages", "--defined-only", apkfile], output=False)
problems = 0
if result.returncode != 0: if result.returncode != 0:
problems += 1 logging.warning(_('scanner not cleanly run apkanalyzer: %s') % result.output)
logging.error(result.output) problems = 0
for suspect, regexp in CODE_SIGNATURES.items(): for suspect, regexp in CODE_SIGNATURES.items():
matches = regexp.findall(result.output) matches = regexp.findall(result.output)
if matches: if matches: