From d2cae0bea4aa58b021e76959e753fcb3befac5bb Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Fri, 2 Jan 2026 09:31:44 -0800 Subject: [PATCH] migrate to flit-core --- Dockerfile | 2 +- bin/restfulHarvest | 44 ++------------------------- bin/theHarvester | 36 +++------------------- pyproject.toml | 20 +++--------- restfulHarvest.py | 5 --- theHarvester.py | 12 -------- theHarvester/__init__.py | 1 + theHarvester/discovery/censysearch.py | 2 +- theHarvester/lib/core.py | 4 +-- theHarvester/lib/version.py | 5 --- 10 files changed, 17 insertions(+), 114 deletions(-) delete mode 100755 restfulHarvest.py delete mode 100755 theHarvester.py delete mode 100644 theHarvester/lib/version.py diff --git a/Dockerfile b/Dockerfile index 46cebc15..7f2dcd9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,4 +22,4 @@ USER theharvester EXPOSE 80 # Run the application as theharvester user -ENTRYPOINT ["python", "restfulHarvest.py", "-H", "0.0.0.0", "-p", "80"] +ENTRYPOINT ["restfulHarvest", "-H", "0.0.0.0", "-p", "80"] diff --git a/bin/restfulHarvest b/bin/restfulHarvest index e7451231..e772df6f 100755 --- a/bin/restfulHarvest +++ b/bin/restfulHarvest @@ -1,43 +1,5 @@ #!/usr/bin/env python3 -import argparse +from theHarvester.restfulHarvest import main -import uvicorn - -parser = argparse.ArgumentParser() -parser.add_argument( - "-H", - "--host", - default="127.0.0.1", - help="IP address to listen on default is 127.0.0.1", -) -parser.add_argument( - "-p", - "--port", - default=5000, - help="Port to bind the web server to, default is 5000", - type=int, -) -parser.add_argument( - "-l", - "--log-level", - default="info", - help="Set logging level, default is info but [critical|error|warning|info|debug|trace] can be set", -) -parser.add_argument( - "-r", - "--reload", - default=False, - help="Enable automatic reload used during development of the api", - action="store_true", -) - -args = parser.parse_args() - -if __name__ == "__main__": - uvicorn.run( - "theHarvester.lib.api.api:app", - host=args.host, - port=args.port, - log_level=args.log_level, - reload=args.reload, - ) +if __name__ == '__main__': + main() diff --git a/bin/theHarvester b/bin/theHarvester index b921606f..7246dad3 100755 --- a/bin/theHarvester +++ b/bin/theHarvester @@ -1,38 +1,12 @@ #!/usr/bin/env python3 # Note: This script runs theHarvester -import asyncio import sys -from theHarvester import __main__ +from theHarvester.theHarvester import main -if sys.version_info.major < 3 or sys.version_info.minor < 11: - print( - "[!] Make sure you have Python 3.11+ installed, quitting.\n\n" - ) +if sys.version_info.major < 3 or sys.version_info.minor < 10: + print('[!] Make sure you have Python 3.10+ installed, quitting.\n\n') sys.exit(1) -if __name__ == "__main__": - platform = sys.platform - if platform == "win32": - # Required or things will break if trying to take screenshots - import multiprocessing - - multiprocessing.freeze_support() - try: - # See if we have winloop as a performance enhancement on windows - import winloop - - asyncio.DefaultEventLoopPolicy = winloop.EventLoopPolicy - except ModuleNotFoundError: - asyncio.DefaultEventLoopPolicy = asyncio.WindowsSelectorEventLoopPolicy - else: - import uvloop - - uvloop.install() - - if "linux" in platform: - import aiomultiprocess - - # As we are not using Windows, we can change the spawn method to fork for greater performance - aiomultiprocess.set_context("fork") - asyncio.run(__main__.entry_point()) +if __name__ == '__main__': + main() diff --git a/pyproject.toml b/pyproject.toml index c2f3586b..c0b4505b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ name = "theHarvester" description = "theHarvester is a very simple, yet effective tool designed to be used in the early stages of a penetration test" readme = "README.md" +license = "GPL-2.0-only" authors = [ { name = "Christian Martorella", email = "cmartorella@edge-security.com" }, { name = "Jay Townsend", email = "jay@cybermon.uk" }, @@ -14,7 +15,6 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: OS Independent", ] dynamic = ["version"] @@ -65,28 +65,16 @@ dev = [ theHarvester = "theHarvester.theHarvester:main" restfulHarvest = "theHarvester.restfulHarvest:main" -[tool.setuptools.dynamic] -version = { attr = "theHarvester.lib.version.VERSION" } - -[tool.setuptools.packages.find] -include = ["theHarvester*"] - -[tool.setuptools.package-data] -"*" = ["*.txt", "*.yaml"] - [tool.pytest.ini_options] minversion = "8.3.3" asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" addopts = "--no-header" -testpaths = [ - "tests", - "tests/discovery/", -] +testpaths = ["tests"] [build-system] -requires = ["setuptools>=68"] -build-backend = "setuptools.build_meta" +requires = ["flit_core >=3.11,<4"] +build-backend = "flit_core.buildapi" [tool.mypy] python_version = "3.13" diff --git a/restfulHarvest.py b/restfulHarvest.py deleted file mode 100755 index e772df6f..00000000 --- a/restfulHarvest.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python3 -from theHarvester.restfulHarvest import main - -if __name__ == '__main__': - main() diff --git a/theHarvester.py b/theHarvester.py deleted file mode 100755 index 7246dad3..00000000 --- a/theHarvester.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -# Note: This script runs theHarvester -import sys - -from theHarvester.theHarvester import main - -if sys.version_info.major < 3 or sys.version_info.minor < 10: - print('[!] Make sure you have Python 3.10+ installed, quitting.\n\n') - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/theHarvester/__init__.py b/theHarvester/__init__.py index e69de29b..8e857387 100644 --- a/theHarvester/__init__.py +++ b/theHarvester/__init__.py @@ -0,0 +1 @@ +__version__ = '4.10.0' diff --git a/theHarvester/discovery/censysearch.py b/theHarvester/discovery/censysearch.py index ff771402..ba915233 100644 --- a/theHarvester/discovery/censysearch.py +++ b/theHarvester/discovery/censysearch.py @@ -5,9 +5,9 @@ from censys.common.exceptions import ( ) from censys.search import CensysCerts +from theHarvester import __version__ as thehavester_version from theHarvester.discovery.constants import MissingKey from theHarvester.lib.core import Core -from theHarvester.lib.version import version as thehavester_version class SearchCensys: diff --git a/theHarvester/lib/core.py b/theHarvester/lib/core.py index 47f5f103..8a4f6f0b 100644 --- a/theHarvester/lib/core.py +++ b/theHarvester/lib/core.py @@ -15,7 +15,7 @@ import ujson as json_loader import yaml from aiohttp_socks import ProxyConnector -from .version import version +from theHarvester import __version__ if TYPE_CHECKING: from collections.abc import Sized @@ -203,7 +203,7 @@ class Core: print(r'* | |_| | | | __/ / __ / (_| | | \ V / __/\__ \ || __/ | *') print(r'* \__|_| |_|\___| \/ /_/ \__,_|_| \_/ \___||___/\__\___|_| *') print('* *') - print('* theHarvester {version}{filler}*'.format(version=version(), filler=' ' * (51 - len(version())))) + print('* theHarvester {version}{filler}*'.format(version=__version__, filler=' ' * (51 - len(__version__)))) print('* Coded by Christian Martorella *') print('* Edge-Security Research *') print('* cmartorella@edge-security.com *') diff --git a/theHarvester/lib/version.py b/theHarvester/lib/version.py deleted file mode 100644 index 74944e29..00000000 --- a/theHarvester/lib/version.py +++ /dev/null @@ -1,5 +0,0 @@ -VERSION = '4.10.0' - - -def version() -> str: - return VERSION