The following issues were found

mvt/ios/cli.py
34 issues
Unable to import 'rich.logging'
Error

Line: 10 Column: 1

              import os

import click
from rich.logging import RichHandler
from rich.prompt import Prompt

from mvt.common.indicators import Indicators, IndicatorsFileBadFormat
from mvt.common.module import run_module, save_timeline
from mvt.common.options import MutuallyExclusiveOption

            

Reported by Pylint.

Unable to import 'rich.prompt'
Error

Line: 11 Column: 1

              
import click
from rich.logging import RichHandler
from rich.prompt import Prompt

from mvt.common.indicators import Indicators, IndicatorsFileBadFormat
from mvt.common.module import run_module, save_timeline
from mvt.common.options import MutuallyExclusiveOption


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 1

              from mvt.common.module import run_module, save_timeline
from mvt.common.options import MutuallyExclusiveOption

from .decrypt import DecryptBackup
from .modules.backup import BACKUP_MODULES
from .modules.fs import FS_MODULES
from .modules.mixed import MIXED_MODULES

# Setup logging using Rich.

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 18 Column: 1

              from mvt.common.options import MutuallyExclusiveOption

from .decrypt import DecryptBackup
from .modules.backup import BACKUP_MODULES
from .modules.fs import FS_MODULES
from .modules.mixed import MIXED_MODULES

# Setup logging using Rich.
LOG_FORMAT = "[%(name)s] %(message)s"

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 1

              
from .decrypt import DecryptBackup
from .modules.backup import BACKUP_MODULES
from .modules.fs import FS_MODULES
from .modules.mixed import MIXED_MODULES

