1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-19 21:30:10 +01:00

update: fix min/target/max edge case parsing with androguard

In order to test that aapt defaults minSdkVersion to 3, I ran this script
then compared the output with meld:

cd $ANDROID_HOME/build-tools
for d in *.*; do echo $d; $ANDROID_HOME/build-tools/$d/aapt dump badging /home/hans/code/fdroid/server/tests/repo/com.politedroid_3.apk > /tmp/${d}.txt; done
meld /tmp/17.0.0.txt /tmp/26.0.2.txt /tmp/27.0.3.txt
This commit is contained in:
Hans-Christoph Steiner 2018-02-14 22:00:42 +01:00
parent 40fac10ebc
commit 699b3e4c69

View File

@ -1069,7 +1069,9 @@ def scan_apk(apk_file):
if 'minSdkVersion' not in apk: if 'minSdkVersion' not in apk:
logging.warning("No SDK version information found in {0}".format(apk_file)) logging.warning("No SDK version information found in {0}".format(apk_file))
apk['minSdkVersion'] = 1 apk['minSdkVersion'] = 3 # aapt defaults to 3 as the min
if 'targetSdkVersion' not in apk:
apk['targetSdkVersion'] = apk['minSdkVersion']
# Check for known vulnerabilities # Check for known vulnerabilities
if has_known_vulnerability(apk_file): if has_known_vulnerability(apk_file):
@ -1125,9 +1127,6 @@ def scan_apk_aapt(apk, apkfile):
+ ' is not a valid minSdkVersion!') + ' is not a valid minSdkVersion!')
else: else:
apk['minSdkVersion'] = m.group(1) apk['minSdkVersion'] = m.group(1)
# if target not set, default to min
if 'targetSdkVersion' not in apk:
apk['targetSdkVersion'] = m.group(1)
elif line.startswith("targetSdkVersion:"): elif line.startswith("targetSdkVersion:"):
m = re.match(APK_SDK_VERSION_PAT, line) m = re.match(APK_SDK_VERSION_PAT, line)
if m is None: if m is None:
@ -1209,7 +1208,9 @@ def scan_apk_androguard(apk, apkfile):
if apkobject.get_max_sdk_version() is not None: if apkobject.get_max_sdk_version() is not None:
apk['maxSdkVersion'] = apkobject.get_max_sdk_version() apk['maxSdkVersion'] = apkobject.get_max_sdk_version()
if apkobject.get_min_sdk_version() is not None:
apk['minSdkVersion'] = apkobject.get_min_sdk_version() apk['minSdkVersion'] = apkobject.get_min_sdk_version()
if apkobject.get_target_sdk_version() is not None:
apk['targetSdkVersion'] = apkobject.get_target_sdk_version() apk['targetSdkVersion'] = apkobject.get_target_sdk_version()
icon_id = int(apkobject.get_element("application", "icon").replace("@", "0x"), 16) icon_id = int(apkobject.get_element("application", "icon").replace("@", "0x"), 16)