mirror of
https://github.com/mandiant/capa.git
synced 2026-06-12 11:01:31 -07:00
Merge pull request #3090 from corkamig/rva_deprecation
RelativeVirtualAddress deprecation
This commit is contained in:
@@ -146,6 +146,8 @@ This release includes Ghidra PyGhidra support, performance improvements, depende
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- deprecate RelativeVirtualAddress @corkamig #3072
|
||||
|
||||
### New Rules (26)
|
||||
|
||||
- nursery/run-as-nodejs-native-module mehunhoff@google.com
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import abc
|
||||
import warnings
|
||||
|
||||
|
||||
class Address(abc.ABC):
|
||||
@@ -131,6 +132,12 @@ class DynamicCallAddress(Address):
|
||||
class RelativeVirtualAddress(int, Address):
|
||||
"""a memory address relative to a base address"""
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
# TODO(corkamig): Removal for v10
|
||||
# https://github.com/mandiant/capa/issues/3072
|
||||
warnings.warn("RelativeVirtualAddress is deprecated - cf issue #3072", DeprecationWarning, stacklevel=2)
|
||||
return super().__new__(cls, *args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return f"relative(0x{self:x})"
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ from capa.features.address import (
|
||||
DynamicCallAddress,
|
||||
DNTokenOffsetAddress,
|
||||
AbsoluteVirtualAddress,
|
||||
RelativeVirtualAddress,
|
||||
)
|
||||
|
||||
ADDR1 = capa.features.address.AbsoluteVirtualAddress(0x401001)
|
||||
@@ -55,6 +56,11 @@ def test_no_address_hash():
|
||||
assert d[addr_zero] == "zero"
|
||||
|
||||
|
||||
def test_relative_address():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
_ = RelativeVirtualAddress(0)
|
||||
|
||||
|
||||
def test_dn_token_offset_address_cross_type_eq():
|
||||
addr = DNTokenOffsetAddress(0x1000, 0x10)
|
||||
assert (addr == AbsoluteVirtualAddress(0x1010)) is False
|
||||
|
||||
Reference in New Issue
Block a user