# Setup logging using Rich.
LOG_FORMAT = "[%(name)s] %(message)s"
logging.basicConfig(level="INFO", format=LOG_FORMAT, handlers=[

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 20 Column: 1

              from .decrypt import DecryptBackup
from .modules.backup import BACKUP_MODULES
from .modules.fs import FS_MODULES
from .modules.mixed import MIXED_MODULES

# Setup logging using Rich.
LOG_FORMAT = "[%(name)s] %(message)s"
logging.basicConfig(level="INFO", format=LOG_FORMAT, handlers=[
    RichHandler(show_path=False, log_time_format="%X")])

            

Reported by Pylint.

Too many arguments for logging format string
Error

Line: 62 Column: 13

              
    if key_file:
        if PASSWD_ENV in os.environ:
            log.info("Ignoring environment variable, using --key-file '%s' instead",
                     PASSWD_ENV, key_file)

        backup.decrypt_with_key_file(key_file)
    elif password:
        log.info("Your password may be visible in the process table because it was supplied on the command line!")

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 145 Column: 16

                  if output and not os.path.exists(output):
        try:
            os.makedirs(output)
        except Exception as e:
            log.critical("Unable to create output folder %s: %s", output, e)
            ctx.exit(1)

    indicators = Indicators(log=log)
    for ioc_path in iocs:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 208 Column: 16

                  if output and not os.path.exists(output):
        try:
            os.makedirs(output)
        except Exception as e:
            log.critical("Unable to create output folder %s: %s", output, e)
            ctx.exit(1)

    indicators = Indicators(log=log)
    for ioc_path in iocs:

            

Reported by Pylint.

Unused variable 'ext'
Error

Line: 282 Column: 20

                  log.info("Loaded a total of %d indicators", indicators.ioc_count)

    for file_name in os.listdir(folder):
        name_only, ext = os.path.splitext(file_name)
        file_path = os.path.join(folder, file_name)

        for iocs_module in all_modules:
            if module and iocs_module.__name__ != module:
                continue

            

Reported by Pylint.

mvt/android/modules/adb/base.py
29 issues
Unable to import 'adb_shell.adb_device'
Error

Line: 14 Column: 1

              import tempfile
import time

from adb_shell.adb_device import AdbDeviceTcp, AdbDeviceUsb
from adb_shell.auth.keygen import keygen, write_public_keyfile
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
from adb_shell.exceptions import (AdbCommandFailureException, DeviceAuthError,
                                  UsbReadFailedError)
from usb1 import USBErrorAccess, USBErrorBusy

            

Reported by Pylint.

Unable to import 'adb_shell.auth.keygen'
Error

Line: 15 Column: 1

              import time

from adb_shell.adb_device import AdbDeviceTcp, AdbDeviceUsb
from adb_shell.auth.keygen import keygen, write_public_keyfile
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
from adb_shell.exceptions import (AdbCommandFailureException, DeviceAuthError,
                                  UsbReadFailedError)
from usb1 import USBErrorAccess, USBErrorBusy


            

Reported by Pylint.

Unable to import 'adb_shell.auth.sign_pythonrsa'
Error

Line: 16 Column: 1

              
from adb_shell.adb_device import AdbDeviceTcp, AdbDeviceUsb
from adb_shell.auth.keygen import keygen, write_public_keyfile
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
from adb_shell.exceptions import (AdbCommandFailureException, DeviceAuthError,
                                  UsbReadFailedError)
from usb1 import USBErrorAccess, USBErrorBusy

from mvt.common.module import InsufficientPrivileges, MVTModule

            

Reported by Pylint.

Unable to import 'adb_shell.exceptions'
Error

Line: 17 Column: 1

              from adb_shell.adb_device import AdbDeviceTcp, AdbDeviceUsb
from adb_shell.auth.keygen import keygen, write_public_keyfile
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
from adb_shell.exceptions import (AdbCommandFailureException, DeviceAuthError,
                                  UsbReadFailedError)
from usb1 import USBErrorAccess, USBErrorBusy

from mvt.common.module import InsufficientPrivileges, MVTModule


            

Reported by Pylint.

Unable to import 'usb1'
Error

Line: 19 Column: 1

              from adb_shell.auth.sign_pythonrsa import PythonRSASigner
from adb_shell.exceptions import (AdbCommandFailureException, DeviceAuthError,
                                  UsbReadFailedError)
from usb1 import USBErrorAccess, USBErrorBusy

from mvt.common.module import InsufficientPrivileges, MVTModule

log = logging.getLogger(__name__)


            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 31 Column: 5

              class AndroidExtraction(MVTModule):
    """This class provides a base for all Android extraction modules."""

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

Redefining name 'log' from outer scope (line 23)
Error

Line: 32 Column: 35

                  """This class provides a base for all Android extraction modules."""

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)

        self.device = None

            

Reported by Pylint.

TODO: Need to support checking files without root privileges as well.
Error

Line: 136 Column: 3

                      :returns: Boolean indicating whether the file exists or not
        """

        # TODO: Need to support checking files without root privileges as well.

        # Connect to the device over adb.
        self._adb_connect()
        # Check if we have root, if not raise an Exception.
        self._adb_root_or_die()

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 157 Column: 17

                          if retry_root:
                self._adb_download_root(remote_path, local_path, progress_callback)
            else:
                raise Exception(f"Unable to download file {remote_path}: {e}")
    
    def _adb_download_root(self, remote_path, local_path, progress_callback=None):
        try:
            # Check if we have root, if not raise an Exception.
            self._adb_root_or_die()

            

Reported by Pylint.

Unused argument 'progress_callback'
Error

Line: 159 Column: 59

                          else:
                raise Exception(f"Unable to download file {remote_path}: {e}")
    
    def _adb_download_root(self, remote_path, local_path, progress_callback=None):
        try:
            # Check if we have root, if not raise an Exception.
            self._adb_root_or_die()

            # We generate a random temporary filename.

            

Reported by Pylint.

mvt/common/module.py
27 issues
Attempted relative import beyond top-level package
Error

Line: 14 Column: 1

              
import simplejson as json

from .indicators import Indicators


class DatabaseNotFoundError(Exception):
    pass


            

Reported by Pylint.

Unused import glob
Error

Line: 7 Column: 1

              #   https://license.mvt.re/1.1/

import csv
import glob
import io
import os
import re

import simplejson as json

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 32 Column: 5

                  enabled = True
    slug = None

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        """Initialize module.
        :param file_path: Path to the module's database file, if there is any.
        :param base_folder: Path to the base folder (backup or filesystem dump)
        :param output_folder: Folder where results will be stored

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 91 Column: 24

                          with io.open(results_json_path, "w", encoding="utf-8") as handle:
                try:
                    json.dump(self.results, handle, indent=4, default=str)
                except Exception as e:
                    self.log.error("Unable to store results of module %s to file %s: %s",
                                   self.__class__.__name__, results_file_name, e)

        if self.detected:
            detected_file_name = f"{name}_detected.json"

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 156 Column: 12

                  except DatabaseCorruptedError as e:
        module.log.error("The %s module database seems to be corrupted and recovery failed: %s",
                         module.__class__.__name__, e)
    except Exception as e:
        module.log.exception("Error in running extraction from module %s: %s",
                             module.__class__.__name__, e)
    else:
        try:
            module.check_indicators()

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 165 Column: 13

                      except NotImplementedError:
            module.log.info("The %s module does not support checking for indicators",
                            module.__class__.__name__)
            pass
        else:
            if module.indicators and not module.detected:
                module.log.info("The %s module produced no detections!",
                                module.__class__.__name__)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mobile Verification Toolkit (MVT)
# Copyright (c) 2021 The MVT Project Authors.
# Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

import csv
import glob
import io
import os

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

              from .indicators import Indicators


class DatabaseNotFoundError(Exception):
    pass

class DatabaseCorruptedError(Exception):
    pass


            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 1

              class DatabaseNotFoundError(Exception):
    pass

class DatabaseCorruptedError(Exception):
    pass

class InsufficientPrivileges(Exception):
    pass


            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

              class DatabaseCorruptedError(Exception):
    pass

class InsufficientPrivileges(Exception):
    pass

class MVTModule(object):
    """This class provides a base for all extraction modules."""


            

Reported by Pylint.

mvt/android/cli.py
27 issues
Unable to import 'rich.logging'
Error

Line: 10 Column: 1

              import os

import click
from rich.logging import RichHandler

from mvt.common.indicators import Indicators, IndicatorsFileBadFormat
from mvt.common.module import run_module, save_timeline

from .download_apks import DownloadAPKs

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 1

              from mvt.common.indicators import Indicators, IndicatorsFileBadFormat
from mvt.common.module import run_module, save_timeline

from .download_apks import DownloadAPKs
from .lookups.koodous import koodous_lookup
from .lookups.virustotal import virustotal_lookup
from .modules.adb import ADB_MODULES
from .modules.backup import BACKUP_MODULES


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 16 Column: 1

              from mvt.common.module import run_module, save_timeline

from .download_apks import DownloadAPKs
from .lookups.koodous import koodous_lookup
from .lookups.virustotal import virustotal_lookup
from .modules.adb import ADB_MODULES
from .modules.backup import BACKUP_MODULES

# Setup logging using Rich.

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 1

              
from .download_apks import DownloadAPKs
from .lookups.koodous import koodous_lookup
from .lookups.virustotal import virustotal_lookup
from .modules.adb import ADB_MODULES
from .modules.backup import BACKUP_MODULES

# Setup logging using Rich.
LOG_FORMAT = "[%(name)s] %(message)s"

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 18 Column: 1

              from .download_apks import DownloadAPKs
from .lookups.koodous import koodous_lookup
from .lookups.virustotal import virustotal_lookup
from .modules.adb import ADB_MODULES
from .modules.backup import BACKUP_MODULES

# Setup logging using Rich.
LOG_FORMAT = "[%(name)s] %(message)s"
logging.basicConfig(level="INFO", format=LOG_FORMAT, handlers=[

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 19 Column: 1

              from .lookups.koodous import koodous_lookup
from .lookups.virustotal import virustotal_lookup
from .modules.adb import ADB_MODULES
from .modules.backup import BACKUP_MODULES

# Setup logging using Rich.
LOG_FORMAT = "[%(name)s] %(message)s"
logging.basicConfig(level="INFO", format=LOG_FORMAT, handlers=[
    RichHandler(show_path=False, log_time_format="%X")])

            

Reported by Pylint.

TODO: Do we actually want to be able to run without storing any file?
Error

Line: 59 Column: 3

                      if from_file:
            download = DownloadAPKs.from_json(from_file)
        else:
            # TODO: Do we actually want to be able to run without storing any file?
            if not output:
                log.critical("You need to specify an output folder with --output!")
                ctx.exit(1)

            if not os.path.exists(output):

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 67 Column: 24

                          if not os.path.exists(output):
                try:
                    os.makedirs(output)
                except Exception as e:
                    log.critical("Unable to create output folder %s: %s", output, e)
                    ctx.exit(1)

            download = DownloadAPKs(output_folder=output, all_apks=all_apks)
            if serial:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 116 Column: 16

                  if output and not os.path.exists(output):
        try:
            os.makedirs(output)
        except Exception as e:
            log.critical("Unable to create output folder %s: %s", output, e)
            ctx.exit(1)

    indicators = Indicators(log=log)
    for ioc_path in iocs:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 170 Column: 16

                  if output and not os.path.exists(output):
        try:
            os.makedirs(output)
        except Exception as e:
            log.critical("Unable to create output folder %s: %s", output, e)
            ctx.exit(1)

    indicators = Indicators(log=log)
    for ioc_path in iocs:

            

Reported by Pylint.

mvt/ios/modules/backup/manifest.py
22 issues
Attempted relative import beyond top-level package
Error

Line: 15 Column: 1

              from mvt.common.module import DatabaseNotFoundError
from mvt.common.utils import convert_timestamp_to_iso

from ..base import IOSExtraction


class Manifest(IOSExtraction):
    """This module extracts information from a backup Manifest.db file."""


            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 21 Column: 5

              class Manifest(IOSExtraction):
    """This module extracts information from a backup Manifest.db file."""

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

No exception type(s) specified
Error

Line: 128 Column: 17

                                      "owner": self._get_key(file_metadata, "UserID"),
                        "size": self._get_key(file_metadata, "Size"),
                    })
                except:
                    self.log.exception("Error reading manifest file metadata for file with ID %s and relative path %s",
                                       file_data["fileID"], file_data["relativePath"])
                    pass

            self.results.append(cleaned_metadata)

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 131 Column: 21

                              except:
                    self.log.exception("Error reading manifest file metadata for file with ID %s and relative path %s",
                                       file_data["fileID"], file_data["relativePath"])
                    pass

            self.results.append(cleaned_metadata)

        cur.close()
        conn.close()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mobile Verification Toolkit (MVT)
# Copyright (c) 2021 The MVT Project Authors.
# Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

import datetime
import io
import os
import plistlib

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 21 Column: 5

              class Manifest(IOSExtraction):
    """This module extracts information from a backup Manifest.db file."""

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

Method could be a function
Error

Line: 27 Column: 5

                                       output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)

    def _get_key(self, dictionary, key):
        """Unserialized plist objects can have keys which are str or byte types
        This is a helper to try fetch a key as both a byte or string type.
        """
        return dictionary.get(key.encode("utf-8"), None) or dictionary.get(key, None)


            

