-
Notifications
You must be signed in to change notification settings - Fork 545
fix(gsutil): Add graceful error handling for missing gsutil #4833
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
Conversation
Hey! @terriko, |
def find_gsutil(): | ||
gsutil_path = shutil.which("gsutil") | ||
if gsutil_path is None: | ||
gsutil_path = f"{sys.prefix}/bin/gsutil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I've been debating the security implications of this one. I think adding a possible new path that the user hasn't set themselves is probably incorrect behaviour, even if in this case the path is probably not actually a problem and likely was already in the user's path options. Can you rework this so we're not adding to the search options beyond what shutil.which
is going to find using the user's existing path settings?
Realized I could resolve my concern via the web interface, so I've done that and the tests will now re-run. |
ok! let me know if anything is required from my side, I would be happy to help! |
Tests are re-running, but I think we're ready if they pass! |
i've fixed the flake8 (which was failing along with html network one), I think it should be fine now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're ready to merge this one. Thank you for your patience!
Description
Fixes #4220
This PR improves error handling in
osv_source.py
by catchingFileNotFoundError
whengsutil
is not found. Instead of failing with a cryptic error, the code now provides a user-friendly message prompting users to check their environment setup.Changes Made
find_gsutil()
function to check forgsutil
usingshutil.which()
.gsutil
is not found in thePATH
, the function checks undersys.prefix/bin/gsutil
.FileNotFoundError
is raised with a clear message."gsutil"
calls withgsutil_path
from the helper function.Why This Change?
cve-bin-tool
without activating their virtual environment were facing an unclear error (FileNotFoundError: [Errno 2] No such file or directory: 'gsutil'
).PATH
.