fix codestyle issues

This commit is contained in:
Yacine Elhamer
2023-06-19 16:59:27 +01:00
parent 9458e851c0
commit 98e7acddf4
2 changed files with 15 additions and 8 deletions

View File

@@ -41,7 +41,7 @@ from capa.features.common import (
FeatureAccess,
)
from capa.features.address import Address
from capa.features.extractors.base_extractor import BBHandle, InsnHandle, FunctionHandle, ProcessHandle, ThreadHandle
from capa.features.extractors.base_extractor import BBHandle, InsnHandle, ThreadHandle, ProcessHandle, FunctionHandle
from capa.features.extractors.dnfile.extractor import DnfileFeatureExtractor
CD = os.path.dirname(__file__)
@@ -185,16 +185,18 @@ def get_binja_extractor(path):
@lru_cache(maxsize=1)
def get_cape_extractor(path):
from capa.features.extractors.cape.extractor import CapeExtractor
import json
from capa.features.extractors.cape.extractor import CapeExtractor
with open(path) as report_file:
report = report_file.read()
report = json.loads(report)
extractor = CapeExtractor.from_report(report)
return extractor
def extract_global_features(extractor):
features = collections.defaultdict(set)
for feature, va in extractor.extract_global_features():
@@ -616,8 +618,8 @@ DYNAMIC_FEATURE_PRESENCE_TESTS = sorted(
("", "process=(),thread=", capa.features.insn.API(""), True),
("", "process=(),thread=", capa.features.insn.API(""), False),
# thread/number call argument
("", "process=(),thread=", capa.features.insn.Number(""), True),
("", "process=(),thread=", capa.features.insn.Number(""), False),
("", "process=(),thread=", capa.features.insn.Number(), True),
("", "process=(),thread=", capa.features.insn.Number(), False),
# thread/string call argument
("", "process=(),thread=", capa.features.common.String(""), True),
("", "process=(),thread=", capa.features.common.String(""), False),
@@ -630,7 +632,11 @@ DYNAMIC_FEATURE_PRESENCE_TESTS = sorted(
DYNAMIC_FEATURE_COUNT_PRESENCE_TESTS = sorted(
[
# file/string
("", "file", capa.features.common.String(""), ),
(
"",
"file",
capa.features.common.String(""),
),
("", "file", capa.features.common.String("makansh menah"), 0),
# file/sections
("", "file", capa.features.file.Section(""), 1),
@@ -648,8 +654,8 @@ DYNAMIC_FEATURE_COUNT_PRESENCE_TESTS = sorted(
("", "process=(),thread=", capa.features.insn.API(""), 1),
("", "process=(),thread=", capa.features.insn.API(""), 0),
# thread/number call argument
("", "process=(),thread=", capa.features.insn.Number(""), 1),
("", "process=(),thread=", capa.features.insn.Number(""), 0),
("", "process=(),thread=", capa.features.insn.Number(), 1),
("", "process=(),thread=", capa.features.insn.Number(), 0),
# thread/string call argument
("", "process=(),thread=", capa.features.common.String(""), 1),
("", "process=(),thread=", capa.features.common.String(""), 0),

View File

@@ -8,6 +8,7 @@
import fixtures
from fixtures import *
@fixtures.parametrize(
"sample,scope,feature,expected",
fixtures.DYNAMIC_FEATURE_PRESENCE_TESTS,