Reported by Pylint.

Method could be a function
Error

Line: 33 Column: 5

                      """
        return dictionary.get(key.encode("utf-8"), None) or dictionary.get(key, None)

    def _convert_timestamp(self, timestamp_or_unix_time_int):
        """Older iOS versions stored the manifest times as unix timestamps.
        """
        if isinstance(timestamp_or_unix_time_int, datetime.datetime):
            return convert_timestamp_to_iso(timestamp_or_unix_time_int)
        else:

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 36 Column: 9

                  def _convert_timestamp(self, timestamp_or_unix_time_int):
        """Older iOS versions stored the manifest times as unix timestamps.
        """
        if isinstance(timestamp_or_unix_time_int, datetime.datetime):
            return convert_timestamp_to_iso(timestamp_or_unix_time_int)
        else:
            timestamp = datetime.datetime.utcfromtimestamp(timestamp_or_unix_time_int)
            return convert_timestamp_to_iso(timestamp)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 5

                          timestamp = datetime.datetime.utcfromtimestamp(timestamp_or_unix_time_int)
            return convert_timestamp_to_iso(timestamp)

    def serialize(self, record):
        records = []
        if "modified" not in record or "status_changed" not in record:
            return
        for ts in set([record["created"], record["modified"], record["status_changed"]]):
            macb = ""

            

Reported by Pylint.

mvt/ios/decrypt.py
21 issues
Unable to import 'iOSbackup'
Error

Line: 13 Column: 1

              import shutil
import sqlite3

from iOSbackup import iOSbackup

log = logging.getLogger(__name__)

class DecryptBackup:
    """This class provides functions to decrypt an encrypted iTunes backup

            

