Autofix for ruff

This commit is contained in:
Rory Flynn
2025-01-14 11:50:24 +01:00
parent 1c78874b82
commit 06f65dbbcf
14 changed files with 16 additions and 23 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ class DumpsysAppopsArtifact(AndroidArtifact):
and perm["access"] == "allow" and perm["access"] == "allow"
): ):
self.log.info( self.log.info(
"Package %s with REQUEST_INSTALL_PACKAGES " "permission", "Package %s with REQUEST_INSTALL_PACKAGES permission",
result["package_name"], result["package_name"],
) )
@@ -16,8 +16,7 @@ class DumpsysPackagesArtifact(AndroidArtifact):
for result in self.results: for result in self.results:
if result["package_name"] in ROOT_PACKAGES: if result["package_name"] in ROOT_PACKAGES:
self.log.warning( self.log.warning(
"Found an installed package related to " 'Found an installed package related to rooting/jailbreaking: "%s"',
'rooting/jailbreaking: "%s"',
result["package_name"], result["package_name"],
) )
self.detected.append(result) self.detected.append(result)
+1 -2
View File
@@ -326,8 +326,7 @@ class AndroidExtraction(MVTModule):
if not header["backup"]: if not header["backup"]:
self.log.error( self.log.error(
"Extracting SMS via Android backup failed. " "Extracting SMS via Android backup failed. No valid backup data found."
"No valid backup data found."
) )
return None return None
+1 -2
View File
@@ -75,8 +75,7 @@ class Packages(AndroidExtraction):
for result in self.results: for result in self.results:
if result["package_name"] in ROOT_PACKAGES: if result["package_name"] in ROOT_PACKAGES:
self.log.warning( self.log.warning(
"Found an installed package related to " 'Found an installed package related to rooting/jailbreaking: "%s"',
'rooting/jailbreaking: "%s"',
result["package_name"], result["package_name"],
) )
self.detected.append(result) self.detected.append(result)
+1 -1
View File
@@ -70,7 +70,7 @@ class SMS(AndroidExtraction):
"timestamp": record["isodate"], "timestamp": record["isodate"],
"module": self.__class__.__name__, "module": self.__class__.__name__,
"event": f"sms_{record['direction']}", "event": f"sms_{record['direction']}",
"data": f"{record.get('address', 'unknown source')}: \"{body}\"", "data": f'{record.get("address", "unknown source")}: "{body}"',
} }
def check_indicators(self) -> None: def check_indicators(self) -> None:
@@ -44,8 +44,7 @@ class Packages(AndroidQFModule):
for result in self.results: for result in self.results:
if result["name"] in ROOT_PACKAGES: if result["name"] in ROOT_PACKAGES:
self.log.warning( self.log.warning(
"Found an installed package related to " 'Found an installed package related to rooting/jailbreaking: "%s"',
'rooting/jailbreaking: "%s"',
result["name"], result["name"],
) )
self.detected.append(result) self.detected.append(result)
+1 -1
View File
@@ -81,7 +81,7 @@ class Command:
os.path.join(self.results_path, "command.log") os.path.join(self.results_path, "command.log")
) )
formatter = logging.Formatter( formatter = logging.Formatter(
"%(asctime)s - %(name)s - " "%(levelname)s - %(message)s" "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
) )
file_handler.setLevel(logging.DEBUG) file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
+1 -2
View File
@@ -383,8 +383,7 @@ class Indicators:
for ioc in self.get_iocs("urls"): for ioc in self.get_iocs("urls"):
if ioc["value"] == url: if ioc["value"] == url:
self.log.warning( self.log.warning(
"Found a known suspicious URL %s " 'Found a known suspicious URL %s matching indicator "%s" from "%s"',
'matching indicator "%s" from "%s"',
url, url,
ioc["value"], ioc["value"],
ioc["name"], ioc["name"],
+3 -4
View File
@@ -100,7 +100,7 @@ def decrypt_backup(ctx, destination, password, key_file, hashes, backup_path):
if key_file: if key_file:
if MVT_IOS_BACKUP_PASSWORD in os.environ: if MVT_IOS_BACKUP_PASSWORD in os.environ:
log.info( log.info(
"Ignoring %s environment variable, using --key-file" "'%s' instead", "Ignoring %s environment variable, using --key-file'%s' instead",
MVT_IOS_BACKUP_PASSWORD, MVT_IOS_BACKUP_PASSWORD,
key_file, key_file,
) )
@@ -114,7 +114,7 @@ def decrypt_backup(ctx, destination, password, key_file, hashes, backup_path):
if MVT_IOS_BACKUP_PASSWORD in os.environ: if MVT_IOS_BACKUP_PASSWORD in os.environ:
log.info( log.info(
"Ignoring %s environment variable, using --password" "argument instead", "Ignoring %s environment variable, using --passwordargument instead",
MVT_IOS_BACKUP_PASSWORD, MVT_IOS_BACKUP_PASSWORD,
) )
@@ -168,8 +168,7 @@ def extract_key(password, key_file, backup_path):
if MVT_IOS_BACKUP_PASSWORD in os.environ: if MVT_IOS_BACKUP_PASSWORD in os.environ:
log.info( log.info(
"Ignoring %s environment variable, using --password " "Ignoring %s environment variable, using --password argument instead",
"argument instead",
MVT_IOS_BACKUP_PASSWORD, MVT_IOS_BACKUP_PASSWORD,
) )
elif MVT_IOS_BACKUP_PASSWORD in os.environ: elif MVT_IOS_BACKUP_PASSWORD in os.environ:
+1 -1
View File
@@ -41,7 +41,7 @@ class BackupInfo(IOSExtraction):
info_path = os.path.join(self.target_path, "Info.plist") info_path = os.path.join(self.target_path, "Info.plist")
if not os.path.exists(info_path): if not os.path.exists(info_path):
raise DatabaseNotFoundError( raise DatabaseNotFoundError(
"No Info.plist at backup path, unable to extract device " "information" "No Info.plist at backup path, unable to extract device information"
) )
with open(info_path, "rb") as handle: with open(info_path, "rb") as handle:
+1 -2
View File
@@ -110,8 +110,7 @@ class Manifest(IOSExtraction):
ioc = self.indicators.check_url(part) ioc = self.indicators.check_url(part)
if ioc: if ioc:
self.log.warning( self.log.warning(
'Found mention of domain "%s" in a backup file with ' 'Found mention of domain "%s" in a backup file with path: %s',
"path: %s",
ioc["value"], ioc["value"],
rel_path, rel_path,
) )
+1 -1
View File
@@ -74,7 +74,7 @@ class IOSExtraction(MVTModule):
if not shutil.which("sqlite3"): if not shutil.which("sqlite3"):
raise DatabaseCorruptedError( raise DatabaseCorruptedError(
"failed to recover without sqlite3 binary: please install " "sqlite3!" "failed to recover without sqlite3 binary: please install sqlite3!"
) )
if '"' in file_path: if '"' in file_path:
raise DatabaseCorruptedError( raise DatabaseCorruptedError(
+1 -1
View File
@@ -43,7 +43,7 @@ class SMS(IOSExtraction):
def serialize(self, record: dict) -> Union[dict, list]: def serialize(self, record: dict) -> Union[dict, list]:
text = record["text"].replace("\n", "\\n") text = record["text"].replace("\n", "\\n")
sms_data = f"{record['service']}: {record['guid']} \"{text}\" from {record['phone_number']} ({record['account']})" sms_data = f'{record["service"]}: {record["guid"]} "{text}" from {record["phone_number"]} ({record["account"]})'
records = [ records = [
{ {
"timestamp": record["isodate"], "timestamp": record["isodate"],
@@ -100,7 +100,7 @@ class WebkitSessionResourceLog(IOSExtraction):
redirect_path += ", ".join(source_domains) redirect_path += ", ".join(source_domains)
redirect_path += " -> " redirect_path += " -> "
redirect_path += f"ORIGIN: \"{entry['origin']}\"" redirect_path += f'ORIGIN: "{entry["origin"]}"'
if len(destination_domains) > 0: if len(destination_domains) > 0:
redirect_path += " -> " redirect_path += " -> "