Skip to content

Commit

Permalink
Switch to poetry build system (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
SR4ven authored Oct 6, 2023
1 parent 124868d commit c2facda
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 160 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install poetry
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
poetry publish --build -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ENV/
env.bak/
venv.bak/
Pipfile
poetry.lock

# Sphinx documentation
docs/_build/
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Fixes
- Specified encoding on file write rather than assuming default encoding
- Changed type of `default_value` from string to bytes for `FromFile`.
- `s_update` primitive was out of date.
- The minimum supported Python version is now 3.7.
- The minimum supported Python version is now 3.8.
- 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.
- Split sessions.py into multiple files.
- Using poetry as package build system.

v0.4.1
------
Expand Down
4 changes: 2 additions & 2 deletions 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.7+
1. Install python version 3.8+

2. Verify tests pass:

Expand Down Expand Up @@ -75,7 +75,7 @@ Prep

2. Increment version number from last release according to PEP 0440 and roughly according to the Semantic Versioning guidelines.

1. In ``boofuzz/__init__.py``.
1. In ``pyproject.toml``.

2. In ``docs/conf.py``.

Expand Down
28 changes: 23 additions & 5 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,38 @@ environment beforehand.

From Source
-----------


1. Like above, it is recommended to set up a virtual environment. Depending on your
concrete setup, this is largely equivalent to the steps outlined above. Make sure
to upgrade ``setuptools`` and ``pip``.
to upgrade ``setuptools`` and ``pip`` or ``poetry``.
2. Download the source code. You can either grab a zip from https://github.com/jtpereyda/boofuzz
or directly clone it with git:

.. code-block:: bash
$ git clone https://github.com/jtpereyda/boofuzz.git
3. Install. Run ``pip`` from within the boofuzz directory after activating the virtual
environment:
Install with Poetry
~~~~~~~~~~~~~~~~~~~
Poetry will automatically create a virtual environment for you and install the required dependencies. The installation
will be editable by default, meaning that changes to the source code will be seen directly without reinstalling.

Simply execute the following command inside the boofuzz source dir:

.. code-block:: bash
$ poetry install
To install with extra dependencies like `dev` or `docs`, specify them in one of the following ways:

.. code-block:: bash
$ poetry install --extras "dev"
$ poetry install -E docs
$ poetry install --all-extras
Install with Pip
~~~~~~~~~~~~~~~~
Run ``pip`` from within the boofuzz directory after activating the virtual environment:

.. code-block:: bash
Expand Down
14 changes: 0 additions & 14 deletions MANIFEST.in

This file was deleted.

2 changes: 0 additions & 2 deletions boofuzz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@
"Word",
]

__version__ = "0.4.1"


# REQUEST MANAGEMENT
def s_get(name=None):
Expand Down
2 changes: 1 addition & 1 deletion boofuzz/fuzz_logger_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(
self._current_num_mutations = 0

self._format_raw_bytes = bytes_to_str
self._version = helpers.get_boofuzz_version(helpers)
self._version = helpers.get_boofuzz_version()

# Resize console to minimum size
self._width, self._height = get_terminal_size()
Expand Down
15 changes: 4 additions & 11 deletions boofuzz/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import errno
import importlib.metadata
import os
import re
import signal
Expand Down Expand Up @@ -424,22 +425,14 @@ def path_exists(path):
return os.path.exists(path)


def get_boofuzz_version(boofuzz_class):
def get_boofuzz_version():
"""
Parses __init__.py for a version string and returns it like 'v0.0.0'
:type boofuzz_class: class
:param boofuzz_class: Any boofuzz class in the same dir as the __init__ class.
Gets the currently installed boofuzz version
:rtype: str
:return: Boofuzz version as string
"""
path = os.path.dirname(boofuzz_class.__file__)
with open(os.path.join(path, "__init__.py")) as search:
for line in search:
if line.find("__version__ = ") != -1:
return "v" + re.search(r'"(.*?)"', line).group(1) # pytype: disable=attribute-error
return "v-.-.-"
return "v" + importlib.metadata.version("boofuzz")


def str_to_bytes(value, encoding="utf-8", errors="replace"):
Expand Down
114 changes: 114 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,116 @@
[tool.poetry]
name = "boofuzz"
version = "0.4.1"
description = "A fork and successor of the Sulley Fuzzing Framework"
authors = ["Joshua Pereyda <joshua.t.pereyda@gmail.com>"]
license = "GPL-2.0-only"
readme = ["README.rst", "CHANGELOG.rst"]
repository = "https://github.com/jtpereyda/boofuzz"
documentation = "https://boofuzz.readthedocs.io/"
keywords = ["security", "fuzzing"]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Environment :: Console :: Curses",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Operating System :: OS Independent",
"Topic :: Security",
"Topic :: System :: Networking",
"Topic :: Software Development :: Testing :: Traffic Generation",
]

