Add removal_date to deprecation API

This commit is contained in:
Andrew Case
2025-03-09 22:23:33 -05:00
committed by David McDonald
parent 4a87bf506a
commit 6cabb0586b
7 changed files with 22 additions and 9 deletions
+5 -5
View File
@@ -14,13 +14,12 @@ from volatility3.framework import interfaces, exceptions
from volatility3.framework.configuration import requirements
def method_being_removed(message: str):
def method_being_removed(message: str, removal_date: str):
def decorator(deprecated_func):
@functools.wraps(deprecated_func)
def wrapper(*args, **kwargs):
warnings.warn(
f"This API ({deprecated_func.__module__}.{deprecated_func.__qualname__}) will be removed in a release very soon. {message}",
f"This API ({deprecated_func.__module__}.{deprecated_func.__qualname__}) will be removed in the first release after {removal_date}. {message}",
FutureWarning,
)
return deprecated_func(*args, **kwargs)
@@ -32,8 +31,9 @@ def method_being_removed(message: str):
def deprecated_method(
replacement: Callable,
removal_date: str,
replacement_version: Tuple[int, int, int] = None,
additional_information: str = "",
additional_information: str = ""
):
"""A decorator for marking functions as deprecated.
@@ -71,7 +71,7 @@ def deprecated_method(
"This is a bug, the deprecated call needs to be removed and the caller needs to update their code to use the new method.",
)
deprecation_msg = f"Method \"{deprecated_func.__module__ + '.' + deprecated_func.__qualname__}\" is deprecated, use \"{replacement.__module__ + '.' + replacement.__qualname__}\" instead. {additional_information}"
deprecation_msg = f"Method \"{deprecated_func.__module__ + '.' + deprecated_func.__qualname__}\" is deprecated and will be removed in the first release after {removal_date}, use \"{replacement.__module__ + '.' + replacement.__qualname__}\" instead. {additional_information}"
warnings.warn(deprecation_msg, FutureWarning)
# Return the wrapped function with its original arguments
return deprecated_func(*args, **kwargs)
@@ -40,6 +40,7 @@ class Check_modules(plugins.PluginInterface):
@classmethod
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.get_kset_modules,
removal_date="2025-09-25",
replacement_version=(2, 0, 0),
)
def get_kset_modules(
@@ -42,6 +42,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface):
@staticmethod
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.get_modules_memory_boundaries,
removal_date="2025-09-25",
replacement_version=(2, 0, 0),
)
def get_modules_memory_boundaries(
@@ -54,6 +55,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface):
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.get_module_address_alignment,
removal_date="2025-09-25",
replacement_version=(2, 0, 0),
)
@classmethod
@@ -81,6 +83,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface):
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.get_hidden_modules,
removal_date="2025-09-25",
replacement_version=(2, 0, 0),
)
@classmethod
@@ -120,6 +123,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface):
@staticmethod
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.validate_alignment_patterns,
removal_date="2025-09-25",
replacement_version=(2, 0, 0),
)
def _validate_alignment_patterns(
@@ -41,6 +41,7 @@ class Lsmod(plugins.PluginInterface):
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.list_modules,
replacement_version=(2, 0, 0),
removal_date="2025-09-25"
)
def list_modules(
cls, context: interfaces.context.ContextInterface, vmlinux_module_name: str
@@ -51,6 +51,7 @@ spot modules presence and taints."""
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.flatten_run_modules_results,
replacement_version=(2, 0, 0),
removal_date="2025-09-25"
)
def flatten_run_modules_results(
cls, run_results: Dict[str, List[extensions.module]], deduplicate: bool = True
@@ -73,6 +74,7 @@ spot modules presence and taints."""
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.run_modules_scanners,
replacement_version=(2, 0, 0),
removal_date="2025-09-25"
)
def run_modules_scanners(
cls,
@@ -369,7 +369,8 @@ class LinuxUtilities(interfaces.configuration.VersionableInterface):
@classmethod
@deprecation.method_being_removed(
"Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`"
removal_date="2025-09-25",
message="Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`"
)
def mask_mods_list(
cls,
@@ -386,7 +387,8 @@ class LinuxUtilities(interfaces.configuration.VersionableInterface):
@classmethod
@deprecation.method_being_removed(
"Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`"
removal_date="2025-09-25",
message="Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`"
)
def generate_kernel_handler_info(
cls,
@@ -419,6 +421,7 @@ class LinuxUtilities(interfaces.configuration.VersionableInterface):
@classmethod
@deprecation.deprecated_method(
replacement=linux_utilities_modules.Modules.lookup_module_address,
removal_date="2025-09-25",
replacement_version=(2, 0, 0),
)
def lookup_module_address(
@@ -104,7 +104,8 @@ class Modules(interfaces.configuration.VersionableInterface):
@classmethod
@deprecation.method_being_removed(
"Code using this function should adapt `linux_utilities_modules.Modules.run_module_scanners`"
removal_date="2025-09-25",
message="Code using this function should adapt `linux_utilities_modules.Modules.run_module_scanners`"
)
def mask_mods_list(
cls,
@@ -128,7 +129,8 @@ class Modules(interfaces.configuration.VersionableInterface):
@classmethod
@deprecation.method_being_removed(
"Use `module_lookup_by_address` to map address to their hosting kernel module and symbol."
removal_date="2025-09-25",
message="Use `module_lookup_by_address` to map address to their hosting kernel module and symbol."
)
def lookup_module_address(
cls,