Skip to content

Add trust_remote_code for _download_additional_modules#1521

Merged
wangxingjun778 merged 2 commits intomodelscope:masterfrom
wangxingjun778:fix/additional_module
Oct 28, 2025
Merged

Add trust_remote_code for _download_additional_modules#1521
wangxingjun778 merged 2 commits intomodelscope:masterfrom
wangxingjun778:fix/additional_module

Conversation

@wangxingjun778
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wangxingjun778, 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 significantly improves the security posture of the module downloading process by requiring explicit consent for executing remote code. It adds a trust_remote_code flag, which, when set to True, allows the execution of code from external sources, while defaulting to False to protect against unintended code execution. This change provides users with greater control and awareness over the security implications of loading certain modules.

Highlights

  • Enhanced Security for Remote Code Execution: Introduced a new trust_remote_code parameter to the _download_additional_modules function, which explicitly controls whether code from remote repositories can be executed.
  • Explicit Opt-in for Remote Code: By default, remote code execution is disabled. If a module requires executing remote code and trust_remote_code is not set to True, a ValueError will be raised, preventing potential security risks.
  • Parameter Propagation: The trust_remote_code value is now correctly propagated from the DatasetModule instance to the _download_additional_modules utility function.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a trust_remote_code parameter to _download_additional_modules to enhance security by preventing the automatic download and execution of remote code from dataset repositories. This is a valuable security improvement, aligning with best practices seen in similar libraries. The implementation is clean and correctly propagates the trust flag. I have one minor suggestion to improve the consistency of error messages.

@wangxingjun778
Copy link
Collaborator Author

wangxingjun778 commented Oct 11, 2025

Fixes #1520

@wangxingjun778 wangxingjun778 merged commit c1fc7bf into modelscope:master Oct 28, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants