From 9ef4e49db40b531345025efa3b68c4074af8a692 Mon Sep 17 00:00:00 2001 From: RahulSankhla312 Date: Tue, 19 Mar 2024 16:24:53 +0530 Subject: [PATCH] Added isort style --- floss/api_hooks.py | 2 +- floss/decoding_manager.py | 6 +-- floss/features/extract.py | 31 +++--------- floss/function_argument_getter.py | 8 ++-- floss/identify.py | 22 ++++----- floss/language/go/coverage.py | 10 ++-- floss/language/go/extract.py | 21 ++++---- floss/language/identify.py | 6 +-- floss/language/rust/coverage.py | 10 ++-- floss/language/rust/extract.py | 20 ++++---- floss/language/utils.py | 8 ++-- floss/main.py | 66 +++++++++++--------------- floss/render/default.py | 20 +++----- floss/render/json.py | 4 +- floss/results.py | 11 ++--- floss/stackstrings.py | 10 ++-- floss/string_decoder.py | 25 +++++----- floss/strings.py | 2 +- floss/tightstrings.py | 12 ++--- floss/utils.py | 21 ++++---- scripts/idaplugin.py | 12 ++--- scripts/render-binja-import-script.py | 4 +- scripts/render-ghidra-import-script.py | 4 +- scripts/render-ida-import-script.py | 4 +- scripts/render-r2-import-script.py | 4 +- scripts/render-x64dbg-database.py | 10 ++-- tests/conftest.py | 15 +++--- tests/test_cli_args.py | 2 +- tests/test_language_extract_go.py | 2 +- tests/test_language_extract_rust.py | 2 +- tests/test_language_go_coverage.py | 6 +-- tests/test_language_id.py | 7 +-- tests/test_language_rust_coverage.py | 6 +-- tests/test_main.py | 2 +- tests/test_memdiff.py | 2 +- tests/test_render.py | 15 ++---- tests/test_scripts.py | 4 +- 37 files changed, 178 insertions(+), 238 deletions(-) diff --git a/floss/api_hooks.py b/floss/api_hooks.py index 161fb65f8..44a819bd0 100644 --- a/floss/api_hooks.py +++ b/floss/api_hooks.py @@ -6,8 +6,8 @@ import envi import viv_utils.emulator_drivers -import floss.utils as fu import floss.logging_ +import floss.utils as fu from floss.const import MOD_NAME logger = floss.logging_.getLogger(__name__) diff --git a/floss/decoding_manager.py b/floss/decoding_manager.py index de73ca443..a9a78ff6e 100644 --- a/floss/decoding_manager.py +++ b/floss/decoding_manager.py @@ -1,15 +1,15 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. -from typing import List, Tuple from dataclasses import dataclass +from typing import List, Tuple -import viv_utils import envi.memory +import viv_utils import viv_utils.emulator_drivers from envi import Emulator -import floss.utils import floss.logging_ +import floss.utils from . import api_hooks from .const import DS_MAX_ADDRESS_REVISITS_EMULATION diff --git a/floss/features/extract.py b/floss/features/extract.py index 5068929a2..e9c0389cd 100644 --- a/floss/features/extract.py +++ b/floss/features/extract.py @@ -1,37 +1,20 @@ # Copyright (C) 2021 Mandiant, Inc. All Rights Reserved. -from typing import Any, Tuple, Callable, Iterator +from typing import Any, Callable, Iterator, Tuple import envi import networkx -import vivisect import viv_utils +import vivisect +from envi.archs.i386.opconst import (INS_CALL, INS_MOV, INS_ROL, INS_ROR, + INS_SHL, INS_SHR, INS_XOR) from networkx import strongly_connected_components from viv_utils import BasicBlock -from envi.archs.i386.opconst import ( - INS_MOV, - INS_ROL, - INS_ROR, - INS_SHL, - INS_SHR, - INS_XOR, - INS_CALL, -) import floss.logging_ from floss.const import TS_TIGHT_FUNCTION_MAX_BLOCKS -from floss.features.features import ( - Mov, - Loop, - Nzxor, - Shift, - CallsTo, - NzxorLoop, - TightLoop, - BlockCount, - TightFunction, - KindaTightLoop, - NzxorTightLoop, -) +from floss.features.features import (BlockCount, CallsTo, KindaTightLoop, Loop, + Mov, Nzxor, NzxorLoop, NzxorTightLoop, + Shift, TightFunction, TightLoop) # security cookie checks may perform non-zeroing XORs, these are expected within a certain # byte range within the first and returning basic blocks, this helps to reduce FP features diff --git a/floss/function_argument_getter.py b/floss/function_argument_getter.py index cced6b091..22e446e16 100644 --- a/floss/function_argument_getter.py +++ b/floss/function_argument_getter.py @@ -1,17 +1,17 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. import contextlib -from typing import Set, List from collections import namedtuple +from typing import List, Set import envi -import vivisect import viv_utils import viv_utils.emulator_drivers +import vivisect -import floss.utils -import floss.logging_ import floss.api_hooks +import floss.logging_ +import floss.utils FunctionContext = namedtuple( "FunctionContext", ["emu_snap", "return_address", "decoded_at_va"] diff --git a/floss/identify.py b/floss/identify.py index 88b6afbeb..047abc075 100644 --- a/floss/identify.py +++ b/floss/identify.py @@ -1,9 +1,9 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. +import collections import copy import operator -import collections -from typing import Dict, List, Tuple, DefaultDict +from typing import DefaultDict, Dict, List, Tuple import tqdm import viv_utils @@ -11,19 +11,13 @@ from tqdm.contrib.logging import logging_redirect_tqdm import floss.logging_ +from floss.features.extract import (abstract_features, + extract_basic_block_features, + extract_function_features, + extract_insn_features) +from floss.features.features import (Arguments, BlockCount, InstructionCount, + TightFunction) from floss.utils import is_thunk_function, redirecting_print_to_tqdm -from floss.features.extract import ( - abstract_features, - extract_insn_features, - extract_function_features, - extract_basic_block_features, -) -from floss.features.features import ( - Arguments, - BlockCount, - TightFunction, - InstructionCount, -) logger = floss.logging_.getLogger(__name__) diff --git a/floss/language/go/coverage.py b/floss/language/go/coverage.py index ef7f1196c..716f8dd52 100644 --- a/floss/language/go/coverage.py +++ b/floss/language/go/coverage.py @@ -1,16 +1,16 @@ # Copyright (C) 2023 Mandiant, Inc. All Rights Reserved. -import sys +import argparse import logging import pathlib -import argparse +import sys from typing import List import pefile -from floss.utils import get_static_strings -from floss.results import StaticString, StringEncoding -from floss.language.utils import get_extract_stats from floss.language.go.extract import extract_go_strings +from floss.language.utils import get_extract_stats +from floss.results import StaticString, StringEncoding +from floss.utils import get_static_strings logger = logging.getLogger(__name__) diff --git a/floss/language/go/extract.py b/floss/language/go/extract.py index bd73ccb2f..f59854b12 100644 --- a/floss/language/go/extract.py +++ b/floss/language/go/extract.py @@ -1,27 +1,24 @@ # Copyright (C) 2023 Mandiant, Inc. All Rights Reserved. -import re -import sys +import argparse import array -import struct import logging import pathlib -import argparse -from typing import List, Tuple, Iterable, Optional -from pathlib import Path -from itertools import chain +import re +import struct +import sys from dataclasses import dataclass +from itertools import chain +from pathlib import Path +from typing import Iterable, List, Optional, Tuple import pefile from typing_extensions import TypeAlias import floss.utils +from floss.language.utils import (StructString, find_lea_xrefs, + get_struct_string_candidates) from floss.results import StaticString, StringEncoding -from floss.language.utils import ( - StructString, - find_lea_xrefs, - get_struct_string_candidates, -) logger = logging.getLogger(__name__) diff --git a/floss/language/identify.py b/floss/language/identify.py index ad45ade26..c2b269db7 100644 --- a/floss/language/identify.py +++ b/floss/language/identify.py @@ -2,15 +2,15 @@ import re from enum import Enum -from typing import Tuple, Iterable from pathlib import Path +from typing import Iterable, Tuple import pefile import floss.logging_ -from floss.results import StaticString -from floss.language.utils import get_rdata_section from floss.language.rust.rust_version_database import rust_commit_hash +from floss.language.utils import get_rdata_section +from floss.results import StaticString logger = floss.logging_.getLogger(__name__) diff --git a/floss/language/rust/coverage.py b/floss/language/rust/coverage.py index 0348833db..22900dd7b 100644 --- a/floss/language/rust/coverage.py +++ b/floss/language/rust/coverage.py @@ -1,16 +1,16 @@ # Copyright (C) 2023 Mandiant, Inc. All Rights Reserved. -import sys +import argparse import logging import pathlib -import argparse -from typing import List, Tuple, Iterable, Optional +import sys +from typing import Iterable, List, Optional, Tuple import pefile -from floss.strings import extract_ascii_unicode_strings -from floss.language.utils import get_extract_stats from floss.language.rust.extract import extract_rust_strings +from floss.language.utils import get_extract_stats +from floss.strings import extract_ascii_unicode_strings logger = logging.getLogger(__name__) diff --git a/floss/language/rust/extract.py b/floss/language/rust/extract.py index 36dbb0914..076fea7a9 100644 --- a/floss/language/rust/extract.py +++ b/floss/language/rust/extract.py @@ -1,22 +1,18 @@ # Copyright (C) 2023 Mandiant, Inc. All Rights Reserved. -import sys -import logging -import pathlib import argparse import itertools -from typing import List, Tuple, Iterable, Optional +import logging +import pathlib +import sys +from typing import Iterable, List, Optional, Tuple -import pefile import binary2strings as b2s +import pefile +from floss.language.utils import (find_lea_xrefs, find_mov_xrefs, + find_push_xrefs, get_rdata_section, + get_struct_string_candidates) from floss.results import StaticString, StringEncoding -from floss.language.utils import ( - find_lea_xrefs, - find_mov_xrefs, - find_push_xrefs, - get_rdata_section, - get_struct_string_candidates, -) logger = logging.getLogger(__name__) diff --git a/floss/language/utils.py b/floss/language/utils.py index 4c28ded6e..24207d676 100644 --- a/floss/language/utils.py +++ b/floss/language/utils.py @@ -1,17 +1,17 @@ -import re import array -import struct import hashlib -from typing import List, Tuple, Iterable, Optional +import re +import struct from dataclasses import dataclass +from typing import Iterable, List, Optional, Tuple import pefile import tabulate from typing_extensions import TypeAlias import floss.utils -from floss.results import StaticString, StringEncoding from floss.render.sanitize import sanitize +from floss.results import StaticString, StringEncoding VA: TypeAlias = int diff --git a/floss/main.py b/floss/main.py index 0aacedb9a..2442eba32 100644 --- a/floss/main.py +++ b/floss/main.py @@ -1,60 +1,50 @@ #!/usr/bin/env python # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. -import os -import sys +import argparse import codecs import logging -import argparse +import os +import sys import textwrap from enum import Enum -from time import time -from typing import Set, List, Optional from pathlib import Path +from time import time +from typing import List, Optional, Set import halo -import viv_utils import rich.traceback +import viv_utils import viv_utils.flirt from vivisect import VivWorkspace -import floss.utils -import floss.results -import floss.version -import floss.logging_ -import floss.render.json -import floss.language.utils -import floss.render.default -import floss.language.go.extract import floss.language.go.coverage -import floss.language.rust.extract +import floss.language.go.extract import floss.language.rust.coverage -from floss.const import MEGABYTE, MAX_FILE_SIZE, MIN_STRING_LENGTH, SUPPORTED_FILE_MAGIC -from floss.utils import ( - hex, - get_imagebase, - get_runtime_diff, - get_static_strings, - get_vivisect_meta_info, - is_string_type_enabled, - set_vivisect_log_level, -) +import floss.language.rust.extract +import floss.language.utils +import floss.logging_ +import floss.render.default +import floss.render.json +import floss.results +import floss.utils +import floss.version +from floss.const import (MAX_FILE_SIZE, MEGABYTE, MIN_STRING_LENGTH, + SUPPORTED_FILE_MAGIC) +from floss.identify import (append_unique, find_decoding_function_features, + get_function_fvas, get_functions_with_tightloops, + get_functions_without_tightloops, + get_tight_function_fvas, get_top_functions) +from floss.language.identify import Language, identify_language_and_version +from floss.logging_ import TRACE, DebugLevel from floss.render import Verbosity from floss.results import Analysis, Metadata, ResultDocument, load -from floss.version import __version__ -from floss.identify import ( - append_unique, - get_function_fvas, - get_top_functions, - get_tight_function_fvas, - get_functions_with_tightloops, - find_decoding_function_features, - get_functions_without_tightloops, -) -from floss.logging_ import TRACE, DebugLevel from floss.stackstrings import extract_stackstrings -from floss.tightstrings import extract_tightstrings from floss.string_decoder import decode_strings -from floss.language.identify import Language, identify_language_and_version +from floss.tightstrings import extract_tightstrings +from floss.utils import (get_imagebase, get_runtime_diff, get_static_strings, + get_vivisect_meta_info, hex, is_string_type_enabled, + set_vivisect_log_level) +from floss.version import __version__ SIGNATURES_PATH_DEFAULT_STRING = "(embedded signatures)" EXTENSIONS_SHELLCODE_32 = ("sc32", "raw32") diff --git a/floss/render/default.py b/floss/render/default.py index 0ef967626..f4fcd932c 100644 --- a/floss/render/default.py +++ b/floss/render/default.py @@ -1,29 +1,23 @@ # Copyright (C) 2022 Mandiant, Inc. All Rights Reserved. +import collections import io import sys import textwrap -import collections from typing import Dict, List, Tuple, Union from rich import box -from rich.table import Table -from rich.markup import escape from rich.console import Console +from rich.markup import escape +from rich.table import Table -import floss.utils as util -import floss.logging_ import floss.language.identify +import floss.logging_ +import floss.utils as util from floss.render import Verbosity -from floss.results import ( - AddressType, - StackString, - TightString, - DecodedString, - ResultDocument, - StringEncoding, -) from floss.render.sanitize import sanitize +from floss.results import (AddressType, DecodedString, ResultDocument, + StackString, StringEncoding, TightString) MIN_WIDTH_LEFT_COL = 22 MIN_WIDTH_RIGHT_COL = 82 diff --git a/floss/render/json.py b/floss/render/json.py index dff16e059..94298b25a 100644 --- a/floss/render/json.py +++ b/floss/render/json.py @@ -1,8 +1,8 @@ # Copyright (C) 2022 Mandiant, Inc. All Rights Reserved. -import json -import datetime import dataclasses +import datetime +import json from floss.results import ResultDocument diff --git a/floss/results.py b/floss/results.py index 2ed15298f..7be319cd0 100644 --- a/floss/results.py +++ b/floss/results.py @@ -1,15 +1,14 @@ # Copyright (C) 2021 Mandiant, Inc. All Rights Reserved. -import re -import json import datetime +import json +import re +from dataclasses import field from enum import Enum -from typing import Dict, List from pathlib import Path -from dataclasses import field +from typing import Dict, List from pydantic import TypeAdapter, ValidationError - # we use pydantic for dataclasses so that we can # easily load and validate JSON reports. # @@ -21,8 +20,8 @@ import floss.logging_ from floss.render import Verbosity -from floss.version import __version__ from floss.render.sanitize import sanitize +from floss.version import __version__ logger = floss.logging_.getLogger(__name__) diff --git a/floss/stackstrings.py b/floss/stackstrings.py index c113ba1e5..a23206b8f 100644 --- a/floss/stackstrings.py +++ b/floss/stackstrings.py @@ -1,19 +1,19 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. -from typing import Set, List, Optional from dataclasses import dataclass +from typing import List, Optional, Set +import envi.archs.amd64 +import envi.archs.i386 import tqdm import viv_utils -import envi.archs.i386 -import envi.archs.amd64 import viv_utils.emulator_drivers -import floss.utils import floss.strings -from floss.utils import getPointerSize, extract_strings +import floss.utils from floss.render import Verbosity from floss.results import StackString +from floss.utils import extract_strings, getPointerSize logger = floss.logging_.getLogger(__name__) MAX_STACK_SIZE = 0x10000 diff --git a/floss/string_decoder.py b/floss/string_decoder.py index 40f041a2b..cc0ad04fd 100644 --- a/floss/string_decoder.py +++ b/floss/string_decoder.py @@ -1,29 +1,26 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. -from typing import Set, List from dataclasses import dataclass +from typing import List, Set import tqdm import viv_utils from vivisect import VivWorkspace -import floss.utils +import floss.decoding_manager +import floss.logging_ import floss.results import floss.strings -import floss.logging_ -import floss.decoding_manager -from floss.const import ( - DS_MAX_INSN_COUNT, - DS_FUNCTION_CALLS_RARE, - DS_FUNCTION_CALLS_OFTEN, - DS_FUNCTION_MIN_DECODED_STRINGS, - DS_FUNCTION_SHORTCUT_THRESHOLD_VERY_OFTEN, -) -from floss.utils import is_all_zeros -from floss.render import Verbosity -from floss.results import AddressType, DecodedString +import floss.utils +from floss.const import (DS_FUNCTION_CALLS_OFTEN, DS_FUNCTION_CALLS_RARE, + DS_FUNCTION_MIN_DECODED_STRINGS, + DS_FUNCTION_SHORTCUT_THRESHOLD_VERY_OFTEN, + DS_MAX_INSN_COUNT) from floss.decoding_manager import Delta from floss.function_argument_getter import extract_decoding_contexts +from floss.render import Verbosity +from floss.results import AddressType, DecodedString +from floss.utils import is_all_zeros logger = floss.logging_.getLogger(__name__) diff --git a/floss/strings.py b/floss/strings.py index c2f5330ec..19e928ebd 100644 --- a/floss/strings.py +++ b/floss/strings.py @@ -1,8 +1,8 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. import re -from typing import Iterable from itertools import chain +from typing import Iterable from floss.results import StaticString, StringEncoding diff --git a/floss/tightstrings.py b/floss/tightstrings.py index a65a7983f..2c12d0746 100644 --- a/floss/tightstrings.py +++ b/floss/tightstrings.py @@ -1,20 +1,20 @@ # Copyright (C) 2021 Mandiant, Inc. All Rights Reserved. -from typing import Set, List, Tuple, Iterator, Optional +from typing import Iterator, List, Optional, Set, Tuple -import tqdm import envi.exc -import viv_utils +import tqdm import tqdm.contrib.logging +import viv_utils import viv_utils.emulator_drivers -import floss.utils import floss.features.features -from floss.const import TS_MAX_INSN_COUNT, DS_MAX_ADDRESS_REVISITS_EMULATION -from floss.utils import extract_strings +import floss.utils +from floss.const import DS_MAX_ADDRESS_REVISITS_EMULATION, TS_MAX_INSN_COUNT from floss.render import Verbosity from floss.results import TightString from floss.stackstrings import CallContext, StackstringContextMonitor +from floss.utils import extract_strings logger = floss.logging_.getLogger(__name__) diff --git a/floss/utils.py b/floss/utils.py index 30830b6b7..213644a97 100644 --- a/floss/utils.py +++ b/floss/utils.py @@ -9,25 +9,30 @@ import argparse import builtins import contextlib -from typing import Set, Tuple, Iterable, Optional -from pathlib import Path +import inspect +import logging +import mmap +import re +import time from collections import OrderedDict +from pathlib import Path +from typing import Iterable, Optional, Set, Tuple -import tqdm +import envi.archs import tabulate -import vivisect +import tqdm import viv_utils -import envi.archs import viv_utils.emulator_drivers +import vivisect from envi import Emulator -import floss.strings import floss.logging_ +import floss.strings -from .const import MEGABYTE, MOD_NAME, MAX_STRING_LENGTH +from .api_hooks import ENABLED_VIV_DEFAULT_HOOKS +from .const import MAX_STRING_LENGTH, MEGABYTE, MOD_NAME from .results import StaticString from .strings import extract_ascii_unicode_strings -from .api_hooks import ENABLED_VIV_DEFAULT_HOOKS STACK_MEM_NAME = "[stack]" diff --git a/scripts/idaplugin.py b/scripts/idaplugin.py index 76d09dc8d..80d8b6b67 100644 --- a/scripts/idaplugin.py +++ b/scripts/idaplugin.py @@ -8,24 +8,24 @@ author: Willi Ballenthin email: willi.ballenthin@gmail.com """ +import logging import os import time -import logging -from typing import List, Union from pathlib import Path +from typing import List, Union import idc import viv_utils import floss +import floss.identify import floss.main -import floss.utils import floss.render -import floss.identify import floss.stackstrings -import floss.tightstrings import floss.string_decoder -from floss.results import AddressType, StackString, TightString, DecodedString +import floss.tightstrings +import floss.utils +from floss.results import AddressType, DecodedString, StackString, TightString logger = logging.getLogger("floss.idaplugin") diff --git a/scripts/render-binja-import-script.py b/scripts/render-binja-import-script.py index 2c99f60e8..81d1ab706 100644 --- a/scripts/render-binja-import-script.py +++ b/scripts/render-binja-import-script.py @@ -21,10 +21,10 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import sys +import argparse import base64 import logging -import argparse +import sys from pathlib import Path from floss.results import AddressType, ResultDocument diff --git a/scripts/render-ghidra-import-script.py b/scripts/render-ghidra-import-script.py index 9410d6266..4e8229cbf 100644 --- a/scripts/render-ghidra-import-script.py +++ b/scripts/render-ghidra-import-script.py @@ -21,10 +21,10 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import sys +import argparse import base64 import logging -import argparse +import sys from pathlib import Path from floss.results import AddressType, ResultDocument diff --git a/scripts/render-ida-import-script.py b/scripts/render-ida-import-script.py index a6bfc8f8e..70d259009 100644 --- a/scripts/render-ida-import-script.py +++ b/scripts/render-ida-import-script.py @@ -20,10 +20,10 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import sys +import argparse import base64 import logging -import argparse +import sys from pathlib import Path from floss.results import AddressType, ResultDocument diff --git a/scripts/render-r2-import-script.py b/scripts/render-r2-import-script.py index 56682e9b2..0725529ce 100644 --- a/scripts/render-r2-import-script.py +++ b/scripts/render-r2-import-script.py @@ -21,10 +21,10 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import sys +import argparse import base64 import logging -import argparse +import sys from pathlib import Path from floss.results import AddressType, ResultDocument diff --git a/scripts/render-x64dbg-database.py b/scripts/render-x64dbg-database.py index f1e27fcbc..4dfc82553 100644 --- a/scripts/render-x64dbg-database.py +++ b/scripts/render-x64dbg-database.py @@ -20,14 +20,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import sys -import json -import logging import argparse import dataclasses -from typing import Dict, List -from pathlib import Path +import json +import logging +import sys from dataclasses import field +from pathlib import Path +from typing import Dict, List from pydantic.dataclasses import dataclass diff --git a/tests/conftest.py b/tests/conftest.py index 46a6e8b04..277b6d374 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,22 +3,19 @@ import os from pathlib import Path -import yaml import pytest import viv_utils +import yaml import floss.main as floss_main import floss.stackstrings as stackstrings -import floss.tightstrings as tightstrings import floss.string_decoder as string_decoder +import floss.tightstrings as tightstrings from floss.const import MIN_STRING_LENGTH -from floss.identify import ( - get_function_fvas, - get_top_functions, - get_functions_with_tightloops, - find_decoding_function_features, - get_functions_without_tightloops, -) +from floss.identify import (find_decoding_function_features, get_function_fvas, + get_functions_with_tightloops, + get_functions_without_tightloops, + get_top_functions) def extract_strings(vw): diff --git a/tests/test_cli_args.py b/tests/test_cli_args.py index 8f3317924..0a8fd41ce 100644 --- a/tests/test_cli_args.py +++ b/tests/test_cli_args.py @@ -1,7 +1,7 @@ # Copyright (C) 2021 Mandiant, Inc. All Rights Reserved. import pytest -from fixtures import scfile, exefile +from fixtures import exefile, scfile import floss.main diff --git a/tests/test_language_extract_go.py b/tests/test_language_extract_go.py index 41ad4eb77..6f5a161b9 100644 --- a/tests/test_language_extract_go.py +++ b/tests/test_language_extract_go.py @@ -2,8 +2,8 @@ import pytest -from floss.results import StaticString, StringEncoding from floss.language.go.extract import extract_go_strings +from floss.results import StaticString, StringEncoding @pytest.fixture(scope="module") diff --git a/tests/test_language_extract_rust.py b/tests/test_language_extract_rust.py index 3bb7546e1..d08b33447 100644 --- a/tests/test_language_extract_rust.py +++ b/tests/test_language_extract_rust.py @@ -2,8 +2,8 @@ import pytest -from floss.results import StaticString, StringEncoding from floss.language.rust.extract import extract_rust_strings +from floss.results import StaticString, StringEncoding @pytest.fixture(scope="module") diff --git a/tests/test_language_go_coverage.py b/tests/test_language_go_coverage.py index b746332b4..ea1885076 100644 --- a/tests/test_language_go_coverage.py +++ b/tests/test_language_go_coverage.py @@ -1,12 +1,12 @@ -import pathlib import contextlib +import pathlib import pefile import pytest -from floss.utils import get_static_strings -from floss.language.go.extract import extract_go_strings from floss.language.go.coverage import get_extract_stats +from floss.language.go.extract import extract_go_strings +from floss.utils import get_static_strings @pytest.mark.parametrize( diff --git a/tests/test_language_id.py b/tests/test_language_id.py index 321a2b295..cddd13853 100644 --- a/tests/test_language_id.py +++ b/tests/test_language_id.py @@ -2,12 +2,9 @@ import pytest +from floss.language.identify import (VERSION_UNKNOWN_OR_NA, Language, + identify_language_and_version) from floss.utils import get_static_strings -from floss.language.identify import ( - VERSION_UNKNOWN_OR_NA, - Language, - identify_language_and_version, -) @pytest.mark.parametrize( diff --git a/tests/test_language_rust_coverage.py b/tests/test_language_rust_coverage.py index f6cc25bba..ce31841c5 100644 --- a/tests/test_language_rust_coverage.py +++ b/tests/test_language_rust_coverage.py @@ -1,12 +1,12 @@ -import pathlib import contextlib +import pathlib import pefile import pytest -from floss.strings import extract_ascii_unicode_strings -from floss.language.utils import get_extract_stats from floss.language.rust.extract import extract_rust_strings +from floss.language.utils import get_extract_stats +from floss.strings import extract_ascii_unicode_strings @pytest.mark.parametrize( diff --git a/tests/test_main.py b/tests/test_main.py index 9cae69c2a..982acd648 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,7 +1,7 @@ # Copyright (C) 2020 Mandiant, Inc. All Rights Reserved. -import pytest import fixtures +import pytest from fixtures import exefile import floss.main diff --git a/tests/test_memdiff.py b/tests/test_memdiff.py index a86d1f59d..2f0e19db9 100644 --- a/tests/test_memdiff.py +++ b/tests/test_memdiff.py @@ -1,7 +1,7 @@ # Copyright (C) 2017 Mandiant, Inc. All Rights Reserved. -import pytest import envi.memory +import pytest from floss.string_decoder import memdiff diff --git a/tests/test_render.py b/tests/test_render.py index 6ae6612f1..28f825ea7 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -1,18 +1,9 @@ # Copyright (C) 2023 Mandiant, Inc. All Rights Reserved. -from floss.results import ( - Strings, - Analysis, - Metadata, - AddressType, - StackString, - TightString, - StaticString, - DecodedString, - ResultDocument, - StringEncoding, -) from floss.render.default import render +from floss.results import (AddressType, Analysis, DecodedString, Metadata, + ResultDocument, StackString, StaticString, + StringEncoding, Strings, TightString) def test_render_rich_markup(): diff --git a/tests/test_scripts.py b/tests/test_scripts.py index ee05f8fa1..d569216d9 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -6,10 +6,10 @@ # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and limitations under the License. -import sys import subprocess -from pathlib import Path +import sys from functools import lru_cache +from pathlib import Path import pytest