include = [
{ path = "*.py", format = "sdist" },
{ path = "*.rst", format = "sdist" },
{ path = "*.toml", format = "sdist" },
{ path = "*.txt", format = "sdist" },
{ path = "tox.ini", format = "sdist" },
{ path = "_static", format = "sdist" },
{ path = "artwork", format = "sdist" },
{ path = "docs", format = "sdist" },
{ path = "examples", format = "sdist" },
{ path = "request_definitions", format = "sdist" },
{ path = "unit_tests", format = "sdist" },
{ path = "utils", format = "sdist" },
]

[tool.poetry.dependencies]
attrs = "*"
click = "*"
colorama = "*"
Flask = "*"
funcy = "*"
psutil = "*"
pydot = "*"
pyserial = "*"
python = "^3.8"
tornado = "*"

# dev extras
black = { version = "*", optional = true }
flake8 = { version = "*", optional = true }
ipaddress = { version = "*", optional = true }
mock = { version = "*", optional = true }
netifaces = { version = "*", optional = true }
pytest = { version = "*", optional = true }
pytest-bdd = { version = "*", optional = true }
pytest-cov = { version = "*", optional = true }
tox = { version = "*", optional = true }
wheel = { version = "*", optional = true }

# docs extras
pygments = { version = ">=2.4.0", optional = true }
sphinx = { version = "*", optional = true }
sphinx_rtd_theme = { version = "*", optional = true }

[tool.poetry.extras]
dev = [
"black",
"flake8",
"ipaddress",
"mock",
"netifaces",
"pygments",
"pytest",
"pytest-bdd",
"pytest-cov",
"sphinx",
"sphinx_rtd_theme",
"tox",
"wheel",
]
docs = [
"sphinx",
"sphinx_rtd_theme",
"pygments",
]

[tool.poetry.scripts]
boo = 'boofuzz.cli:main'

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 120

[tool.pytest.ini_options]
testpaths = ["unit_tests"]
filterwarnings = [
"ignore:SocketConnection is deprecated:FutureWarning",
]

[tool.pytype]
disable = [
"import-error",
]
exclude = [
"**/ida_fuzz_library_extender.py",
"examples/*.py",
"**/*_test_*.py",
"request_definitions/*.py",
"utils/*.py",
]
20 changes: 0 additions & 20 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
[easy_install]
zip_ok = False

[zest.releaser]
python-file-with-version = boofuzz/__init__.py

[flake8]
ignore = F403, F405, W503, E203
per-file-ignores = utils/ida_fuzz_library_extender.py:F821
max-complexity = 15
max-line-length = 120
extend-exclude = env,venv,.env,.venv

[tool:pytest]
testpaths = unit_tests
filterwarnings =
ignore:SocketConnection is deprecated:FutureWarning

[pytype]
disable =
import-error
exclude =
**/ida_fuzz_library_extender.py
examples/*.py
request_definitions/*.py
utils/*.py

[coverage:run]
source = ./boofuzz
Loading

0 comments on commit c2facda

Please sign in to comment.