Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecation warning for Session.fuzz(name=name) #689

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixes
- `s_update` primitive was out of date.
- The minimum supported Python version is now 3.7.
- Removed duplicates from `BitField` primitive.
- Fixed unwanted deprecation warning when using `Session.fuzz(name=name)`.

v0.4.1
------
Expand Down
29 changes: 17 additions & 12 deletions boofuzz/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,29 +1274,34 @@ def fuzz(self, name=None, max_depth=None):
None
"""
self.total_mutant_index = 0
self.total_num_mutations = self.num_mutations(max_depth=max_depth)

if name is None or name == "":
self.total_num_mutations = self.num_mutations(max_depth=max_depth)
self._main_fuzz_loop(self._generate_mutations_indefinitely(max_depth=max_depth))
else:
self.fuzz_by_name(name=name)
path, mutations = helpers.parse_test_case_name(name)
if len(mutations) < 1:
self._fuzz_single_node_by_path(path)
else:
self.total_num_mutations = 1

node_edges = self._path_names_to_edges(node_names=path)
self._main_fuzz_loop(self._generate_test_case_from_named_mutations(node_edges, mutations))

def fuzz_by_name(self, name):
"""Fuzz a particular test case or node by name.

Args:
name (str): Name of node.
"""
warnings.warn("Session.fuzz_by_name is deprecated in favor of Session.fuzz(name=name).")
path, mutations = helpers.parse_test_case_name(name)
if len(mutations) < 1:
self._fuzz_single_node_by_path(path)
else:
self.total_mutant_index = 0
self.total_num_mutations = 1

node_edges = self._path_names_to_edges(node_names=path)
self._main_fuzz_loop(self._generate_test_case_from_named_mutations(node_edges, mutations))
.. deprecated :: 0.4.0
Use :meth:`Session.fuzz` instead.
"""
warnings.warn(
"Session.fuzz_by_name is deprecated in favor of Session.fuzz(name=name).",
FutureWarning,
)
self.fuzz(name=name)

def _fuzz_single_node_by_path(self, node_names):
"""Fuzz a particular node via the path in node_names.
Expand Down