Package: python3-shodan Version: 1.31.0-2 Severity: critical Tags: patch
Dear maintainer, the `shodan` command fails at startup, regardless of arguments: ``` $ shodan Traceback (most recent call last): File "/usr/bin/shodan", line 33, in <module>sys.exit(load_entry_point('shodan==1.31.0', 'console_scripts', 'shodan')()) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/shodan", line 25, in importlib_load_entry_point
return next(matches).load()
~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.14/importlib/metadata/__init__.py", line 179,
in load
module = import_module(match.group('module'))
File "/usr/lib/python3.14/importlib/__init__.py", line 88, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1406, in _gcd_import
File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
File "<frozen importlib._bootstrap>", line 1342, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 938, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 763, in exec_moduleFile "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed File "/usr/lib/python3/dist-packages/shodan/__main__.py", line 33, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
```
Expected behaviour:
`shodan` prints its usage; `shodan version` prints 1.31.0.
Cause:
shodan/__main__.py imports pkg_resources for plugin discovery and for
get_distribution().version`. src:setuptools >= 81 no longer builds
python3-pkg-resources (python3-setuptools 84.2.0-1 is in testing/
unstable breaking python3-pkg-resources which has been removed from
testing). python3-shodan also does not declare dependency on
python3-pkg-resources or python3-setuptools, so it only worked when
either package happened to be installed.
Suggested fixes Upstream: The issue is reported upstream and has open pull requests (https://github.com/achillean/shodan-python/pull/248, https://github.com/achillean/shodan-python/pull/253). The last upstream commit is from December 2023, so a downstream patch seems necessary for now. Proposed Patch:The attached patch (to be applied after pr241-click-plugins.patch) replaces pkg_resources with importlib.metadata. Plugin discovery passes the group name to the vendored with_plugins(), which already resolves it
via importlib.metadata.entry_points().Reproduced on Kali rolling, which ships this package unmodified from Debian SID.
Kernel version:Linux 0trust 7.1.5+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 7.1.5-1kali1 (2026-07-29) x86_64 GNU/Linux
Shared C library: -rwxr-xr-x 1 root root 2317000 Oct 3 15:48 /lib/i386-linux-gnu/libc.so.6 -rwxr-xr-x 1 root root 2014248 Oct 3 15:48 /lib/x86_64-linux-gnu/libc.so.6
Description: Replace pkg_resources with importlib.metadata pkg_resources was removed from setuptools (>= 81), which causes the shodan CLI to fail with "ModuleNotFoundError: No module named 'pkg_resources'". Instead use importlib.metadata for the version lookup and pass the entry point group name to with_plugins(), which already resolves it via importlib.metadata.entry_points(). Author: Thomas Zink <[email protected]> --- a/shodan/__main__.py +++ b/shodan/__main__.py @@ -30,7 +30,6 @@ import csv import os import os.path -import pkg_resources import shodan import shodan.helpers as helpers import threading @@ -48,9 +47,6 @@ from shodan.cli.helpers import async_spinner, get_api_key, escape_data, timestr, open_streaming_file, get_banner_field, match_filters from shodan.cli.host import HOST_PRINT -# Allow 3rd-parties to develop custom commands -from pkg_resources import iter_entry_points - # Large subcommands are stored in separate modules from shodan.cli.alert import alert from shodan.cli.data import data @@ -58,6 +54,7 @@ from shodan.cli.scan import scan from shodan.click_plugins import with_plugins +from importlib.metadata import version as distribution_version # Make "-h" work like "--help" CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) @@ -78,7 +75,7 @@ # Define the main entry point for all of our commands # and expose a way for 3rd-party plugins to tie into the Shodan CLI. -@with_plugins(iter_entry_points('shodan.cli.plugins')) +@with_plugins('shodan.cli.plugins') @click.group(context_settings=CONTEXT_SETTINGS) def main(): pass @@ -942,8 +939,7 @@ @main.command() def version(): """Print version of this tool.""" - print(pkg_resources.get_distribution("shodan").version) - + print(distribution_version("shodan")) if __name__ == '__main__': main()
smime.p7s
Description: S/MIME Cryptographic Signature