Reported by Pylint.

Instance of 'Exception' has no 'filename' member
Error

Line: 124 Column: 72

                      except Exception as e:
            if isinstance(e, KeyError) and len(e.args) > 0 and e.args[0] == b"KEY":
                log.critical("Failed to decrypt backup. Password is probably wrong.")
            elif isinstance(e, FileNotFoundError) and os.path.basename(e.filename) == "Manifest.plist":
                log.critical("Failed to find a valid backup at %s. Did you point to the right backup path?",
                             self.backup_path)
            else:
                log.exception(e)
                log.critical("Failed to decrypt backup. Did you provide the correct password? Did you point to the right backup path?")

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 85 Column: 20

                                                                targetName=file_id,
                                                  targetFolder=item_folder)
                log.info("Decrypted file %s [%s] to %s/%s", relative_path, domain, item_folder, file_id)
            except Exception as e:
                log.error("Failed to decrypt file %s: %s", relative_path, e)

        # Copying over the root plist files as well.
        for file_name in os.listdir(self.backup_path):
            if file_name.endswith(".plist"):

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 121 Column: 16

                          self._backup = iOSbackup(udid=os.path.basename(self.backup_path),
                                     cleartextpassword=password,
                                     backuproot=os.path.dirname(self.backup_path))
        except Exception as e:
            if isinstance(e, KeyError) and len(e.args) > 0 and e.args[0] == b"KEY":
                log.critical("Failed to decrypt backup. Password is probably wrong.")
            elif isinstance(e, FileNotFoundError) and os.path.basename(e.filename) == "Manifest.plist":
                log.critical("Failed to find a valid backup at %s. Did you point to the right backup path?",
                             self.backup_path)

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 155 Column: 16

                          self._backup = iOSbackup(udid=os.path.basename(self.backup_path),
                                     derivedkey=key_bytes_raw,
                                     backuproot=os.path.dirname(self.backup_path))
        except Exception as e:
            log.exception(e)
            log.critical("Failed to decrypt backup. Did you provide the correct key file?")

    def get_key(self):
        """Retrieve and prints the encryption key.

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 179 Column: 16

                      try:
            with open(key_path, 'w') as handle:
                handle.write(self._decryption_key)
        except Exception as e:
            log.exception(e)
            log.critical("Failed to write key to file: %s", key_path)
            return
        else:
            log.info("Wrote decryption key to file: %s. This file is equivalent to a plaintext password. Keep it safe!",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mobile Verification Toolkit (MVT)
# Copyright (c) 2021 The MVT Project Authors.
# Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

import binascii
import glob
import logging
import os

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 5

                      self._backup = None
        self._decryption_key = None

    def can_process(self) -> bool:
        return self._backup is not None

    def is_encrypted(self, backup_path) -> bool:
        """Query Manifest.db file to see if it's encrypted or not.
        :param backup_path: Path to the backup to decrypt

            

