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

update: force all "SDK Version" values to int when parsing aapt

This commit is contained in:
Hans-Christoph Steiner 2019-02-01 09:49:07 +01:00
parent dd695c650e
commit 09bbca4a51

View File

@ -1148,16 +1148,16 @@ def scan_apk_aapt(apk, apkfile):
logging.error(line.replace('sdkVersion:', '')
+ ' is not a valid minSdkVersion!')
else:
apk['minSdkVersion'] = m.group(1)
apk['minSdkVersion'] = int(m.group(1))
elif line.startswith("targetSdkVersion:"):
m = re.match(APK_SDK_VERSION_PAT, line)
if m is None:
logging.error(line.replace('targetSdkVersion:', '')
+ ' is not a valid targetSdkVersion!')
else:
apk['targetSdkVersion'] = m.group(1)
apk['targetSdkVersion'] = int(m.group(1))
elif line.startswith("maxSdkVersion:"):
apk['maxSdkVersion'] = re.match(APK_SDK_VERSION_PAT, line).group(1)
apk['maxSdkVersion'] = int(re.match(APK_SDK_VERSION_PAT, line).group(1))
elif line.startswith("native-code:"):
apk['nativecode'] = []
for arch in line[13:].split(' '):
@ -1193,12 +1193,14 @@ def scan_apk_aapt(apk, apkfile):
def _sanitize_sdk_version(value):
"""Sanitize the raw values from androguard to handle bad values
minSdkVersion/targetSdkVersion/maxSdkVersion must be integers,
but that doesn't stop devs from doing strange things like
setting them using Android XML strings.
minSdkVersion/targetSdkVersion/maxSdkVersion must be integers, but
that doesn't stop devs from doing strange things like setting them
using Android XML strings. This method makes the Androguard output
match the output from `aapt dump badging`: bad values are ignored.
https://gitlab.com/souch/SMSbypass/blob/v0.9/app/src/main/AndroidManifest.xml#L29
https://gitlab.com/souch/SMSbypass/blob/v0.9/app/src/main/res/values/strings.xml#L27
"""
try:
sdk_version = int(value)