Improves code PEP8 compliance and adds ruff check

This commit is contained in:
tek 2023-03-01 16:43:08 -05:00
parent fc4e2a9029
commit 4ed8ff51ff
26 changed files with 79 additions and 57 deletions

21
.github/workflows/ruff.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Ruff
on: [push]
jobs:
ruff_py3:
name: Ruff syntax check
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9
architecture: x64
- name: Checkout
uses: actions/checkout@master
- name: Install Dependencies
run: |
pip install ruff
- name: ruff
run: |
ruff check .

View File

@ -1,5 +1,10 @@
PWD = $(shell pwd)
check:
flake8
pytest -q
ruff check -q .
clean:
rm -rf $(PWD)/build $(PWD)/dist $(PWD)/mvt.egg-info

View File

@ -9,10 +9,9 @@ import click
from rich.logging import RichHandler
from mvt.common.cmd_check_iocs import CmdCheckIOCS
from mvt.common.help import (HELP_MSG_FAST, HELP_MSG_IOC,
from mvt.common.help import (HELP_MSG_FAST, HELP_MSG_HASHES, HELP_MSG_IOC,
HELP_MSG_LIST_MODULES, HELP_MSG_MODULE,
HELP_MSG_OUTPUT, HELP_MSG_SERIAL,
HELP_MSG_HASHES)
HELP_MSG_OUTPUT, HELP_MSG_SERIAL)
from mvt.common.logo import logo
from mvt.common.updates import IndicatorsUpdates

View File

@ -9,15 +9,15 @@ import os
import sys
import tarfile
from pathlib import Path
from typing import Callable, Optional, List
from typing import List, Optional
from rich.prompt import Prompt
from mvt.android.modules.backup.base import BackupExtraction
from mvt.android.parsers.backup import (AndroidBackupParsingError,
InvalidBackupPassword, parse_ab_header,
parse_backup_file)
from mvt.common.command import Command
from mvt.android.modules.backup.base import BackupExtraction
from .modules.backup import BACKUP_MODULES

View File

@ -6,11 +6,11 @@
import logging
import os
from pathlib import Path
from typing import Callable, Optional, List
from typing import List, Optional
from zipfile import ZipFile
from mvt.common.command import Command
from mvt.android.modules.bugreport.base import BugReportModule
from mvt.common.command import Command
from .modules.bugreport import BUGREPORT_MODULES

View File

@ -4,7 +4,7 @@
# https://license.mvt.re/1.1/
import logging
from typing import Optional, Union, List
from typing import List, Optional, Union
from rich.console import Console
from rich.progress import track

View File

@ -6,7 +6,7 @@
import fnmatch
import logging
import os
from typing import Union, List, Dict, Any, Optional
from typing import Any, Dict, List, Optional, Union
from mvt.common.module import MVTModule

View File

@ -4,14 +4,12 @@
# https://license.mvt.re/1.1/
import logging
from datetime import datetime
from typing import Optional, Union, List, Any, Dict
from typing import Any, Dict, List, Optional, Union
from mvt.android.modules.adb.packages import (DANGEROUS_PERMISSIONS,
DANGEROUS_PERMISSIONS_THRESHOLD,
ROOT_PACKAGES)
from mvt.android.parsers.dumpsys import parse_dumpsys_packages
from mvt.common.utils import convert_datetime_to_iso
from .base import AndroidQFModule

View File