Reported by Pylint.

Method could be a function
Error

Line: 35 Column: 5

                  def can_process(self) -> bool:
        return self._backup is not None

    def is_encrypted(self, backup_path) -> bool:
        """Query Manifest.db file to see if it's encrypted or not.
        :param backup_path: Path to the backup to decrypt
        """
        conn = sqlite3.connect(os.path.join(backup_path, "Manifest.db"))
        cur = conn.cursor()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 49 Column: 5

                          log.critical("The backup does not seem encrypted!")
            return False

    def process_backup(self):
        if not os.path.exists(self.dest_path):
            os.makedirs(self.dest_path)

        manifest_path = os.path.join(self.dest_path, "Manifest.db")
        # We extract a decrypted Manifest.db.

            

Reported by Pylint.

mvt/common/indicators.py
21 issues
Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              import json
import os

from .url import URL


class IndicatorsFileBadFormat(Exception):
    pass


            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 43 Column: 17

                          try:
                data = json.load(handle)
            except json.decoder.JSONDecodeError:
                raise IndicatorsFileBadFormat("Unable to parse STIX2 indicators file, the file seems malformed or in the wrong format")

        for entry in data.get("objects", []):
            if entry.get("type", "") != "indicator":
                continue


            

Reported by Pylint.

TODO: If the IOC domain contains a subdomain, it is not currently
Error

