Skip to content

Commit

Permalink
python: move VMIHandler into it's own package
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzel committed Mar 22, 2021
1 parent d6feb3c commit 41850ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 8 additions & 0 deletions python/microvmi/volatility/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
This package regroups the volatility plugins developed on top of the Microvmi package
It is intended to be used as a volatility3 plugins directory:
Example:
vol.py -p /path/to/microvmi/volatility windows.pslist.PsList
"""
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Any, List, Optional, Tuple, Type
from typing import Any, List, Optional, Tuple
from urllib.parse import parse_qs, urlparse
from urllib.request import BaseHandler, Request

Expand All @@ -8,22 +8,23 @@
# to be used by volatility, the VMIHandler should inherit from VolatilityHandler
# in order to be non cacheable
# if we find volatility, use VolatilityHandler, otherwise use the BaseHandler from stdlib
HANDLER_BASE_CLASS: Type[BaseHandler] = BaseHandler
try:
from volatility3.framework.layers.handler import VolatilityHandler

HANDLER_BASE_CLASS = VolatilityHandler
from volatility3.framework.layers.resources import VolatilityHandler
except ImportError:
pass
# define dummy class
# mypy checking: ignore name already defined
class VolatilityHandler(BaseHandler): # type: ignore
pass


micro: Optional[Microvmi] = None


class MicrovmiHandlerError(Exception):
pass

# Note: mypy: dynamic base classes are not handled
class VMIHandler(HANDLER_BASE_CLASS): # type: ignore

class VMIHandler(VolatilityHandler):
"""
Handles the Virtual Machine Introspection URL scheme based on libmicrovmi
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from microvmi import DriverType
from microvmi.handler import MicrovmiHandlerError, url_to_driver_parameters
from microvmi.volatility.vmi_handler import MicrovmiHandlerError, url_to_driver_parameters


def test_valid_scheme():
Expand Down

0 comments on commit 41850ec

Please sign in to comment.