@ -4,7 +4,7 @@
# https://license.mvt.re/1.1/
import logging
from typing import Optional, List, Dict, Union, Any
from typing import Any, Dict, List, Optional, Union
from mvt.android.modules.adb.dumpsys_receivers import (
INTENT_DATA_SMS_RECEIVED, INTENT_NEW_OUTGOING_CALL,

View File

@ -1,7 +1,7 @@
# Mobile Verification Toolkit (MVT) - Private
# Mobile Verification Toolkit (MVT)
# Copyright (c) 2021-2023 Claudio Guarnieri.
# This file is part of MVT Private and its content is confidential.
# Please refer to the project maintainers before sharing with others.
# Use of this software is governed by the MVT License 1.1 that can be found at
# https://license.mvt.re/1.1
import getpass
import logging

View File

@ -7,7 +7,7 @@ import fnmatch
import logging
import os
from tarfile import TarFile
from typing import Optional, List
from typing import List, Optional
from mvt.common.module import MVTModule

View File

@ -6,7 +6,7 @@
import fnmatch
import logging
import os
from typing import Optional, List
from typing import List, Optional
from zipfile import ZipFile
from mvt.common.module import MVTModule

View File

@ -4,8 +4,8 @@
# https://license.mvt.re/1.1/
import re
from typing import List, Dict, Any
from datetime import datetime
from typing import Any, Dict, List
from mvt.common.utils import convert_datetime_to_iso

View File

@ -3,17 +3,18 @@
# Use of this software is governed by the MVT License 1.1 that can be found at
# https://license.mvt.re/1.1/
import hashlib
import json
import logging
import os
import sys
from datetime import datetime
from typing import Callable, Optional
from typing import Optional
from mvt.common.indicators import Indicators
from mvt.common.module import run_module, save_timeline, MVTModule
from mvt.common.utils import convert_datetime_to_iso, generate_hashes_from_path, get_sha256_from_file_path
from mvt.common.module import MVTModule, run_module, save_timeline
from mvt.common.utils import (convert_datetime_to_iso,
generate_hashes_from_path,
get_sha256_from_file_path)
from mvt.common.version import MVT_VERSION

View File

@ -7,7 +7,7 @@ import csv
import logging
import os
import re
from typing import Callable, Optional, Union, List, Any, Dict
from typing import Any, Callable, Dict, List, Optional, Union
import simplejson as json

View File

@ -3,11 +3,11 @@
# Use of this software is governed by the MVT License 1.1 that can be found at
# https://license.mvt.re/1.1/
import os
import datetime
import hashlib
import os
import re
from typing import Union, Iterator
from typing import Iterator, Union
def convert_chrometime_to_datetime(timestamp: int) -> datetime.datetime:

View File

@ -3,18 +3,18 @@
# 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 logging
import os
import json
import click
from rich.logging import RichHandler
from rich.prompt import Prompt
from mvt.common.cmd_check_iocs import CmdCheckIOCS
from mvt.common.help import (HELP_MSG_FAST, HELP_MSG_IOC,
from mvt.common.help import (HELP_MSG_FAST, HELP_MSG_HASHES, HELP_MSG_IOC,
HELP_MSG_LIST_MODULES, HELP_MSG_MODULE,
HELP_MSG_OUTPUT, HELP_MSG_HASHES)
HELP_MSG_OUTPUT)
from mvt.common.logo import logo
from mvt.common.options import MutuallyExclusiveOption
from mvt.common.updates import IndicatorsUpdates

View File

@ -2,9 +2,8 @@
# 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 typing import Dict
from logging import Logger
from typing import Optional
from typing import Dict, Optional
import packaging

6
ruff.toml Normal file
View File

@ -0,0 +1,6 @@
# Never enforce `E501` (line length violations).
ignore = ["E501"]
# Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`.
[per-file-ignores]
"__init__.py" = ["F401"]

View File

@ -1,9 +1,7 @@
# Mobile Verification Toolkit (MVT) - Private
# Mobile Verification Toolkit (MVT)
# Copyright (c) 2021-2023 Claudio Guarnieri.
# This file is part of MVT Private and its content is confidential.
# Please refer to the project maintainers before sharing with others.
import logging
# 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.android.modules.androidqf.dumpsys_accessibility import \
DumpsysAccessibility

View File

@ -1,9 +1,7 @@
# Mobile Verification Toolkit (MVT) - Private
# Mobile Verification Toolkit (MVT)
# Copyright (c) 2021-2023 Claudio Guarnieri.
# This file is part of MVT Private and its content is confidential.
# Please refer to the project maintainers before sharing with others.
import logging
# 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.android.modules.androidqf.dumpsys_appops import DumpsysAppops
from mvt.common.module import run_module

View File

@ -1,7 +1,7 @@
# Mobile Verification Toolkit (MVT) - Private
# Mobile Verification Toolkit (MVT)
# Copyright (c) 2021-2023 Claudio Guarnieri.
# This file is part of MVT Private and its content is confidential.
# Please refer to the project maintainers before sharing with others.
# Use of this software is governed by the MVT License 1.1 that can be found at
# https://license.mvt.re/1.1/
import logging

View File

@ -1,9 +1,7 @@
# Mobile Verification Toolkit (MVT) - Private
# Mobile Verification Toolkit (MVT)
# Copyright (c) 2021-2023 Claudio Guarnieri.
# This file is part of MVT Private and its content is confidential.
# Please refer to the project maintainers before sharing with others.
import logging
# 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.android.modules.androidqf.dumpsys_receivers import DumpsysReceivers
from mvt.common.module import run_module

View File

@ -1,7 +1,7 @@
# Mobile Verification Toolkit (MVT) - Private
# Mobile Verification Toolkit (MVT)
# Copyright (c) 2021-2023 Claudio Guarnieri.
# This file is part of MVT Private and its content is confidential.
# Please refer to the project maintainers before sharing with others.
# 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.android.modules.androidqf.settings import Settings
from mvt.common.module import run_module

View File

@ -3,15 +3,17 @@
# Use of this software is governed by the MVT License 1.1 that can be found at
# https://license.mvt.re/1.1/
import os
import logging
from ..utils import get_artifact_folder
import os
from mvt.common.utils import (convert_datetime_to_iso, convert_mactime_to_iso,
convert_unix_to_iso,
convert_unix_to_utc_datetime,
generate_hashes_from_path,
get_sha256_from_file_path)
from ..utils import get_artifact_folder
TEST_DATE_EPOCH = 1626566400
TEST_DATE_ISO = "2021-07-18 00:00:00.000000"
TEST_DATE_MAC = TEST_DATE_EPOCH - 978307200

View File

@ -3,9 +3,6 @@
# Use of this software is governed by the MVT License 1.1 that can be found at
# https://license.mvt.re/1.1/
import logging
from mvt.common.indicators import Indicators
from mvt.common.module import run_module
from mvt.ios.modules.mixed.webkit_resource_load_statistics import \
WebkitResourceLoadStatistics