diff --git a/pkgs/by-name/ro/routersploit/package.nix b/pkgs/by-name/ro/routersploit/package.nix index 32d8cc7bfe1c..42d174baf7cc 100644 --- a/pkgs/by-name/ro/routersploit/package.nix +++ b/pkgs/by-name/ro/routersploit/package.nix @@ -1,36 +1,35 @@ { lib, + stdenv, fetchFromGitHub, python3, }: - -let - version = "3.4.7"; -in -python3.pkgs.buildPythonApplication { +python3.pkgs.buildPythonApplication (finalAttrs: { pname = "routersploit"; - inherit version; + version = "3.4.7"; pyproject = true; src = fetchFromGitHub { owner = "threat9"; repo = "routersploit"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-10NBSY/mYjOWoz2XCJ1UvXUIYUW4csRJHHtDlWMO420="; }; build-system = with python3.pkgs; [ setuptools ]; - dependencies = with python3.pkgs; [ - paramiko - pycryptodome - pysnmp - requests - setuptools - ]; - - # Tests are out-dated and support for newer pysnmp is not implemented yet - doCheck = false; + dependencies = + with python3.pkgs; + [ + paramiko + pycryptodome + pysnmp + requests + setuptools + ] + ++ lib.optionals (pythonAtLeast "3.13") [ + standard-telnetlib + ]; nativeCheckInputs = with python3.pkgs; [ pytest-xdist @@ -51,9 +50,31 @@ python3.pkgs.buildPythonApplication { "tests/test_module_info.py" ]; + disabledTests = [ + # AttributeError: module 'paramiko' has no attribute 'DSSKey'. + "test_exploit_empty_response" + "test_exploit_error_response" + "test_exploit_not_found_response" + "test_exploit_redirect_response" + "test_exploit_trash_response" + + # Runs substantially slower, making this test flaky + "test_exploit_timeout_response" + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # port conflict when running simultaneous builds + "test_http_scenario_service_empty_response" + "test_http_scenario_service_error" + "test_http_scenario_service_found" + "test_http_scenario_service_not_found" + "test_http_scenario_service_redirect" + "test_http_scenario_service_trash" + ]; + meta = { description = "Exploitation Framework for Embedded Devices"; homepage = "https://github.com/threat9/routersploit"; + changelog = "https://github.com/threat9/routersploit/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.bsd3; maintainers = with lib.maintainers; [ fab @@ -61,4 +82,4 @@ python3.pkgs.buildPythonApplication { ]; mainProgram = "rsf"; }; -} +}) diff --git a/pkgs/development/python-modules/threat9-test-bed/asyncio-loop.patch b/pkgs/development/python-modules/threat9-test-bed/asyncio-loop.patch new file mode 100644 index 000000000000..2d2687bfcce4 --- /dev/null +++ b/pkgs/development/python-modules/threat9-test-bed/asyncio-loop.patch @@ -0,0 +1,18 @@ +diff --git a/threat9_test_bed/telnet_service/telnet_server.py b/threat9_test_bed/telnet_service/telnet_server.py +index 7d29e8f..77f5e48 100644 +--- a/threat9_test_bed/telnet_service/telnet_server.py ++++ b/threat9_test_bed/telnet_service/telnet_server.py +@@ -6,8 +6,11 @@ logger = logging.getLogger(__name__) + + class TelnetServer: + def __init__(self, host: str, port: int, protocol): +- self.loop = asyncio.get_event_loop() +- ++ try: ++ self.loop = asyncio.get_running_loop() ++ except RuntimeError: ++ self.loop = asyncio.new_event_loop() ++ asyncio.set_event_loop(self.loop) + coro = self.loop.create_server(protocol, host, port) + self.server = self.loop.run_until_complete(coro) + diff --git a/pkgs/development/python-modules/threat9-test-bed/default.nix b/pkgs/development/python-modules/threat9-test-bed/default.nix index 32afef3b0aac..c9f4701ea23a 100644 --- a/pkgs/development/python-modules/threat9-test-bed/default.nix +++ b/pkgs/development/python-modules/threat9-test-bed/default.nix @@ -26,6 +26,8 @@ buildPythonPackage rec { hash = "sha256-0YSjMf2gDdrvkDaT77iwfCkiDDXKHnZyI8d7JmBSuCg="; }; + patches = [ ./asyncio-loop.patch ]; + build-system = [ setuptools-scm ]; dependencies = [