mirror of
https://github.com/mandiant/capa.git
synced 2026-04-28 11:53:20 -07:00
style: ruff format changed files
This commit is contained in:
committed by
Willi Ballenthin
parent
a834c4c0a7
commit
e745fa6aab
Submodule tests/data updated: f41a1998b9...413fd2803e
@@ -17,7 +17,13 @@ import pytest
|
||||
import capa.features.address
|
||||
from capa.engine import Or, And, Not, Some, Range
|
||||
from capa.features.insn import Number
|
||||
from capa.features.address import ThreadAddress, ProcessAddress, DynamicCallAddress, DNTokenOffsetAddress, AbsoluteVirtualAddress
|
||||
from capa.features.address import (
|
||||
ThreadAddress,
|
||||
ProcessAddress,
|
||||
DynamicCallAddress,
|
||||
DNTokenOffsetAddress,
|
||||
AbsoluteVirtualAddress,
|
||||
)
|
||||
|
||||
ADDR1 = capa.features.address.AbsoluteVirtualAddress(0x401001)
|
||||
ADDR2 = capa.features.address.AbsoluteVirtualAddress(0x401002)
|
||||
@@ -138,7 +144,10 @@ def test_some():
|
||||
|
||||
def test_complex():
|
||||
assert True is bool(
|
||||
Or([And([Number(1), Number(2)]), Or([Number(3), Some(2, [Number(4), Number(5), Number(6)])])]).evaluate({
|
||||
Or([
|
||||
And([Number(1), Number(2)]),
|
||||
Or([Number(3), Some(2, [Number(4), Number(5), Number(6)])]),
|
||||
]).evaluate({
|
||||
Number(5): {ADDR1},
|
||||
Number(6): {ADDR1},
|
||||
Number(7): {ADDR1},
|
||||
@@ -147,7 +156,10 @@ def test_complex():
|
||||
)
|
||||
|
||||
assert False is bool(
|
||||
Or([And([Number(1), Number(2)]), Or([Number(3), Some(2, [Number(4), Number(5)])])]).evaluate({
|
||||
Or([
|
||||
And([Number(1), Number(2)]),
|
||||
Or([Number(3), Some(2, [Number(4), Number(5)])]),
|
||||
]).evaluate({
|
||||
Number(5): {ADDR1},
|
||||
Number(6): {ADDR1},
|
||||
Number(7): {ADDR1},
|
||||
|
||||
@@ -29,7 +29,11 @@ import capa.features.extractors.null
|
||||
import capa.features.freeze.features
|
||||
import capa.features.extractors.base_extractor
|
||||
from capa.features.address import Address, AbsoluteVirtualAddress
|
||||
from capa.features.extractors.base_extractor import BBHandle, SampleHashes, FunctionHandle
|
||||
from capa.features.extractors.base_extractor import (
|
||||
BBHandle,
|
||||
SampleHashes,
|
||||
FunctionHandle,
|
||||
)
|
||||
|
||||
EXTRACTOR = capa.features.extractors.null.NullStaticFeatureExtractor(
|
||||
base_address=AbsoluteVirtualAddress(0x401000),
|
||||
@@ -40,28 +44,46 @@ EXTRACTOR = capa.features.extractors.null.NullStaticFeatureExtractor(
|
||||
),
|
||||
global_features=[],
|
||||
file_features=[
|
||||
(AbsoluteVirtualAddress(0x402345), capa.features.common.Characteristic("embedded pe")),
|
||||
(
|
||||
AbsoluteVirtualAddress(0x402345),
|
||||
capa.features.common.Characteristic("embedded pe"),
|
||||
),
|
||||
],
|
||||
functions={
|
||||
AbsoluteVirtualAddress(0x401000): capa.features.extractors.null.FunctionFeatures(
|
||||
features=[
|
||||
(AbsoluteVirtualAddress(0x401000), capa.features.common.Characteristic("indirect call")),
|
||||
(
|
||||
AbsoluteVirtualAddress(0x401000),
|
||||
capa.features.common.Characteristic("indirect call"),
|
||||
),
|
||||
],
|
||||
basic_blocks={
|
||||
AbsoluteVirtualAddress(0x401000): capa.features.extractors.null.BasicBlockFeatures(
|
||||
features=[
|
||||
(AbsoluteVirtualAddress(0x401000), capa.features.common.Characteristic("tight loop")),
|
||||
(
|
||||
AbsoluteVirtualAddress(0x401000),
|
||||
capa.features.common.Characteristic("tight loop"),
|
||||
),
|
||||
],
|
||||
instructions={
|
||||
AbsoluteVirtualAddress(0x401000): capa.features.extractors.null.InstructionFeatures(
|
||||
features=[
|
||||
(AbsoluteVirtualAddress(0x401000), capa.features.insn.Mnemonic("xor")),
|
||||
(AbsoluteVirtualAddress(0x401000), capa.features.common.Characteristic("nzxor")),
|
||||
(
|
||||
AbsoluteVirtualAddress(0x401000),
|
||||
capa.features.insn.Mnemonic("xor"),
|
||||
),
|
||||
(
|
||||
AbsoluteVirtualAddress(0x401000),
|
||||
capa.features.common.Characteristic("nzxor"),
|
||||
),
|
||||
],
|
||||
),
|
||||
AbsoluteVirtualAddress(0x401002): capa.features.extractors.null.InstructionFeatures(
|
||||
features=[
|
||||
(AbsoluteVirtualAddress(0x401002), capa.features.insn.Mnemonic("mov")),
|
||||
(
|
||||
AbsoluteVirtualAddress(0x401002),
|
||||
capa.features.insn.Mnemonic("mov"),
|
||||
),
|
||||
],
|
||||
),
|
||||
},
|
||||
|
||||
@@ -44,7 +44,12 @@ def test_render_offset():
|
||||
|
||||
def test_render_property():
|
||||
assert (
|
||||
str(capa.features.insn.Property("System.IO.FileInfo::Length", access=capa.features.common.FeatureAccess.READ))
|
||||
str(
|
||||
capa.features.insn.Property(
|
||||
"System.IO.FileInfo::Length",
|
||||
access=capa.features.common.FeatureAccess.READ,
|
||||
)
|
||||
)
|
||||
== "property/read(System.IO.FileInfo::Length)"
|
||||
)
|
||||
|
||||
@@ -184,7 +189,10 @@ def test_render_meta_maec():
|
||||
(capa.features.common.Regex("^foo"), "regex: ^foo"),
|
||||
(capa.features.common.String("foo"), 'string: "foo" @ 0x401000'),
|
||||
(capa.features.common.Class("BeanFactory"), "class: BeanFactory @ 0x401000"),
|
||||
(capa.features.common.Namespace("std::enterprise"), "namespace: std::enterprise @ 0x401000"),
|
||||
(
|
||||
capa.features.common.Namespace("std::enterprise"),
|
||||
"namespace: std::enterprise @ 0x401000",
|
||||
),
|
||||
(capa.features.insn.API("CreateFileW"), "api: CreateFileW @ 0x401000"),
|
||||
(capa.features.insn.Property("foo"), "property: foo @ 0x401000"),
|
||||
(capa.features.insn.Property("foo", "read"), "property/read: foo @ 0x401000"),
|
||||
|
||||
Reference in New Issue
Block a user