Skip to content

Commit 72d928f

Browse files
authored
Merge pull request #819 from volatilityfoundation/feature/cache-path-fix
Core: Allow for deprecation of constants gracefully
2 parents 7f24c4d + 7529c7b commit 72d928f

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

volatility3/framework/automagic/linux.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
import logging
6+
import os
67
from typing import Optional, Tuple, Type
78

89
from volatility3.framework import constants, interfaces
@@ -40,7 +41,8 @@ def stack(cls,
4041
if isinstance(layer, intel.Intel):
4142
return None
4243

43-
linux_banners = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH).get_identifier_dictionary(
44+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
45+
linux_banners = symbol_cache.SqliteCache(identifiers_path).get_identifier_dictionary(
4446
operating_system = 'linux')
4547
# If we have no banners, don't bother scanning
4648
if not linux_banners:

volatility3/framework/automagic/mac.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
import logging
6+
import os
67
import struct
78
from typing import Optional
89

@@ -42,7 +43,8 @@ def stack(cls,
4243
if isinstance(layer, intel.Intel):
4344
return None
4445

45-
mac_banners = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH).get_identifier_dictionary(
46+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
47+
mac_banners = symbol_cache.SqliteCache(identifiers_path).get_identifier_dictionary(
4648
operating_system = 'mac')
4749
# If we have no banners, don't bother scanning
4850
if not mac_banners:

volatility3/framework/automagic/symbol_cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ class SymbolCacheMagic(interfaces.automagic.AutomagicInterface):
388388

389389
def __init__(self, *args, **kwargs):
390390
super().__init__(*args, **kwargs)
391-
self._cache = SqliteCache(constants.IDENTIFIERS_PATH)
391+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
392+
self._cache = SqliteCache(identifiers_path)
392393

393394
def __call__(self, context, config_path, configurable, progress_callback = None):
394395
"""Runs the automagic over the configurable."""

volatility3/framework/automagic/symbol_finder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
import logging
6+
import os
67
from typing import Any, Callable, Iterable, List, Optional, Tuple
78

89
from volatility3.framework import constants, interfaces, layers
@@ -40,7 +41,8 @@ def banners(self) -> symbol_cache.BannersType:
4041
"""Creates a cached copy of the results, but only it's been
4142
requested."""
4243
if not self._banners:
43-
cache = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH)
44+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
45+
cache = symbol_cache.SqliteCache(identifiers_path)
4446
self._banners = cache.get_identifier_dictionary(operating_system = self.operating_system)
4547
return self._banners
4648

volatility3/framework/constants/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@
6767
CACHE_PATH = os.path.realpath(os.path.join(os.environ.get("APPDATA", os.path.expanduser("~")), "volatility3"))
6868
os.makedirs(CACHE_PATH, exist_ok = True)
6969

70-
LINUX_BANNERS_PATH = os.path.join(CACHE_PATH, "linux_banners.cache")
71-
"""Default location to record information about available linux banners"""
72-
73-
MAC_BANNERS_PATH = os.path.join(CACHE_PATH, "mac_banners.cache")
74-
"""Default location to record information about available mac banners"""
75-
76-
IDENTIFIERS_PATH = os.path.join(CACHE_PATH, "identifiers.cache")
70+
IDENTIFIERS_FILENAME = "identifier.cache"
7771
"""Default location to record information about available identifiers"""
7872

7973
CACHE_SQLITE_SCHEMA_VERSION = 1

volatility3/framework/plugins/isfinfo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def check_valid(data):
109109
num_enums = len(data.get('enums', []))
110110
num_bases = len(data.get('base_types', []))
111111

112-
identifier_cache = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH)
112+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
113+
identifier_cache = symbol_cache.SqliteCache(identifiers_path)
113114
identifier = identifier_cache.get_identifier(location = entry)
114115
if identifier:
115116
identifier = identifier.decode('utf-8', errors = 'replace')
@@ -120,7 +121,8 @@ def check_valid(data):
120121
vollog.warning(f"Invalid ISF: {entry}")
121122
yield (0, (entry, valid, num_bases, num_types, num_symbols, num_enums, identifier))
122123
else:
123-
cache = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH)
124+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
125+
cache = symbol_cache.SqliteCache(identifiers_path)
124126
valid = 'Unknown'
125127
for identifier, location in cache.get_identifier_dictionary().items():
126128
num_bases, num_types, num_enums, num_symbols = cache.get_location_statistics(location)

volatility3/framework/symbols/windows/pdbutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def load_windows_symbol_table(cls,
8080
vollog.debug(f"Required version of SQLiteCache not found")
8181
return None
8282

83-
value = symbol_cache.SqliteCache(constants.IDENTIFIERS_PATH).find_location(
83+
identifiers_path = os.path.join(constants.CACHE_PATH, constants.IDENTIFIERS_FILENAME)
84+
value = symbol_cache.SqliteCache(identifiers_path).find_location(
8485
symbol_cache.WindowsIdentifier.generate(pdb_name.strip('\x00'), guid.upper(), age), 'windows')
8586

8687
if value:

0 commit comments

Comments
 (0)