prospector icon indicating copy to clipboard operation
prospector copied to clipboard

[BUG] macOS/darwin prospector tries to walk into restricted directories

Open kittydoor opened this issue 3 years ago • 0 comments

Describe the bug On MacOS Monterey, when running prospector from within a directory containing a project, everything works as expected. However, when run from the home directory and given a path to a project (e.g. prospector ~/bin/myscript.py) it tries to walk the filesystem, attempting to go into locations such as ~/Library/Application Support/CallHistoryTransactions.

This both takes too long (tested it, and it's taking forever), and also requires the terminal application to have Full Disk Access (so far in my experience nothing else required this, and it is quite obscure).

To Reproduce Steps to reproduce the behavior on MacOS Mojave, on a terminal without FDA:

  1. Go to '~/'
  2. Call prospector the following way 'prospector ~/path/to/myscript.py'
  3. See error
prospector ~/bin/myscript.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/prospector/autodetect.py", line 48, in find_from_path
    dirlist = os.listdir(path)
PermissionError: [Errno 1] Operation not permitted: '/Users/USERNAME/Library/Application Support/CallHistoryTransactions'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/prospector", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/prospector/run.py", line 192, in main
    config = ProspectorConfig()
  File "/usr/local/lib/python3.10/site-packages/prospector/config/__init__.py", line 31, in __init__
    self.libraries = self._find_used_libraries(self.config, self.profile)
  File "/usr/local/lib/python3.10/site-packages/prospector/config/__init__.py", line 184, in _find_used_libraries
    for found_dep in autodetect_libraries(self.workdir):
  File "/usr/local/lib/python3.10/site-packages/prospector/autodetect.py", line 97, in autodetect_libraries
    libraries = find_from_path(path)
  File "/usr/local/lib/python3.10/site-packages/prospector/autodetect.py", line 57, in find_from_path
    names |= find_from_path(item_path)
  File "/usr/local/lib/python3.10/site-packages/prospector/autodetect.py", line 57, in find_from_path
    names |= find_from_path(item_path)
  File "/usr/local/lib/python3.10/site-packages/prospector/autodetect.py", line 57, in find_from_path
    names |= find_from_path(item_path)
  File "/usr/local/lib/python3.10/site-packages/prospector/autodetect.py", line 50, in find_from_path
    raise PermissionMissing(path) from err
prospector.exceptions.PermissionMissing: The current user USERNAME does not have permission to open directory /Users/USERNAME/Library/Application Support/CallHistoryTransactions. Either fix permissions or tell prospector to skip it by adding this path to `--ignore-paths` on the commandline or in `ignore-paths` in the prospector profile (see https://prospector.landscape.io/en/master/profiles.html#ignoring-paths-and-patterns)

Expected behavior Prospector should be skipping some known directories in the FS tree, such as Application Support, or better, should not arbitrarily walk the FS when run from ~/. Perhaps it should only start walking from the paths given (if multiple, start from all and merge?).

Environment (please complete the following information):

  • OS: macOS
  • Prospector version 1.1.7
  • Python version 3.10.5

Additional context

$ pip3 freeze
astroid==2.11.7
dill==0.3.5.1
dodgy==0.2.1
flake8==4.0.1
flake8-polyfill==1.0.2
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.6.1
pep8-naming==0.10.0
platformdirs==2.5.2
prospector==1.7.7
pycodestyle==2.8.0
pydocstyle==6.1.1
pyflakes==2.4.0
pylint==2.14.5
pylint-celery==0.3
pylint-django==2.5.3
pylint-flask==0.6
pylint-plugin-utils==0.7
PyYAML==6.0
requirements-detector==0.7
setoptconf-tmp==0.3.1
six==1.16.0
snowballstemmer==2.2.0
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.1
wrapt==1.14.1

kittydoor avatar Jul 27 '22 11:07 kittydoor