move capa/features/__init__.py logic to common.py

also cleanup imports across the board,
thanks to pylance.
This commit is contained in:
William Ballenthin
2021-06-09 22:20:53 -06:00
parent 7029ad32c4
commit ac59e50b5f
46 changed files with 551 additions and 529 deletions

View File

@@ -12,10 +12,10 @@ import pytest
import capa.rules
import capa.engine
import capa.features
from capa.features import ARCH_X32, ARCH_X64, String
import capa.features.common
from capa.features.file import FunctionName
from capa.features.insn import Number, Offset
from capa.features.common import ARCH_X32, ARCH_X64, String
def test_rule_ctor():
@@ -752,17 +752,17 @@ def test_regex_values_always_string():
]
features, matches = capa.engine.match(
capa.engine.topologically_order_rules(rules),
{capa.features.String("123"): {1}},
{capa.features.common.String("123"): {1}},
0x0,
)
assert capa.features.MatchedRule("test rule") in features
assert capa.features.comm.MatchedRule("test rule") in features
features, matches = capa.engine.match(
capa.engine.topologically_order_rules(rules),
{capa.features.String("0x123"): {1}},
{capa.features.common.String("0x123"): {1}},
0x0,
)
assert capa.features.MatchedRule("test rule") in features
assert capa.features.common.MatchedRule("test rule") in features
def test_filter_rules():