Skip to content

Add implementation for setting to disable Github extensions#12838

Merged
kevinjwang1 merged 9 commits intogoogle-gemini:mainfrom
kevinjwang1:disableGithubExtension
Nov 11, 2025
Merged

Add implementation for setting to disable Github extensions#12838
kevinjwang1 merged 9 commits intogoogle-gemini:mainfrom
kevinjwang1:disableGithubExtension

Conversation

@kevinjwang1
Copy link
Copy Markdown
Contributor

Summary

Add a new setting to disable installing and loading extensions from github.

Details

Uses the install metadata to check if a installed extension is from local or remote sources. Rejects installing the extension if its from a remote source. If a remote extension is already installed, the extension manager will reject loading that extension.

Related Issues

Resolves #12557

@kevinjwang1 kevinjwang1 requested a review from a team as a code owner November 10, 2025 18:16
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kevinjwang1, 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 enhances the security posture of the application by introducing a configurable setting that allows users to explicitly disable the installation and loading of extensions originating from remote Git repositories or GitHub releases. This provides greater control over the execution of external code, addressing potential security concerns related to third-party extensions.

Highlights

  • New Security Setting: A new boolean setting, security.blockGithubExtensions, has been introduced to control the installation and loading of extensions from remote sources.
  • Installation Blocking: The extension manager now prevents the installation of extensions sourced from Git repositories or GitHub releases if security.blockGithubExtensions is enabled.
  • Loading Prevention: Existing extensions that were installed from remote Git or GitHub release sources will not be loaded by the extension manager if security.blockGithubExtensions is enabled.
  • Unit Tests: New unit tests have been added to verify that both the installation and loading of remote extensions are correctly blocked when the new security setting is active.
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
Copy Markdown
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 new security setting to block the installation and loading of extensions from GitHub. The implementation correctly adds checks in both the installation and loading paths, and the associated tests and schema changes are appropriate. My review identifies a critical issue where the implementation is overly broad, blocking all git sources instead of just GitHub, which contradicts the feature's description. I've provided suggestions to correct this logic. I also noted that this security check is duplicated and recommended refactoring it into a helper method for better maintainability.

Comment on lines +131 to +139
if (
(installMetadata.type === 'git' ||
installMetadata.type === 'github-release') &&
this.settings.security?.blockGithubExtensions
) {
throw new Error(
'Installing extensions from remote sources is disallowed by your current settings.',
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The current implementation incorrectly blocks all extensions of type git, not just those from GitHub. This contradicts the setting's name (blockGithubExtensions) and description, which specify blocking extensions only from GitHub. A user might want to block public GitHub extensions but still allow installations from a private Git server. The check should be more specific to GitHub sources. I've also updated the error message to be more specific.

Additionally, this security check is duplicated in the loadExtension method. Consider extracting this logic into a private helper method to improve maintainability and reduce risk.

Suggested change
if (
(installMetadata.type === 'git' ||
installMetadata.type === 'github-release') &&
this.settings.security?.blockGithubExtensions
) {
throw new Error(
'Installing extensions from remote sources is disallowed by your current settings.',
);
}
const isGithubSource =
installMetadata.type === 'github-release' ||
(installMetadata.type === 'git' &&
!!tryParseGithubUrl(installMetadata.source));
if (isGithubSource && this.settings.security?.blockGithubExtensions) {
throw new Error(
'Installing extensions from GitHub is disallowed by your current settings.',
);
}

Comment on lines +457 to +463
if (
(installMetadata?.type === 'git' ||
installMetadata?.type === 'github-release') &&
this.settings.security?.blockGithubExtensions
) {
return null;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

Similar to the installOrUpdateExtension method, this check incorrectly blocks all git sources instead of just GitHub sources. This should be updated to specifically check for GitHub URLs.

As mentioned in the other comment, this duplicated logic should be extracted into a shared private helper method to ensure consistency and maintainability of this security feature.

Suggested change
if (
(installMetadata?.type === 'git' ||
installMetadata?.type === 'github-release') &&
this.settings.security?.blockGithubExtensions
) {
return null;
}
const isGithubSource =
installMetadata &&
(installMetadata.type === 'github-release' ||
(installMetadata.type === 'git' &&
!!tryParseGithubUrl(installMetadata.source)));
if (isGithubSource && this.settings.security?.blockGithubExtensions) {
return null;
}

@kevinjwang1 kevinjwang1 added this pull request to the merge queue Nov 11, 2025
Merged via the queue into google-gemini:main with commit b248ec6 Nov 11, 2025
21 checks passed
@kevinjwang1 kevinjwang1 deleted the disableGithubExtension branch November 11, 2025 18:46
danpalmer pushed a commit to danpalmer/gemini-cli that referenced this pull request Nov 29, 2025
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.

Add setting to disable github extensions

2 participants