Skip to content

Commit

Permalink
Support for Python 3.13 (#735)
Browse files Browse the repository at this point in the history
Removed support for eol 3.8
Reformat with black 25.1
  • Loading branch information
SR4ven authored Feb 7, 2025
1 parent 6ea8d24 commit 10a1501
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/2_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ body:
label: Python version
description: What Python version are you running?
options:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- "Other"
validations:
required: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
python-version: [3.9, "3.10", 3.11, 3.12, 3.13]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Upcomming
---------
Features
^^^^^^^^
- Added Python 3.12 compatibility.
- Added Python 3.13 compatibility.

Fixes
^^^^^
- The minimum supported Python version is now 3.9.

v0.4.2
------
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See installation instructions for details on installing boofuzz from source with
Pull Request Checklist
----------------------

1. Install python version 3.8+
1. Install python version 3.9+

2. Verify tests pass:

Expand Down
2 changes: 1 addition & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Installing boofuzz
Prerequisites
-------------

Boofuzz requires Python ≥ 3.8. Recommended installation requires ``pip``. As a base requirement, the following packages
Boofuzz requires Python ≥ 3.9. Recommended installation requires ``pip``. As a base requirement, the following packages
are needed:

Ubuntu/Debian
Expand Down
6 changes: 3 additions & 3 deletions boofuzz/blocks/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def __init__(
self._fuzz_library = [
b"\x00" * self._length,
b"\x11" * self._length,
b"\xEE" * self._length,
b"\xFF" * self._length,
b"\xFF" * (self._length - 1) + b"\xFE",
b"\xee" * self._length,
b"\xff" * self._length,
b"\xff" * (self._length - 1) + b"\xfe",
b"\x00" * (self._length - 1) + b"\x01",
]

Expand Down
2 changes: 1 addition & 1 deletion boofuzz/connections/raw_l3_socket_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RawL3SocketConnection(base_socket_connection.BaseSocketConnection):
send_timeout (float): Seconds to wait for send before timing out. Default 5.0.
recv_timeout (float): Seconds to wait for recv before timing out. Default 5.0.
ethernet_proto (int): Ethernet protocol to bind to. Defaults to ETH_P_IP (0x0800).
l2_dst (bytes): Layer2 destination address (e.g. MAC address). Default b'\xFF\xFF\xFF\xFF\xFF\xFF' (broadcast)
l2_dst (bytes): Layer2 destination address (e.g. MAC address). Default b'\xff\xff\xff\xff\xff\xff' (broadcast)
packet_size (int): Maximum packet size (in bytes). Default 1500 if the underlying interface uses
standard ethernet for layer 2. Otherwise, a different packet size may apply (e.g. Jumboframes,
802.5 Token Ring, 802.11 wifi, ...) that must be specified.
Expand Down
4 changes: 2 additions & 2 deletions boofuzz/connections/socket_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def SocketConnection(
send_timeout=5.0,
recv_timeout=5.0,
ethernet_proto=None,
l2_dst=b"\xFF" * 6,
l2_dst=b"\xff" * 6,
udp_broadcast=False,
server=False,
sslcontext=None,
Expand Down Expand Up @@ -66,7 +66,7 @@ def SocketConnection(
ethernet_proto (int): Ethernet protocol when using 'raw-l3'. 16 bit integer.
Default ETH_P_IP (0x0800) when using 'raw-l3'. See "if_ether.h" in Linux documentation for more options.
l2_dst (str): Layer 2 destination address (e.g. MAC address). Used only by 'raw-l3'.
Default '\xFF\xFF\xFF\xFF\xFF\xFF' (broadcast).
Default '\xff\xff\xff\xff\xff\xff' (broadcast).
udp_broadcast (bool): Set to True to enable UDP broadcast. Must supply appropriate broadcast address for send()
to work, and '' for bind host for recv() to work.
server (bool): Set to True to enable server side fuzzing.
Expand Down
2 changes: 1 addition & 1 deletion boofuzz/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def ip_str_to_bytes(ip):
:param ip: IP address string, e.g. '127.0.0.1'
:return 4-byte representation of ip, e.g. b'\x7F\x00\x00\x01'
:return 4-byte representation of ip, e.g. b'\x7f\x00\x00\x01'
:rtype bytes
:raises ValueError if ip is not a legal IP address.
Expand Down
24 changes: 12 additions & 12 deletions boofuzz/primitives/bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Bytes(Fuzzable):
_fuzz_library = [
b"",
b"\x00",
b"\xFF",
b"\xff",
b"A" * 10,
b"A" * 100,
b"A" * 1000,
Expand Down Expand Up @@ -88,30 +88,30 @@ class Bytes(Fuzzable):
# This is a list of "interesting" 1,2 and 4 byte binary strings.
# The lists are used to replace each block of 1, 2 or 4 byte in the original
# value with each of those "interesting" values.
_fuzz_strings_1byte = [b"\x00", b"\x01", b"\x7F", b"\x80", b"\xFF"] + [
_fuzz_strings_1byte = [b"\x00", b"\x01", b"\x7f", b"\x80", b"\xff"] + [
i for i in _magic_debug_values if len(i) == 1
]

_fuzz_strings_2byte = [
b"\x00\x00",
b"\x01\x00",
b"\x00\x01",
b"\x7F\xFF",
b"\xFF\x7F",
b"\xFE\xFF",
b"\xFF\xFE",
b"\xFF\xFF",
b"\x7f\xff",
b"\xff\x7f",
b"\xfe\xff",
b"\xff\xfe",
b"\xff\xff",
] + [i for i in _magic_debug_values if len(i) == 2]

_fuzz_strings_4byte = [
b"\x00\x00\x00\x00",
b"\x00\x00\x00\x01",
b"\x01\x00\x00\x00",
b"\x7F\xFF\xFF\xFF",
b"\xFF\xFF\xFF\x7F",
b"\xFE\xFF\xFF\xFF",
b"\xFF\xFF\xFF\xFE",
b"\xFF\xFF\xFF\xFF",
b"\x7f\xff\xff\xff",
b"\xff\xff\xff\x7f",
b"\xfe\xff\xff\xff",
b"\xff\xff\xff\xfe",
b"\xff\xff\xff\xff",
] + [i for i in _magic_debug_values if len(i) == 4]

_mutators_of_default_value = [
Expand Down
4 changes: 2 additions & 2 deletions boofuzz/primitives/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ class String(Fuzzable):
"}",
"\x14",
"\x00",
"\xFE", # expands to 4 characters under utf1
"\xFF", # expands to 4 characters under utf1
"\xfe", # expands to 4 characters under utf1
"\xff", # expands to 4 characters under utf1
]

_long_string_lengths = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 32768, 0xFFFF]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ funcy = "*"
psutil = "*"
pydot = "*"
pyserial = "*"
python = "^3.8"
python = "^3.9"
tornado = "*"

# dev extras
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
minversion=2.0
isolated_build = true
skip_missing_interpreters = True
envlist = py{38,39,310,311,312}-{Linux,Windows,macOS}, docs, lint
envlist = py{39,310,311,312,313}-{Linux,Windows,macOS}, docs, lint

[testenv]
platform =
Expand Down
10 changes: 5 additions & 5 deletions unit_tests/test_helpers_ip_str_to_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
@pytest.mark.parametrize(
["ip_str", "ip_bytes"],
[
("127.0.0.1", b"\x7F\x00\x00\x01"),
("255.255.255.255", b"\xFF\xFF\xFF\xFF"),
("127.0.0.1", b"\x7f\x00\x00\x01"),
("255.255.255.255", b"\xff\xff\xff\xff"),
("0.0.0.0", b"\x00\x00\x00\x00"),
("0.1.2.3", b"\x00\x01\x02\x03"),
("1.2.3", b"\x01\x02\x00\x03"),
("1.2.256", b"\x01\x02\x01\x00"),
("1.2.65535", b"\x01\x02\xFF\xFF"),
("1.16777215", b"\x01\xFF\xFF\xFF"),
("4294967294", b"\xFF\xFF\xFF\xFE"),
("1.2.65535", b"\x01\x02\xff\xff"),
("1.16777215", b"\x01\xff\xff\xff"),
("4294967294", b"\xff\xff\xff\xfe"),
],
)
@scenario("helpers_ip_str_to_bytes.feature", "Valid IP addresses")
Expand Down
12 changes: 6 additions & 6 deletions unit_tests/test_name_resolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ def complex_request_scenario(context, name, block_name):
"sizer_l3": block_name if name == "sizer_l3" else ".A",
}
s_initialize("test_req")
s_static(b"\xA1\xA1", name="A")
s_static(b"\xB1", name="B1")
s_static(b"\xa1\xa1", name="A")
s_static(b"\xb1", name="B1")
s_size(block_names["sizer_l1"], name="sizer_l1", length=1)
with s_block("C"):
s_static(b"\xA2\xA2\xA2", name="A")
s_static(b"\xB2", name="B2")
s_static(b"\xa2\xa2\xa2", name="A")
s_static(b"\xb2", name="B2")
s_size(block_names["sizer_l2"], name="sizer_l2", length=1)
with s_block("C"):
s_static(b"\xA3\xA3\xA3\xA3", name="A")
s_static(b"\xB3", name="B3")
s_static(b"\xa3\xa3\xa3\xa3", name="A")
s_static(b"\xb3", name="B3")
s_size(block_names["sizer_l3"], name="sizer_l3", length=1)

context.req = s_get("test_req")
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/test_session_failure_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MiniTestServer:
def __init__(self, stay_silent=False, proto="tcp", host="0.0.0.0"):
self.server_socket = None
self.received = None
self.data_to_send = b"\xFE\xEB\xDA\xED"
self.data_to_send = b"\xfe\xeb\xda\xed"
self.active_port = None
self.stay_silent = stay_silent
self.proto = proto
Expand Down
10 changes: 5 additions & 5 deletions unit_tests/test_socket_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class MiniTestServer:
def __init__(self, stay_silent=False, proto="tcp", host="0.0.0.0"):
self.server_socket = None
self.received = None
self.data_to_send = b"\xFE\xEB\xDA\xED"
self.data_to_send = b"\xfe\xeb\xda\xed"
self.active_port = None
self.stay_silent = stay_silent
self.proto = proto
Expand Down Expand Up @@ -462,8 +462,8 @@ def test_raw_l2(self):
raw_packet = ethernet_frame(
payload=ip_packet(
payload=udp_packet(payload=data_to_send, src_port=server.active_port + 1, dst_port=server.active_port),
src_ip=b"\x7F\x00\x00\x01",
dst_ip=b"\x7F\x00\x00\x01",
src_ip=b"\x7f\x00\x00\x01",
dst_ip=b"\x7f\x00\x00\x01",
),
src_mac=b"\x00" * 6,
dst_mac=b"\xff" * 6,
Expand Down Expand Up @@ -613,8 +613,8 @@ def test_raw_l3(self):
# Assemble packet...
raw_packet = ip_packet(
payload=udp_packet(payload=data_to_send, src_port=server.active_port + 1, dst_port=server.active_port),
src_ip=b"\x7F\x00\x00\x01",
dst_ip=b"\x7F\x00\x00\x01",
src_ip=b"\x7f\x00\x00\x01",
dst_ip=b"\x7f\x00\x00\x01",
)
expected_server_receive = ETHER_IPV4_HEADER + raw_packet

Expand Down

0 comments on commit 10a1501

Please sign in to comment.