mirror of
https://github.com/mvt-project/mvt.git
synced 2024-07-01 08:29:03 +00:00
Fixes #329 outdated iOS version error
This commit is contained in:
parent
8ce6b31299
commit
95842ac449
|
@ -9,7 +9,7 @@ import plistlib
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from mvt.common.module import DatabaseNotFoundError
|
from mvt.common.module import DatabaseNotFoundError
|
||||||
from mvt.ios.versions import get_device_desc_from_id, latest_ios_version
|
from mvt.ios.versions import get_device_desc_from_id, is_ios_version_outdated
|
||||||
|
|
||||||
from ..base import IOSExtraction
|
from ..base import IOSExtraction
|
||||||
|
|
||||||
|
@ -63,7 +63,4 @@ class BackupInfo(IOSExtraction):
|
||||||
self.results[field] = value
|
self.results[field] = value
|
||||||
|
|
||||||
if "Product Version" in info:
|
if "Product Version" in info:
|
||||||
latest = latest_ios_version()
|
is_ios_version_outdated(info["Product Version"], log=self.log)
|
||||||
if info["Product Version"] != latest["version"]:
|
|
||||||
self.log.warning("This phone is running an outdated iOS version: %s (latest is %s)",
|
|
||||||
info["Product Version"], latest['version'])
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
# Copyright (c) 2021-2023 Claudio Guarnieri.
|
# Copyright (c) 2021-2023 Claudio Guarnieri.
|
||||||
# Use of this software is governed by the MVT License 1.1 that can be found at
|
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||||
# https://license.mvt.re/1.1/
|
# https://license.mvt.re/1.1/
|
||||||
|
from logging import Logger
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
import packaging
|
||||||
|
|
||||||
IPHONE_MODELS = [
|
IPHONE_MODELS = [
|
||||||
{"identifier": "iPhone4,1", "description": "iPhone 4S"},
|
{"identifier": "iPhone4,1", "description": "iPhone 4S"},
|
||||||
|
@ -279,3 +283,27 @@ def find_version_by_build(build: str) -> str:
|
||||||
|
|
||||||
def latest_ios_version() -> str:
|
def latest_ios_version() -> str:
|
||||||
return IPHONE_IOS_VERSIONS[-1]
|
return IPHONE_IOS_VERSIONS[-1]
|
||||||
|
|
||||||
|
|
||||||
|
def is_ios_version_outdated(version: str, log: Optional[Logger] = None) -> bool:
|
||||||
|
"""
|
||||||
|
Check if the given version is below the latest version
|
||||||
|
version can be a build number or version number
|
||||||
|
Returns true if outdated for sure, false otherwise
|
||||||
|
"""
|
||||||
|
# Check if it is a build
|
||||||
|
if "." not in version:
|
||||||
|
version = find_version_by_build(version)
|
||||||
|
# If we can't find it
|
||||||
|
if version == "":
|
||||||
|
return False
|
||||||
|
|
||||||
|
latest_parsed = packaging.version.parse(latest_ios_version()["version"])
|
||||||
|
current_parsed = packaging.version.parse(version)
|
||||||
|
if current_parsed < latest_parsed:
|
||||||
|
if log:
|
||||||
|
log.warning("This phone is running an outdated iOS version: %s (latest is %s)",
|
||||||
|
version,
|
||||||
|
latest_ios_version()["version"])
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
14
tests/test_ios_versions.py
Normal file
14
tests/test_ios_versions.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Mobile Verification Toolkit (MVT)
|
||||||
|
# Copyright (c) 2021-2023 Claudio Guarnieri.
|
||||||
|
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||||
|
# https://license.mvt.re/1.1/
|
||||||
|
|
||||||
|
from mvt.ios.versions import is_ios_version_outdated
|
||||||
|
|
||||||
|
|
||||||
|
class TestIosVersions:
|
||||||
|
|
||||||
|
def test_is_ios_version_outdated(self):
|
||||||
|
assert is_ios_version_outdated("20B110") is True
|
||||||
|
assert is_ios_version_outdated("16.3") is True
|
||||||
|
assert is_ios_version_outdated("38.2") is False
|
Loading…
Reference in New Issue
Block a user