Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Prospector cannot run if the current user cannot read all directories in the workdir #487

Closed
carlio opened this issue Feb 25, 2022 · 1 comment
Assignees
Labels

Comments

@carlio
Copy link
Member

carlio commented Feb 25, 2022

Prospector cannot run if a directory not owned by the current user is in the working directory or a subdirectory

This can happen if a docker volume is in the current working directory, for example.

To reproduce:

$ sudo mkdir root-owned
$ sudo chmod 700 root-owned/
$ prospector
Traceback (most recent call last):
  File "/tmp/test/venv/bin/prospector", line 8, in <module>
    sys.exit(main())
  File "/tmp/test/venv/lib/python3.9/site-packages/prospector/run.py", line 173, in main
    config = ProspectorConfig()
  File "/tmp/test/venv/lib/python3.9/site-packages/prospector/config/__init__.py", line 30, in __init__
    self.libraries = self._find_used_libraries(self.config, self.profile)
  File "/tmp/test/venv/lib/python3.9/site-packages/prospector/config/__init__.py", line 169, in _find_used_libraries
    for found_dep in autodetect_libraries(self.workdir):
  File "/tmp/test/venv/lib/python3.9/site-packages/prospector/autodetect.py", line 93, in autodetect_libraries
    libraries = find_from_path(path)
  File "/tmp/test/venv/lib/python3.9/site-packages/prospector/autodetect.py", line 51, in find_from_path
    names |= find_from_path(item_path)
  File "/tmp/test/venv/lib/python3.9/site-packages/prospector/autodetect.py", line 46, in find_from_path
    for item in os.listdir(path):
PermissionError: [Errno 13] Permission denied: '/tmp/test/root-owned'

Autodetection and also finding python files breaks. Directories which are not readable should be either skipped, or a warning issued, and if specified in the --ignore-paths command line, should be ignored before trying to inspect them.

@carlio carlio changed the title [BUG] Prospector cannot run if a directory not owned by the current user is in the working directory or a subdirectory [BUG] Prospector cannot run if the current user cannot read all directories in the workdir Feb 25, 2022
@carlio carlio self-assigned this Feb 25, 2022
carlio added a commit that referenced this issue Feb 27, 2022
…skip it if it is in the list of ignored paths)
@carlio
Copy link
Member Author

carlio commented Feb 27, 2022

Fixed in 1.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant