-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge two Linux APIs for mapping kernel modules to pointers. Fix bugs… #1673
Open
atcuno
wants to merge
9
commits into
develop
Choose a base branch
from
linux_kernel_api_overhaul
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bdc3443
Merge two Linux APIs for mapping kernel modules to pointers. Fix bugs…
atcuno 2ead4d3
update for black
atcuno 636bb10
Update volatility3/framework/plugins/linux/hidden_modules.py
atcuno 00678fb
Update volatility3/framework/plugins/linux/hidden_modules.py
ikelos 6a32aa4
Deprecation API updates
atcuno b68b4f3
Bring back change after merge conflict
atcuno 4a87bf5
Add new deprecation module
atcuno 6cabb05
Add removal_date to deprecation API
atcuno 3eae04c
Add removal_date to deprecation API
atcuno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# This file is Copyright 2025 Volatility Foundation and licensed under the Volatility Software License 1.0 | ||
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0 | ||
# | ||
|
||
# This file contains the Deprecation class used to deprecate methods in an orderly manner | ||
|
||
import warnings | ||
import functools | ||
import inspect | ||
|
||
from typing import Callable, Tuple | ||
|
||
from volatility3.framework import interfaces, exceptions | ||
from volatility3.framework.configuration import requirements | ||
|
||
|
||
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 the first release after {removal_date}. {message}", | ||
FutureWarning, | ||
) | ||
return deprecated_func(*args, **kwargs) | ||
|
||
return wrapper | ||
|
||
return decorator | ||
|
||
|
||
def deprecated_method( | ||
replacement: Callable, | ||
removal_date: str, | ||
replacement_version: Tuple[int, int, int] = None, | ||
additional_information: str = "", | ||
): | ||
"""A decorator for marking functions as deprecated. | ||
|
||
Args: | ||
replacement: The replacement function overriding the deprecated API, in the form of a Callable (typically a method) | ||
replacement_version: The "replacement" base class version that the deprecated method expects before proxying to it. This implies that "replacement" is a method from a class that inherits from VersionableInterface. | ||
additional_information: Information appended at the end of the deprecation message | ||
""" | ||
|
||
def decorator(deprecated_func): | ||
@functools.wraps(deprecated_func) | ||
def wrapper(*args, **kwargs): | ||
nonlocal replacement, replacement_version, additional_information | ||
# Prevent version mismatches between deprecated (proxy) methods and the ones they proxy | ||
if ( | ||
replacement_version is not None | ||
and callable(replacement) | ||
and hasattr(replacement, "__self__") | ||
): | ||
replacement_base_class = replacement.__self__ | ||
|
||
# Verify that the base class inherits from VersionableInterface | ||
if inspect.isclass(replacement_base_class) and issubclass( | ||
replacement_base_class, | ||
interfaces.configuration.VersionableInterface, | ||
): | ||
# SemVer check | ||
if not requirements.VersionRequirement.matches_required( | ||
replacement_version, replacement_base_class.version | ||
): | ||
raise exceptions.VersionMismatchException( | ||
deprecated_func, | ||
replacement_base_class, | ||
replacement_version, | ||
"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 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) | ||
|
||
return wrapper | ||
|
||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance of a docstring for this please?