Line: 68 Column: 3

                                                  iocs_list=self.ioc_files)

    def check_domain(self, url):
        # TODO: If the IOC domain contains a subdomain, it is not currently
        # being matched.

        try:
            # First we use the provided URL.
            orig_url = URL(url)

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 94 Column: 16

                          else:
                # If it's not shortened, we just use the original URL object.
                final_url = orig_url
        except Exception as e:
            # If URL parsing failed, we just try to do a simple substring
            # match.
            for ioc in self.ioc_domains:
                if ioc.lower() in url:
                    self.log.warning("Maybe found a known suspicious domain: %s", url)

            

Reported by Pylint.

Unused variable 'e'
Error

Line: 94 Column: 9

                          else:
                # If it's not shortened, we just use the original URL object.
                final_url = orig_url
        except Exception as e:
            # If URL parsing failed, we just try to do a simple substring
            # match.
            for ioc in self.ioc_domains:
                if ioc.lower() in url:
                    self.log.warning("Maybe found a known suspicious domain: %s", url)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mobile Verification Toolkit (MVT)
# Copyright (c) 2021 The MVT Project Authors.
# Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

import json
import os

from .url import URL

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              from .url import URL


class IndicatorsFileBadFormat(Exception):
    pass

class Indicators:
    """This class is used to parse indicators from a STIX2 file and provide
    functions to compare extracted artifacts to the indicators.

            

Reported by Pylint.

Line too long (135/100)
Error

Line: 43 Column: 1

                          try:
                data = json.load(handle)
            except json.decoder.JSONDecodeError:
                raise IndicatorsFileBadFormat("Unable to parse STIX2 indicators file, the file seems malformed or in the wrong format")

        for entry in data.get("objects", []):
            if entry.get("type", "") != "indicator":
                continue


            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 67 Column: 5

                              self._add_indicator(ioc=value,
                                    iocs_list=self.ioc_files)

    def check_domain(self, url):
        # TODO: If the IOC domain contains a subdomain, it is not currently
        # being matched.

        try:
            # First we use the provided URL.

            

Reported by Pylint.

Too many branches (13/12)
Error

Line: 67 Column: 5

                              self._add_indicator(ioc=value,
                                    iocs_list=self.ioc_files)

    def check_domain(self, url):
        # TODO: If the IOC domain contains a subdomain, it is not currently
        # being matched.

        try:
            # First we use the provided URL.

            

Reported by Pylint.

mvt/ios/modules/mixed/interactionc.py
19 issues
Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              
from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso

from ..base import IOSExtraction

INTERACTIONC_BACKUP_IDS = [
    "1f5a521220a3ad80ebfdc196978df8e7a2e49dee",
]
INTERACTIONC_ROOT_PATHS = [

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 22 Column: 5

              class InteractionC(IOSExtraction):
    """This module extracts data from InteractionC db."""

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

TODO: Support all versions.
Error

Line: 72 Column: 3

                      conn = sqlite3.connect(self.file_path)
        cur = conn.cursor()

        # TODO: Support all versions.
        # Taken from:
        # https://github.com/mac4n6/APOLLO/blob/master/modules/interaction_contact_interactions.txt
        cur.execute("""
            SELECT
                ZINTERACTIONS.ZSTARTDATE,

            

Reported by Pylint.

Unused variable 'names'
Error

