Skip to content

Fix broken symlinks in Poetry installer command#4

Open
bortlicenseplates wants to merge 2 commits intomise-plugins:mainfrom
bortlicenseplates:patch-1
Open

Fix broken symlinks in Poetry installer command#4
bortlicenseplates wants to merge 2 commits intomise-plugins:mainfrom
bortlicenseplates:patch-1

Conversation

@bortlicenseplates
Copy link
Copy Markdown

Updated Poetry installation command to enable symlinks. Fixes issue #3

Updated Poetry installation command to enable symlinks. Fixes issue mise-plugins#3
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @bortlicenseplates, 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 resolves an issue where Poetry installations were encountering broken symlinks. The change modifies the Poetry installation command to ensure that symlinks are correctly enabled during the setup process, thereby fixing compatibility problems and ensuring proper functionality.

Highlights

  • Poetry Installation: The Poetry installation command has been updated to explicitly enable symlinks. This is achieved by piping the installer script through sed to replace symlinks=False with symlinks=True.
Changelog
  • hooks/post_install.lua
    • Modified the Poetry installation command to enable symlinks.
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.

@bortlicenseplates
Copy link
Copy Markdown
Author

@gemini-code-assist review

Copy link
Copy Markdown

@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 aims to fix broken symlinks during Poetry installation by enabling symlinks in the installer. It also addresses a critical issue where the original model response incorrectly returned the schema definition itself, with the properties field at the top level, instead of a valid JSON object conforming to the specified schema. For the symlink fix, the current use of sed to modify the installer script is fragile; a more robust solution would be to leverage the --symlinks flag provided by the installer.

Copy link
Copy Markdown

@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 aims to fix broken symlinks in the Poetry installer. However, the current approach introduces a critical command injection vulnerability. The installation script construction is vulnerable because it concatenates variables into a shell script without proper escaping, specifically using double quotes in hooks/post_install.lua which allows command substitution. A similar, more critical vulnerability exists in hooks/env_keys.lua which could lead to Remote Code Execution (RCE). Additionally, the use of sed to modify the installer script on the fly is brittle and may break with upstream changes. It is recommended to implement robust shell escaping for all variables in shell commands and consider more stable methods for enabling symlinks.

Copy link
Copy Markdown

@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 aims to fix an issue with broken symlinks during Poetry installation by patching the installer script on the fly using sed. However, the modified line introduces a critical command injection vulnerability where user-controlled variables (installation path and version) are injected into a shell script without proper escaping. This sed patching approach is also inherently fragile and could break if the upstream installer script changes. Furthermore, similar critical command injection vulnerabilities were identified in hooks/env_keys.lua (via the pyproject option) and other parts of hooks/post_install.lua (via os.execute calls) that should be addressed to ensure the overall security of the plugin.


# Run the Poetry installer
curl -sSL https://install.python-poetry.org | POETRY_HOME="%s" python3 - --version "%s"
curl -sSL https://install.python-poetry.org | sed 's/symlinks=False/symlinks=True/' | POETRY_HOME="%s" python3 - --version "%s"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-critical critical

This line is vulnerable to critical command injection. The install_path and version variables are injected into a bash script using string.format without proper shell escaping. If an attacker can control the version string or if the installation path contains shell metacharacters, they can execute arbitrary commands. It is highly recommended to sanitize these variables or use a robust shell-escaping mechanism. Additionally, the sed patching approach is brittle and could fail silently if the upstream install.python-poetry.org script changes its format. Consider improving the sed command to be more flexible with whitespace and adding an explanatory comment acknowledging its fragility.

# Patch installer to enable symlinks (https://github.com/mise-plugins/vfox-poetry/issues/3)
# This is fragile and may break if the installer script changes.
curl -sSL https://install.python-poetry.org | sed -E 's/symlinks[[:space:]]*=[[:space:]]*False/symlinks=True/' | POETRY_HOME="%s" python3 - --version "%s"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The external dependency is already likely to break. Putting pressure on the poetry-install maintainers to fix this issue python-poetry/install.python-poetry.org#24 is probably the "right" solution. Forking and patching the script could also work, but that's a lot more work to maintain. IMO until python-poetry/install.python-poetry.org#24 is fixed, this is the correct solution.

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.

1 participant