Skip to content

Commit 68ad063

Browse files
committed
Fixing style errors.
1 parent de3ed7d commit 68ad063

File tree

4 files changed

+37
-22
lines changed

4 files changed

+37
-22
lines changed

boofuzz/cli.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ def cli():
4242
)
4343
@click.option("--procmon-host", help="Process monitor port host or IP")
4444
@click.option("--procmon-port", type=int, default=DEFAULT_PROCMON_PORT, help="Process monitor port")
45-
@click.option("--stdout", type=click.Choice(["HIDE", "CAPTURE", "MIRROR"], case_sensitive=False), default="MIRROR",
46-
help="How to handle stdout (and stderr) of target. CAPTURE saves output for crash reporting but can "
47-
"slow down fuzzing.")
45+
@click.option(
46+
"--stdout",
47+
type=click.Choice(["HIDE", "CAPTURE", "MIRROR"], case_sensitive=False),
48+
default="MIRROR",
49+
help="How to handle stdout (and stderr) of target. CAPTURE saves output for crash reporting but can "
50+
"slow down fuzzing.",
51+
)
4852
@click.option("--tui/--no-tui", help="Enable TUI")
4953
@click.option("--text-dump/--no-text-dump", help="Enable full text dump of logs", default=False)
5054
@click.option("--feature-check", is_flag=True, help="Run a feature check instead of a fuzz test", default=False)
@@ -64,12 +68,18 @@ def cli():
6468
type=int,
6569
help="Record this many cases before each failure. Set to 0 to record all test cases (high disk space usage!).",
6670
)
67-
@click.option("--qemu/--no-qemu", is_flag=True, default=False,
68-
help="Experimental: Enable QEMU mode with code coverage feedback; requires afl-qemu-trace")
71+
@click.option(
72+
"--qemu/--no-qemu",
73+
is_flag=True,
74+
default=False,
75+
help="Experimental: Enable QEMU mode with code coverage feedback; requires afl-qemu-trace",
76+
)
6977
@click.option("--qemu-path", help="afl-qemu-trace path; looks in PATH by default")
7078
@click.option("--web-port", type=int, default=constants.DEFAULT_WEB_UI_PORT, help="port for web GUI")
7179
@click.option("--restart-interval", type=int, help="restart every n test cases")
72-
@click.option("--target-start-wait", type=float, default=0, help="wait n seconds for target to settle in before fuzzing")
80+
@click.option(
81+
"--target-start-wait", type=float, default=0, help="wait n seconds for target to settle in before fuzzing"
82+
)
7383
@click.pass_context
7484
def fuzz(
7585
ctx,

boofuzz/helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
COLOR_PAIR_MAGENTA = 6
3030
COLOR_PAIR_BLACK = 7
3131

32-
sigmap = dict((k, v) for v, k in reversed(sorted(signal.__dict__.items()))
33-
if v.startswith('SIG') and not v.startswith('SIG_'))
32+
sigmap = dict(
33+
(k, v) for v, k in reversed(sorted(signal.__dict__.items())) if v.startswith("SIG") and not v.startswith("SIG_")
34+
)
3435

3536
test_step_info = {
3637
"test_case": {
@@ -310,7 +311,7 @@ def udp_checksum(msg, src_addr, dst_addr):
310311
# If the packet is too big, the checksum is undefined since len(msg)
311312
# won't fit into two bytes. So we just pick our best definition.
312313
# "Truncate" the message as it appears in the checksum.
313-
msg = msg[0: ip_constants.UDP_MAX_LENGTH_THEORETICAL]
314+
msg = msg[0 : ip_constants.UDP_MAX_LENGTH_THEORETICAL]
314315

315316
return ipv4_checksum(_udp_checksum_pseudo_header(src_addr, dst_addr, len(msg)) + msg)
316317

boofuzz/sessions.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,9 @@ def _stop_targets(self):
10131013
target.vmcontrol.restart_target()
10141014
else:
10151015
for monitor in target.monitors:
1016-
self._fuzz_data_logger.log_info("Stopping target process using {}".format(monitor.__class__.__name__))
1016+
self._fuzz_data_logger.log_info(
1017+
"Stopping target process using {}".format(monitor.__class__.__name__)
1018+
)
10171019
monitor.stop_target()
10181020

10191021
def _restart_target(self, target):
@@ -1533,7 +1535,8 @@ def _generate_n_mutations_for_path(self, path, depth, base_mutations=None):
15331535
if base_mutations is not None:
15341536
skip_elements.update(m.qualified_name for m in base_mutations)
15351537
for mutations in self._generate_n_mutations_for_path_recursive(
1536-
path, depth=depth, skip_elements=skip_elements, base_mutations=base_mutations):
1538+
path, depth=depth, skip_elements=skip_elements, base_mutations=base_mutations
1539+
):
15371540
if not self._mutations_contain_duplicate(mutations):
15381541
self.total_mutant_index += 1
15391542
yield MutationContext(message_path=path, mutations={n.qualified_name: n for n in mutations})
@@ -1662,13 +1665,13 @@ def _parse_mutation_names(self, mutation_names):
16621665
try:
16631666
request = self.nodes[request_name]
16641667
except KeyError:
1665-
raise Exception(
1666-
"Request {0} not found in blocks.REQUESTS: {1}".format(request_name, self.nodes))
1668+
raise Exception("Request {0} not found in blocks.REQUESTS: {1}".format(request_name, self.nodes))
16671669
try:
16681670
fuzzable = request.names[qualified_name]
16691671
except KeyError:
1670-
raise Exception("Name {0} not found in request {1}.names: {2}".format(
1671-
qualified_name, request_name, request.names))
1672+
raise Exception(
1673+
"Name {0} not found in request {1}.names: {2}".format(qualified_name, request_name, request.names)
1674+
)
16721675
mutations += next(itertools.islice(fuzzable.get_mutations(), index, index + 1))
16731676
return mutations
16741677

boofuzz/utils/debugger_thread_qemu.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
class ForkServer:
3737
"""Implements the AFL fork server protocol. Used by DebuggerThreadQemu."""
38+
3839
def __init__(self, args, hide_output):
3940
self.hide_output = hide_output
4041
self.pid = None
@@ -53,8 +54,7 @@ def __init__(self, args, hide_output):
5354
self.parent()
5455

5556
def child(self, args):
56-
"""Execute afl-qemu-trace with appropriate inputs: target command args, env var settings, and file descriptors.
57-
"""
57+
"""Execute afl-qemu-trace with appropriate inputs: target command args, env var settings, and file descriptors."""
5858
os.dup2(self.forkserv_fd_to_server_out, AFL_FORKSRV_FD)
5959
os.dup2(self.forkserv_fd_from_server_in, AFL_FORKSRV_FD + 1)
6060

@@ -68,9 +68,10 @@ def child(self, args):
6868
os.close(self.forkserv_fd_to_server_out)
6969
os.close(self.forkserv_fd_from_server_in)
7070
os.close(self.forkserv_fd_from_server_out)
71-
env = {"QEMU_LOG": "nochain",
72-
AFL_SHM_ENV_VAR: str(self.shm_id),
73-
}
71+
env = {
72+
"QEMU_LOG": "nochain",
73+
AFL_SHM_ENV_VAR: str(self.shm_id),
74+
}
7475
os.execve(QEMU_PATH, ["afl-qemu-trace"] + args, env)
7576

7677
def parent(self):
@@ -79,8 +80,7 @@ def parent(self):
7980
os.read(self.forkserv_fd_from_server_out, 4)
8081

8182
def run(self): # only the parent runs run()
82-
"""Runs the testcase in QEMU (by sending a command to the fork server) and returns the pid.
83-
"""
83+
"""Runs the testcase in QEMU (by sending a command to the fork server) and returns the pid."""
8484
os.write(self.forkserv_fd_to_server_in, b"\0\0\0\0") # Tell AFL Fork Server to start the target
8585
pid = struct.unpack("I", os.read(self.forkserv_fd_from_server_out, 4))[0] # Read PID from Fork Server
8686
self.pid = pid
@@ -111,6 +111,7 @@ def _get_coredump_path():
111111

112112
class DebuggerThreadQemu(threading.Thread):
113113
"""Debugger thread using QEMU and AFL fork server."""
114+
114115
fork_server = None # use class attribute due to the procmon's behavior of creating a new debugger thread on restart
115116

116117
def __init__(

0 commit comments

Comments
 (0)