Line: 127 Column: 9

                              LEFT JOIN ZCONTACTS RECEIPIENTCONACT ON Z_2INTERACTIONRECIPIENT.Z_2RECIPIENTS== RECEIPIENTCONACT.Z_PK;
        """)

        names = [description[0] for description in cur.description]

        for row in cur:
            self.results.append({
                "start_date": convert_timestamp_to_iso(convert_mactime_to_unix(row[0])),
                "end_date": convert_timestamp_to_iso(convert_mactime_to_unix(row[1])),

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mobile Verification Toolkit (MVT)
# Copyright (c) 2021 The MVT Project Authors.
# Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

import sqlite3

from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso


            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 22 Column: 5

              class InteractionC(IOSExtraction):
    """This module extracts data from InteractionC db."""

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 5

                          "last_outgoing_recipient_date",
        ]

    def serialize(self, record):
        records = []
        processed = []
        for ts in self.timestamps:
            # Check if the record has the current timestamp.
            if ts not in record or not record[ts]:

            

Reported by Pylint.

Variable name "ts" doesn't conform to snake_case naming style
Error

Line: 44 Column: 13

                  def serialize(self, record):
        records = []
        processed = []
        for ts in self.timestamps:
            # Check if the record has the current timestamp.
            if ts not in record or not record[ts]:
                continue

            # Check if the timestamp was already processed.

            

Reported by Pylint.

Line too long (112/100)
Error

Line: 57 Column: 1

                              "timestamp": record[ts],
                "module": self.__class__.__name__,
                "event": ts,
                "data": f"[{record['bundle_id']}] {record['account']} - from {record['sender_display_name']} " \
                        f"({record['sender_identifier']}) to {record['recipient_display_name']} " \
                        f"({record['recipient_identifier']}): {record['content']}"
            })
            processed.append(record[ts])


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 65 Column: 5

              
        return records

    def run(self):
        self._find_ios_database(backup_ids=INTERACTIONC_BACKUP_IDS, root_paths=INTERACTIONC_ROOT_PATHS)
        self.log.info("Found InteractionC database at path: %s", self.file_path)

        conn = sqlite3.connect(self.file_path)
        cur = conn.cursor()

            

Reported by Pylint.

mvt/ios/modules/mixed/webkit_resource_load_statistics.py
19 issues
Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              
from mvt.common.utils import convert_timestamp_to_iso

from ..base import IOSExtraction

WEBKIT_RESOURCELOADSTATICS_BACKUP_RELPATH = "Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db"
WEBKIT_RESOURCELOADSTATICS_ROOT_PATHS = [
    "private/var/mobile/Containers/Data/Application/*/Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db",
    "private/var/mobile/Containers/Data/Application/*/SystemData/com.apple.SafariViewService/Library/WebKit/WebsiteData/observations.db",

            

Reported by Pylint.

TODO: Add serialize().
Error

Line: 23 Column: 3

              class WebkitResourceLoadStatistics(IOSExtraction):
    """This module extracts records from WebKit ResourceLoadStatistics observations.db.
    """
    # TODO: Add serialize().

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 25 Column: 5

                  """
    # TODO: Add serialize().

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

Attribute 'detected' defined outside __init__
Error

Line: 37 Column: 9

                      if not self.indicators:
            return

        self.detected = {}
        for key, items in self.results.items():
            for item in items:
                if self.indicators.check_domain(item["registrable_domain"]):
                    if key not in self.detected:
                        self.detected[key] = [item,]

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 81 Column: 20

                                  db_path = os.path.join(self.base_folder, backup_file["file_id"][0:2], backup_file["file_id"])
                    key = f"{backup_file['domain']}/{WEBKIT_RESOURCELOADSTATICS_BACKUP_RELPATH}"
                    self._process_observations_db(db_path=db_path, key=key)
            except Exception as e:
                self.log.info("Unable to search for WebKit observations.db: %s", e)
        elif self.is_fs_dump:
            for db_path in self._get_fs_files_from_patterns(WEBKIT_RESOURCELOADSTATICS_ROOT_PATHS):
                self._process_observations_db(db_path=db_path, key=os.path.relpath(db_path, self.base_folder))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mobile Verification Toolkit (MVT)
# Copyright (c) 2021 The MVT Project Authors.
# Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

import datetime
import os
import sqlite3


            

Reported by Pylint.

Line too long (111/100)
Error

Line: 14 Column: 1

              
from ..base import IOSExtraction

WEBKIT_RESOURCELOADSTATICS_BACKUP_RELPATH = "Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db"
WEBKIT_RESOURCELOADSTATICS_ROOT_PATHS = [
    "private/var/mobile/Containers/Data/Application/*/Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db",
    "private/var/mobile/Containers/Data/Application/*/SystemData/com.apple.SafariViewService/Library/WebKit/WebsiteData/observations.db",
]


            

Reported by Pylint.

Line too long (121/100)
Error

Line: 16 Column: 1

              
WEBKIT_RESOURCELOADSTATICS_BACKUP_RELPATH = "Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db"
WEBKIT_RESOURCELOADSTATICS_ROOT_PATHS = [
    "private/var/mobile/Containers/Data/Application/*/Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db",
    "private/var/mobile/Containers/Data/Application/*/SystemData/com.apple.SafariViewService/Library/WebKit/WebsiteData/observations.db",
]

