From 954ed3a40828a89aa9369d00cef8f731ba9f5ffd Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Wed, 9 Jun 2021 22:22:03 -0600 Subject: [PATCH] pep8 --- capa/features/extractors/ida/insn.py | 2 +- capa/features/extractors/smda/file.py | 2 +- capa/features/extractors/smda/insn.py | 2 +- capa/features/extractors/viv/file.py | 2 +- capa/features/extractors/viv/insn.py | 4 ++-- capa/ida/plugin/form.py | 8 +++++--- capa/ida/plugin/model.py | 2 +- capa/render/vverbose.py | 2 +- capa/rules.py | 2 +- scripts/show-capabilities-by-function.py | 2 +- tests/test_freeze.py | 4 ++-- tests/test_pefile_features.py | 5 ++--- tests/test_smda_features.py | 5 ++--- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/capa/features/extractors/ida/insn.py b/capa/features/extractors/ida/insn.py index bf8ad847..044e5923 100644 --- a/capa/features/extractors/ida/insn.py +++ b/capa/features/extractors/ida/insn.py @@ -12,6 +12,7 @@ import idautils import capa.features.extractors.helpers import capa.features.extractors.ida.helpers +from capa.features.insn import API, Number, Offset, Mnemonic from capa.features.common import ( ARCH_X32, ARCH_X64, @@ -21,7 +22,6 @@ from capa.features.common import ( String, Characteristic, ) -from capa.features.insn import API, Number, Offset, Mnemonic # 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/capa/features/extractors/smda/file.py b/capa/features/extractors/smda/file.py index cc9d5859..5250e26b 100644 --- a/capa/features/extractors/smda/file.py +++ b/capa/features/extractors/smda/file.py @@ -3,8 +3,8 @@ import lief import capa.features.extractors.helpers import capa.features.extractors.strings -from capa.features.common import String, Characteristic from capa.features.file import Export, Import, Section +from capa.features.common import String, Characteristic def extract_file_embedded_pe(smda_report, file_path): diff --git a/capa/features/extractors/smda/insn.py b/capa/features/extractors/smda/insn.py index 22c9c66e..eddc859d 100644 --- a/capa/features/extractors/smda/insn.py +++ b/capa/features/extractors/smda/insn.py @@ -5,6 +5,7 @@ import struct from smda.common.SmdaReport import SmdaReport import capa.features.extractors.helpers +from capa.features.insn import API, Number, Offset, Mnemonic from capa.features.common import ( ARCH_X32, ARCH_X64, @@ -14,7 +15,6 @@ from capa.features.common import ( String, Characteristic, ) -from capa.features.insn import API, Number, Offset, Mnemonic # 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/capa/features/extractors/viv/file.py b/capa/features/extractors/viv/file.py index 76426f63..8a0becce 100644 --- a/capa/features/extractors/viv/file.py +++ b/capa/features/extractors/viv/file.py @@ -13,8 +13,8 @@ import viv_utils.flirt import capa.features.insn import capa.features.extractors.helpers import capa.features.extractors.strings -from capa.features.common import String, Characteristic from capa.features.file import Export, Import, Section, FunctionName +from capa.features.common import String, Characteristic def extract_file_embedded_pe(vw, file_path): diff --git a/capa/features/extractors/viv/insn.py b/capa/features/extractors/viv/insn.py index 4061bc3c..9c563090 100644 --- a/capa/features/extractors/viv/insn.py +++ b/capa/features/extractors/viv/insn.py @@ -11,13 +11,14 @@ import viv_utils import envi.memory import viv_utils.flirt import envi.archs.i386.regs -import envi.archs.i386.disasm import envi.archs.amd64.regs +import envi.archs.i386.disasm import envi.archs.amd64.disasm import capa.features.extractors.viv import capa.features.extractors.helpers import capa.features.extractors.viv.helpers +from capa.features.insn import API, Number, Offset, Mnemonic from capa.features.common import ( ARCH_X32, ARCH_X64, @@ -27,7 +28,6 @@ from capa.features.common import ( String, Characteristic, ) -from capa.features.insn import API, Number, Offset, Mnemonic from capa.features.extractors.viv.indirect_calls import NotFoundError, resolve_indirect_call # security cookie checks may perform non-zeroing XORs, these are expected within a certain diff --git a/capa/ida/plugin/form.py b/capa/ida/plugin/form.py index ee73bbc2..215ec2d7 100644 --- a/capa/ida/plugin/form.py +++ b/capa/ida/plugin/form.py @@ -22,10 +22,10 @@ import capa.main import capa.rules import capa.engine import capa.ida.helpers -import capa.features.common -import capa.features.extractors.ida.extractor import capa.render.json +import capa.features.common import capa.render.result_document +import capa.features.extractors.ida.extractor from capa.ida.plugin.icon import QICON from capa.ida.plugin.view import ( CapaExplorerQtreeView, @@ -773,7 +773,9 @@ class CapaExplorerForm(idaapi.PluginForm): update_wait_box("rendering results") try: - self.doc = capa.render.result_document.convert_capabilities_to_result_document(meta, self.ruleset_cache, capabilities) + self.doc = capa.render.result_document.convert_capabilities_to_result_document( + meta, self.ruleset_cache, capabilities + ) except Exception as e: logger.error("Failed to render results (error: %s)", e) return False diff --git a/capa/ida/plugin/model.py b/capa/ida/plugin/model.py index 78f785c7..bd9b8430 100644 --- a/capa/ida/plugin/model.py +++ b/capa/ida/plugin/model.py @@ -14,8 +14,8 @@ from PyQt5 import QtGui, QtCore import capa.rules import capa.ida.helpers -import capa.features.common import capa.render.utils as rutils +import capa.features.common from capa.ida.plugin.item import ( CapaExplorerDataItem, CapaExplorerRuleItem, diff --git a/capa/render/vverbose.py b/capa/render/vverbose.py index aa04495d..683945b2 100644 --- a/capa/render/vverbose.py +++ b/capa/render/vverbose.py @@ -11,8 +11,8 @@ import tabulate import capa.rules import capa.render.utils as rutils import capa.render.verbose -import capa.render.result_document import capa.features.common +import capa.render.result_document def render_locations(ostream, match): diff --git a/capa/rules.py b/capa/rules.py index ab6dca93..184c046e 100644 --- a/capa/rules.py +++ b/capa/rules.py @@ -26,12 +26,12 @@ import ruamel.yaml import capa.rules import capa.engine +import capa.engine as ceng import capa.features import capa.features.file import capa.features.insn import capa.features.common import capa.features.basicblock -import capa.engine as ceng from capa.features.common import MAX_BYTES_FEATURE_SIZE logger = logging.getLogger(__name__) diff --git a/scripts/show-capabilities-by-function.py b/scripts/show-capabilities-by-function.py index 60b328b0..ad0af057 100644 --- a/scripts/show-capabilities-by-function.py +++ b/scripts/show-capabilities-by-function.py @@ -61,8 +61,8 @@ import capa.rules import capa.engine import capa.features import capa.render.utils as rutils -import capa.render.result_document import capa.features.freeze +import capa.render.result_document from capa.helpers import get_file_taste logger = logging.getLogger("capa.show-capabilities-by-function") diff --git a/tests/test_freeze.py b/tests/test_freeze.py index f65b35da..0b3ba949 100644 --- a/tests/test_freeze.py +++ b/tests/test_freeze.py @@ -12,10 +12,10 @@ from fixtures import * import capa.main import capa.rules import capa.helpers -import capa.features.insn import capa.features.file -import capa.features.freeze +import capa.features.insn import capa.features.common +import capa.features.freeze import capa.features.basicblock import capa.features.extractors.base_extractor diff --git a/tests/test_pefile_features.py b/tests/test_pefile_features.py index 7d8e4a90..8bb46d43 100644 --- a/tests/test_pefile_features.py +++ b/tests/test_pefile_features.py @@ -6,13 +6,12 @@ # 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 pytest - -import capa.features.file - import fixtures from fixtures import * from fixtures import parametrize +import capa.features.file + @parametrize( "sample,scope,feature,expected", diff --git a/tests/test_smda_features.py b/tests/test_smda_features.py index 24440f06..6614c24d 100644 --- a/tests/test_smda_features.py +++ b/tests/test_smda_features.py @@ -6,13 +6,12 @@ # 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 pytest - -import capa.features.file - import fixtures from fixtures import * from fixtures import parametrize +import capa.features.file + @parametrize( "sample,scope,feature,expected",