maurosoria / dirsearch

Web path scanner
11.57k stars 2.29k forks source link

Resolve the pkg_resources module warning issue in the dirsearch scanning tool. #1337

Closed dioos886 closed 6 months ago

dioos886 commented 8 months ago

python 3.11 └─$ python dirsearch.py -h
/home/XXX/XX/XXXX/dirsearch-master/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import DistributionNotFound, VersionConflict

Change the code on line 23 of dirsearch.py to the following.

try:
    from importlib import resources as pkg_resources
except ImportError:
    # Fallback for Python versions that don't have importlib.resources
    import pkg_resources

image

xghsyh commented 6 months ago

thank you

shelld3v commented 6 months ago

@dioos886 would you like to submit a pull request?

shelld3v commented 6 months ago

Hi @dioos886, I don't think importlib.resources is the same as pkg_resources:

>>> from importlib.resources import DistributionNotFound, VersionConflict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'DistributionNotFound' from 'importlib.resources' (/usr/lib/python3.11/importlib/resources/__init__.py)
...
>>> from importlib.resources import require
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'require' from 'importlib.resources' (/usr/lib/python3.11/importlib/resources/__init__.py)
exploide commented 1 month ago

@shelld3v the deprecation warning is still present when running dirsearch with Python 3.12. I think this issue should not be closed.

dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import DistributionNotFound, VersionConflict

EDIT: sorry nevermind, seems to be a duplicate of #1321

Jeyaraman-J commented 3 days ago

Thank you