[Fixes #14021] Replace deprecated distutils with shutil and custom strtobool#14081
[Fixes #14021] Replace deprecated distutils with shutil and custom strtobool#14081
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses the deprecation of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the strtobool utility function by moving its implementation from distutils.util to geonode.utils and updating all import paths across the codebase. Additionally, it replaces the deprecated distutils.dir_util.copy_tree with shutil.copytree in the restore.py command. A critical security and stability concern was raised regarding the shutil.copytree operation, as it currently copies external resources directly to the filesystem root, which could lead to data loss or system vulnerabilities.
| external_folder = os.path.join(target_folder, utils.EXTERNAL_ROOT) | ||
| if os.path.exists(external_folder): | ||
| dir_util.copy_tree(external_folder, "/") | ||
| shutil.copytree(external_folder, "/", dirs_exist_ok=True) |
There was a problem hiding this comment.
The change correctly replaces the deprecated distutils.dir_util.copy_tree with shutil.copytree. However, copying the contents of external_folder directly to the root directory (/) is a critical security and stability concern. This operation could overwrite essential system files, lead to data loss, or introduce vulnerabilities if the external_folder contains unexpected or malicious content. It is highly recommended to use a specific, configurable, and secure destination path for external resources, rather than the filesystem root.
| shutil.copytree(external_folder, "/", dirs_exist_ok=True) | |
| # Consider replacing "/" with a configurable and secure destination path for external resources. | |
| shutil.copytree(external_folder, "/path/to/secure/external_resources", dirs_exist_ok=True) |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14081 +/- ##
==========================================
- Coverage 74.58% 74.57% -0.01%
==========================================
Files 951 951
Lines 57245 57255 +10
Branches 7771 7775 +4
==========================================
+ Hits 42694 42700 +6
- Misses 12833 12835 +2
- Partials 1718 1720 +2 🚀 New features to boost your workflow:
|
Fixes #14021
Checklist
For all pull requests:
The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):
Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.