Skip to content

Commit

Permalink
Changed type of dep_value argument of Block to bytes (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
SR4ven authored Oct 4, 2023
1 parent 38e280c commit fbe81fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Fixes
- The minimum supported Python version is now 3.7.
- Removed duplicates from `BitField` primitive.
- Fixed unwanted deprecation warning when using `Session.fuzz(name=name)`.
- Changed type of `dep_value` argument of `Block` to bytes and added type checks.

v0.4.1
------
Expand Down
4 changes: 2 additions & 2 deletions boofuzz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ def s_block(name=None, group=None, encoder=None, dep=None, dep_value=None, dep_v
:param encoder: (Optional, def=None) Optional pointer to a function to pass rendered data to prior to return
:type dep: str, optional
:param dep: (Optional, def=None) Optional primitive whose specific value this block is dependant on
:type dep_value: Mixed, optional
:type dep_value: bytes, optional
:param dep_value: (Optional, def=None) Value that field "dep" must contain for block to be rendered
:type dep_values: List of Mixed Types, optional
:type dep_values: List of bytes, optional
:param dep_values: (Optional, def=None) Values that field "dep" may contain for block to be rendered
:type dep_compare: str, optional
:param dep_compare: (Optional, def="==") Comparison method to use on dependency (==, !=, >, >=, <, <=)
Expand Down
10 changes: 9 additions & 1 deletion boofuzz/blocks/block.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..fuzzable_block import FuzzableBlock
from typing import List


class Block(FuzzableBlock):
Expand All @@ -21,7 +22,7 @@ class Block(FuzzableBlock):
:param dep: Optional primitive whose specific value this block is dependant on, defaults to None
:type dep: str, optional
:param dep_value: Value that field "dep" must contain for block to be rendered, defaults to None
:type dep_value: Any, optional
:type dep_value: bytes, optional
:param dep_values: Values that field "dep" may contain for block to be rendered, defaults to None
:type dep_values: list, optional
:param dep_compare: Comparison method to apply to dependency (==, !=, >, >=, <, <=), defaults to None
Expand All @@ -43,6 +44,13 @@ def __init__(
*args,
**kwargs
):
if dep_value is not None and not isinstance(dep_value, bytes):
raise TypeError("dep_value must be of bytes type")
if dep_values is not None and not (
isinstance(dep_values, list) and all(isinstance(x, bytes) for x in dep_values)
):
raise TypeError("dep_values must be of list of bytes type")

super(Block, self).__init__(
name=name, default_value=default_value, request=request, children=children, *args, **kwargs
)
Expand Down

0 comments on commit fbe81fd

Please sign in to comment.