RelativeVirtualAddress deprecation warning

This commit is contained in:
Ange Albertini
2026-05-28 13:09:53 +00:00
parent 3eada453e5
commit 61c24ebcbb
2 changed files with 19 additions and 0 deletions
+9
View File
@@ -13,6 +13,7 @@
# limitations under the License.
import abc
import warnings
class Address(abc.ABC):
@@ -131,6 +132,14 @@ class DynamicCallAddress(Address):
class RelativeVirtualAddress(int, Address):
"""a memory address relative to a base address"""
def __new__(cls, *args, **kwargs):
warnings.warn(
"RelativeVirtualAddress is deprecated",
DeprecationWarning,
stacklevel=2
)
return super().__new__(cls, *args, **kwargs)
def __repr__(self):
return f"relative(0x{self:x})"
+10
View File
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import warnings
import pytest
import capa.features.address
@@ -23,6 +25,7 @@ from capa.features.address import (
DynamicCallAddress,
DNTokenOffsetAddress,
AbsoluteVirtualAddress,
RelativeVirtualAddress,
)
ADDR1 = capa.features.address.AbsoluteVirtualAddress(0x401001)
@@ -55,6 +58,13 @@ def test_no_address_hash():
assert d[addr_zero] == "zero"
def test_relative_address():
with pytest.raises(DeprecationWarning):
warnings.filterwarnings("error", category=DeprecationWarning)
_ = RelativeVirtualAddress(0)
warnings.resetwarnings()
def test_dn_token_offset_address_cross_type_eq():
addr = DNTokenOffsetAddress(0x1000, 0x10)
assert (addr == AbsoluteVirtualAddress(0x1010)) is False