Skip to content

Commit e8a23cc

Browse files
authored
Merge pull request #1884 from volatilityfoundation/issues/ruff-formatter
Apply changes that ruff formatter would make which black doesn't mind
2 parents 4541a6e + 841b2b6 commit e8a23cc

File tree

92 files changed

+2425
-588
lines changed

Some content is hidden

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

92 files changed

+2425
-588
lines changed

development/banner_server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515

1616
class BannerCacheGenerator:
17-
1817
def __init__(self, path: str, url_prefix: str):
1918
self._path = path
2019
self._url_prefix = url_prefix
@@ -79,7 +78,6 @@ def run(self):
7978

8079

8180
if __name__ == "__main__":
82-
8381
parser = argparse.ArgumentParser()
8482
parser.add_argument("--path", default=os.path.dirname(__file__))
8583
parser.add_argument(

development/compare-vol.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def plugin_cmd(self, plugin: VolatilityPlugin, image: VolatilityImage) -> List[s
208208

209209

210210
class VolatilityTester:
211-
212211
def __init__(
213212
self,
214213
images: List[VolatilityImage],

development/pdbparse-to-json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323

2424
class PDBRetreiver:
25-
2625
def retreive_pdb(self, guid: str, file_name: str) -> Optional[str]:
2726
logger.info("Download PDB file...")
2827
file_name = ".".join(file_name.split(".")[:-1] + ["pdb"])

development/stock-linux-json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class Downloader:
16-
1716
def __init__(self, url_lists: List[List[str]]) -> None:
1817
self.url_lists = url_lists
1918

test/plugins/windows/test_scheduled_tasks.py

Lines changed: 1809 additions & 227 deletions
Large diffs are not rendered by default.

test/renderers/test_parquet_renderers.py

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
import pyarrow as pa
99
import pyarrow.parquet as pq
1010
import pyarrow.compute as pc
11+
1112
HAS_PYARROW = True
1213
except ImportError:
13-
# The user doesn't have pyarrow installed, but HAS_PYARROW will be false so just continue
14+
# The user doesn't have pyarrow installed, but HAS_PYARROW will be false so just continue
1415
pass
1516

1617

@@ -41,10 +42,33 @@ def test_windows_generic_pslist(self, volatility, python, image):
4142
table = self._get_table_from_output(out)
4243
assert table.num_rows > 10
4344

44-
assert table.filter(pc.match_substring(pc.utf8_lower(table.column('ImageFileName')), "system")).num_rows > 0
45-
assert table.filter(pc.match_substring(pc.utf8_lower(table.column('ImageFileName')), "csrss.exe")).num_rows > 0
46-
assert table.filter(pc.match_substring(pc.utf8_lower(table.column('ImageFileName')), "svchost.exe")).num_rows > 0
47-
assert table.filter(pc.greater(table.column('PID'), 0)).num_rows == table.num_rows
45+
assert (
46+
table.filter(
47+
pc.match_substring(
48+
pc.utf8_lower(table.column("ImageFileName")), "system"
49+
)
50+
).num_rows
51+
> 0
52+
)
53+
assert (
54+
table.filter(
55+
pc.match_substring(
56+
pc.utf8_lower(table.column("ImageFileName")), "csrss.exe"
57+
)
58+
).num_rows
59+
> 0
60+
)
61+
assert (
62+
table.filter(
63+
pc.match_substring(
64+
pc.utf8_lower(table.column("ImageFileName")), "svchost.exe"
65+
)
66+
).num_rows
67+
> 0
68+
)
69+
assert (
70+
table.filter(pc.greater(table.column("PID"), 0)).num_rows == table.num_rows
71+
)
4872

4973
def test_linux_generic_pslist(self, volatility, python, image):
5074
rc, out, _err = test_volatility.runvol_plugin(
@@ -59,12 +83,23 @@ def test_linux_generic_pslist(self, volatility, python, image):
5983
table = self._get_table_from_output(out)
6084
assert table.num_rows > 10
6185

62-
init_rows = table.filter(pc.match_substring(pc.utf8_lower(table.column('COMM')), "init"))
63-
systemd_rows = table.filter(pc.match_substring(pc.utf8_lower(table.column('COMM')), "systemd"))
86+
init_rows = table.filter(
87+
pc.match_substring(pc.utf8_lower(table.column("COMM")), "init")
88+
)
89+
systemd_rows = table.filter(
90+
pc.match_substring(pc.utf8_lower(table.column("COMM")), "systemd")
91+
)
6492
assert (init_rows.num_rows > 0) or (systemd_rows.num_rows > 0)
6593

66-
assert table.filter(pc.match_substring(pc.utf8_lower(table.column('COMM')), "watchdog")).num_rows > 0
67-
assert table.filter(pc.greater(table.column('PID'), 0)).num_rows == table.num_rows
94+
assert (
95+
table.filter(
96+
pc.match_substring(pc.utf8_lower(table.column("COMM")), "watchdog")
97+
).num_rows
98+
> 0
99+
)
100+
assert (
101+
table.filter(pc.greater(table.column("PID"), 0)).num_rows == table.num_rows
102+
)
68103

69104
def test_windows_generic_handles(self, volatility, python, image):
70105
rc, out, _err = test_volatility.runvol_plugin(
@@ -79,7 +114,14 @@ def test_windows_generic_handles(self, volatility, python, image):
79114

80115
table = self._get_table_from_output(out)
81116
assert table.num_rows > 500
82-
assert table.filter(pc.match_substring(pc.utf8_lower(table.column('Name')), "machine\\system")).num_rows > 0
117+
assert (
118+
table.filter(
119+
pc.match_substring(
120+
pc.utf8_lower(table.column("Name")), "machine\\system"
121+
)
122+
).num_rows
123+
> 0
124+
)
83125

84126
def test_linux_generic_lsof(self, volatility, python, image):
85127
rc, out, _err = test_volatility.runvol_plugin(
@@ -94,6 +136,7 @@ def test_linux_generic_lsof(self, volatility, python, image):
94136
table = self._get_table_from_output(out)
95137
assert table.num_rows > 35
96138

139+
97140
class TestParquetRenderer(TestArrowRendererBase):
98141
renderer_format = "parquet"
99142

@@ -106,4 +149,3 @@ class TestArrowRenderer(TestArrowRendererBase):
106149

107150
def _get_table_from_output(self, output_bytes):
108151
return pa.ipc.open_stream(io.BytesIO(output_bytes)).read_all()
109-

test/volatility3_code_analysis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def __str__(self):
8282

8383

8484
class UnrequiredVersionableUsage(CodeViolation):
85-
8685
def __init__(
8786
self,
8887
module: types.ModuleType,
@@ -107,7 +106,6 @@ def __str__(self) -> str:
107106

108107

109108
class DirectVolatilityImportUsage(CodeViolation):
110-
111109
def __init__(
112110
self,
113111
module: types.ModuleType,
@@ -174,8 +172,11 @@ def _check_vol3_import_from(self, node: ast.ImportFrom):
174172
"""
175173
if (
176174
node.module
177-
and node.module.startswith("volatility3.") # Give a pass to volatility3 module
178-
and node.module != "volatility3.framework.constants._version" # make an exception for this
175+
and node.module.startswith(
176+
"volatility3."
177+
) # Give a pass to volatility3 module
178+
and node.module
179+
!= "volatility3.framework.constants._version" # make an exception for this
179180
):
180181
for name in node.names:
181182
try:
@@ -204,7 +205,6 @@ def _check_vol3_import_from(self, node: ast.ImportFrom):
204205
def enter_ImportFrom(self, node: ast.ImportFrom):
205206
self._check_vol3_import_from(node)
206207

207-
208208
def enter_ClassDef(self, node: ast.ClassDef) -> Any:
209209
logger.debug("Entering class %s", node.name)
210210
clazz = None

volatility3/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0
33
#
44
"""Volatility 3 - An open-source memory forensics framework"""
5+
56
import inspect
67
import sys
78
from importlib import abc

volatility3/cli/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* run the plugin
1111
* display the results
1212
"""
13+
1314
import argparse
1415
import inspect
1516
import io
@@ -458,8 +459,9 @@ def run(self):
458459
raise ValueError(
459460
"Invalid extension (extensions must be of the format \"conf.path.value='value'\")"
460461
)
461-
address, value = extension[: extension.find("=")], json.loads(
462-
extension[extension.find("=") + 1 :]
462+
address, value = (
463+
extension[: extension.find("=")],
464+
json.loads(extension[extension.find("=") + 1 :]),
463465
)
464466
ctx.config[address] = value
465467

@@ -574,7 +576,7 @@ def load_system_defaults(
574576
delayed_logs.append(
575577
(
576578
logging.DEBUG,
577-
f"Loaded configuration: {json.dumps(result, indent = 2, sort_keys = True)}",
579+
f"Loaded configuration: {json.dumps(result, indent=2, sort_keys=True)}",
578580
)
579581
)
580582
return delayed_logs, result
@@ -763,7 +765,7 @@ def order_extra_verbose_levels(self):
763765
constants.LOGLEVEL_VVVV,
764766
]
765767
):
766-
logging.addLevelName(level_value, f"DETAIL {level+1}")
768+
logging.addLevelName(level_value, f"DETAIL {level + 1}")
767769

768770
def file_handler_class_factory(self, direct=True):
769771
output_dir = self.output_dir

volatility3/cli/text_renderer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ def ignored_columns(
278278

279279

280280
class QuickTextRenderer(CLIRenderer):
281-
282281
name = "quick"
283282

284283
def get_render_options(self):
@@ -348,7 +347,6 @@ def render(self, grid: interfaces.renderers.TreeGrid) -> None:
348347

349348

350349
class CSVRenderer(CLIRenderer):
351-
352350
name = "csv"
353351
structured_output = True
354352

0 commit comments

Comments
 (0)