Skip to content

Commit 62506ae

Browse files
committed
Core: Fix up github security issues
This fixes an unused import, an improper use of self and lots and lots of places where we implicitly return None. This now explicitly returns None to improve readability and prevent mixed implicit and explicit return values. This should also somewhat aid type checking by humans.
1 parent 7012edb commit 62506ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+106
-106
lines changed

volatility3/cli/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def __init__(self, filename: str):
662662
def close(self):
663663
# Don't overcommit
664664
if self.closed:
665-
return
665+
return None
666666

667667
self.seek(0)
668668

@@ -712,7 +712,7 @@ def close(self):
712712
"""Closes and commits the file (by moving the temporary file to the correct name"""
713713
# Don't overcommit
714714
if self._file.closed:
715-
return
715+
return None
716716

717717
self._file.close()
718718
output_filename = self._get_final_filename()

volatility3/cli/volshell/generic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def help(self, *args):
108108
"""Describes the available commands"""
109109
if args:
110110
help(*args)
111-
return
111+
return None
112112

113113
variables = []
114114
print("\nMethods:")
@@ -325,7 +325,7 @@ def display_type(
325325
(str, interfaces.objects.ObjectInterface, interfaces.objects.Template),
326326
):
327327
print("Cannot display information about non-type object")
328-
return
328+
return None
329329

330330
if not isinstance(object, str):
331331
# Mypy requires us to order things this way
@@ -453,7 +453,7 @@ def display_symbols(self, symbol_table: str = None):
453453
"""Prints an alphabetical list of symbols for a symbol table"""
454454
if symbol_table is None:
455455
print("No symbol table provided")
456-
return
456+
return None
457457
longest_offset = longest_name = 0
458458

459459
table = self.context.symbol_space[symbol_table]

volatility3/cli/volshell/linux.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def change_task(self, pid=None):
3535
process_layer = task.add_process_layer()
3636
if process_layer is not None:
3737
self.change_layer(process_layer)
38-
return
38+
return None
3939
print(f"Layer for task ID {pid} could not be constructed")
40-
return
40+
return None
4141
print(f"No task with task ID {pid} found")
4242

4343
def list_tasks(self):

volatility3/cli/volshell/mac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def change_task(self, pid=None):
3535
process_layer = task.add_process_layer()
3636
if process_layer is not None:
3737
self.change_layer(process_layer)
38-
return
38+
return None
3939
print(f"Layer for task ID {pid} could not be constructed")
40-
return
40+
return None
4141
print(f"No task with task ID {pid} found")
4242

4343
def list_tasks(self, method=None):

volatility3/cli/volshell/windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def change_process(self, pid=None):
3232
if process.UniqueProcessId == pid:
3333
process_layer = process.add_process_layer()
3434
self.change_layer(process_layer)
35-
return
35+
return None
3636
print(f"No process with process ID {pid} found")
3737

3838
def list_processes(self):

volatility3/framework/automagic/module.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def __call__(
2929
requirement.requirements[req],
3030
progress_callback,
3131
)
32-
return
32+
return None
3333
if not requirement.unsatisfied(context, config_path):
34-
return
34+
return None
3535
# The requirement is unfulfilled and is a ModuleRequirement
3636

3737
context.config[
@@ -43,7 +43,7 @@ def __call__(
4343
requirement.requirements[req].unsatisfied(context, new_config_path)
4444
and req != "offset"
4545
):
46-
return
46+
return None
4747

4848
# We now just have the offset requirement, but the layer requirement has been fulfilled.
4949
# Unfortunately we don't know the layer name requirement's exact name

volatility3/framework/automagic/stacker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def stack(
103103
appropriate_config_path, layer_name = result
104104
context.config.merge(appropriate_config_path, subconfig)
105105
context.config[appropriate_config_path] = top_layer_name
106-
return
106+
return None
107107
self._cached = None
108108

109109
new_context = context.clone()

volatility3/framework/automagic/symbol_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __call__(
6969

7070
# Bomb out early if our details haven't been configured
7171
if self.symbol_class is None:
72-
return
72+
return None
7373

7474
self._requirements = self.find_requirements(
7575
context,
@@ -120,7 +120,7 @@ def _banner_scan(
120120

121121
# Bomb out early if there's no banners
122122
if not self.banners:
123-
return
123+
return None
124124

125125
mss = scanners.MultiStringScanner([x for x in self.banners if x is not None])
126126

volatility3/framework/layers/intel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ def _mapping(
331331
except exceptions.InvalidAddressException:
332332
if not ignore_errors:
333333
raise
334-
return
334+
return None
335335
yield offset, length, mapped_offset, length, layer_name
336-
return
336+
return None
337337
while length > 0:
338338
try:
339339
chunk_offset, page_size, layer_name = self._translate(offset)

volatility3/framework/layers/msf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def pdb_symbol_table(self) -> str:
4747
def read_streams(self):
4848
# Shortcut in case they've already been read
4949
if self._streams:
50-
return
50+
return None
5151

5252
# Recover the root table, by recovering the root table index table...
5353
module = self.context.module(self.pdb_symbol_table, self._base_layer, offset=0)

0 commit comments

Comments
 (0)