class WebkitResourceLoadStatistics(IOSExtraction):
    """This module extracts records from WebKit ResourceLoadStatistics observations.db.

            

Reported by Pylint.

Line too long (137/100)
Error

Line: 17 Column: 1

              WEBKIT_RESOURCELOADSTATICS_BACKUP_RELPATH = "Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db"
WEBKIT_RESOURCELOADSTATICS_ROOT_PATHS = [
    "private/var/mobile/Containers/Data/Application/*/Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db",
    "private/var/mobile/Containers/Data/Application/*/SystemData/com.apple.SafariViewService/Library/WebKit/WebsiteData/observations.db",
]

class WebkitResourceLoadStatistics(IOSExtraction):
    """This module extracts records from WebKit ResourceLoadStatistics observations.db.
    """

            

Reported by Pylint.

Too many arguments (7/5)
Error

Line: 25 Column: 5

                  """
    # TODO: Add serialize().

    def __init__(self, file_path=None, base_folder=None, output_folder=None,
                 fast_mode=False, log=None, results=[]):
        super().__init__(file_path=file_path, base_folder=base_folder,
                         output_folder=output_folder, fast_mode=fast_mode,
                         log=log, results=results)


            

Reported by Pylint.

mvt/ios/modules/mixed/__init__.py
18 issues
Unable to import '__init__.calls'
Error

Line: 6 Column: 1

              # Use of this software is governed by the MVT License 1.1 that can be found at
#   https://license.mvt.re/1.1/

from .calls import Calls
from .chrome_favicon import ChromeFavicon
from .chrome_history import ChromeHistory
from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory

            

Reported by Pylint.

Unable to import '__init__.chrome_favicon'
Error

Line: 7 Column: 1

              #   https://license.mvt.re/1.1/

from .calls import Calls
from .chrome_favicon import ChromeFavicon
from .chrome_history import ChromeHistory
from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache

            

Reported by Pylint.

Unable to import '__init__.chrome_history'
Error

Line: 8 Column: 1

              
from .calls import Calls
from .chrome_favicon import ChromeFavicon
from .chrome_history import ChromeHistory
from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC

            

Reported by Pylint.

Unable to import '__init__.contacts'
Error

Line: 9 Column: 1

              from .calls import Calls
from .chrome_favicon import ChromeFavicon
from .chrome_history import ChromeHistory
from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients

            

Reported by Pylint.

Unable to import '__init__.firefox_favicon'
Error

Line: 10 Column: 1

              from .chrome_favicon import ChromeFavicon
from .chrome_history import ChromeHistory
from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients
from .net_datausage import Datausage

            

Reported by Pylint.

Unable to import '__init__.firefox_history'
Error

Line: 11 Column: 1

              from .chrome_history import ChromeHistory
from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients
from .net_datausage import Datausage
from .safari_browserstate import SafariBrowserState

            

Reported by Pylint.

Unable to import '__init__.idstatuscache'
Error

Line: 12 Column: 1

              from .contacts import Contacts
from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients
from .net_datausage import Datausage
from .safari_browserstate import SafariBrowserState
from .safari_history import SafariHistory

            

Reported by Pylint.

Unable to import '__init__.interactionc'
Error

Line: 13 Column: 1

              from .firefox_favicon import FirefoxFavicon
from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients
from .net_datausage import Datausage
from .safari_browserstate import SafariBrowserState
from .safari_history import SafariHistory
from .sms import SMS

            

Reported by Pylint.

Unable to import '__init__.locationd'
Error

Line: 14 Column: 1

              from .firefox_history import FirefoxHistory
from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients
from .net_datausage import Datausage
from .safari_browserstate import SafariBrowserState
from .safari_history import SafariHistory
from .sms import SMS
from .sms_attachments import SMSAttachments

            

Reported by Pylint.

Unable to import '__init__.net_datausage'
Error

Line: 15 Column: 1

              from .idstatuscache import IDStatusCache
from .interactionc import InteractionC
from .locationd import LocationdClients
from .net_datausage import Datausage
from .safari_browserstate import SafariBrowserState
from .safari_history import SafariHistory
from .sms import SMS
from .sms_attachments import SMSAttachments
from .webkit_resource_load_statistics import WebkitResourceLoadStatistics

            

Reported by Pylint.