From f2ac496e22d97a6092aeb74b61e14cd82780431d Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Wed, 30 Dec 2020 17:48:07 +0000 Subject: [PATCH] Core: Implement the ability to cache from the CLI --- volatility/__init__.py | 2 ++ volatility/cli/__init__.py | 6 ++++++ volatility/framework/caching.py | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 volatility/framework/caching.py diff --git a/volatility/__init__.py b/volatility/__init__.py index f766a4ba2..ebdde4d27 100644 --- a/volatility/__init__.py +++ b/volatility/__init__.py @@ -10,6 +10,8 @@ from typing import List, TypeVar, Callable, Any, Optional _T = TypeVar("_T") _S = TypeVar("_S") +CACHING = True + class classproperty(property): """Class property decorator. diff --git a/volatility/cli/__init__.py b/volatility/cli/__init__.py index 3e680aa26..92fce87cd 100644 --- a/volatility/cli/__init__.py +++ b/volatility/cli/__init__.py @@ -22,6 +22,11 @@ import traceback from typing import Dict, Type, Union, Any from urllib import parse, request +import volatility + +if "--live" in sys.argv: + volatility.CACHING = False + import volatility.plugins import volatility.symbols from volatility import framework @@ -134,6 +139,7 @@ class CommandLine: help = "Log output to a file as well as the console", default = None, type = str) + parser.add_argument("--live", help = "Disable caching of layer reads", action = 'store_true') parser.add_argument("-o", "--output-dir", help = "Directory in which to output any generated files", diff --git a/volatility/framework/caching.py b/volatility/framework/caching.py new file mode 100644 index 000000000..39ed3c3ef --- /dev/null +++ b/volatility/framework/caching.py @@ -0,0 +1,9 @@ +import functools +import volatility + + +def lru_cache(*args, **kwargs): + if not volatility.CACHING: + return lambda x: x + raise Exception + return functools.lru_cache(*args, **kwargs)