fix(global): transform with-nth with fzf>= 0.69#2593
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 an issue related to Highlights
Changelog
ActivityUsing 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. 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
|
There was a problem hiding this comment.
Code Review
This pull request fixes the global picker to correctly handle with-nth transformations for fzf versions 0.69 and newer. However, the implementation is vulnerable to Action Injection because the with-nth value is concatenated into the fzf action string without sanitization, potentially allowing arbitrary shell command execution via fzf's execute action. Additionally, a potential bug exists where an unavailable sub-picker could lead to a runtime error.
| local picker_opts = config.normalize_opts(t.opts, name:gsub("^lsp_", "lsp.")) | ||
| if not utils.map_get(def, "opts.fzf_opts") then utils.map_set(def, "opts.fzf_opts", {}) end | ||
| def.opts.fzf_opts = vim.tbl_deep_extend("force", def.opts.fzf_opts, picker_opts.fzf_opts) |
There was a problem hiding this comment.
This logic has a potential issue. If gen_def returns opts = nil (e.g., for an unavailable picker like tags when no tags file is found), def.opts will be nil.
Line 198 will then create a partial def.opts table: def.opts = { fzf_opts = {} }. When this picker is later selected, opts.__alt_opts will be set to this partial table, which will likely cause errors in actions that expect a full options table (e.g., missing cwd).
While the global picker configuration tries to provide fallbacks, it's not guaranteed that a fallback is always available. If an unavailable picker makes it into the list, this will cause a runtime error later when new_picker.contents is accessed (as it would be nil).
A safer approach would be to only perform this logic if def.opts is not nil.
if def.opts then
local picker_opts = config.normalize_opts(t.opts, name:gsub("^lsp_", "lsp."))
def.opts.fzf_opts = vim.tbl_deep_extend("force", def.opts.fzf_opts or {}, picker_opts.fzf_opts)
end
| if utils.has(opts, "fzf", { 0, 69 }) then | ||
| -- `false|nil` defaults to all fields (..) | ||
| local with_nth = utils.map_get(new_picker, "opts.fzf_opts.--with-nth") | ||
| reload = reload .. string.format("change-with-nth(%s)+", with_nth or "..") |
There was a problem hiding this comment.
The reload string for fzf's transform action is constructed by concatenating the --with-nth option without proper sanitization. If an attacker can influence the picker's configuration (e.g., via malicious options passed through a script or a shared configuration), they can inject arbitrary fzf actions. For example, a value like 1)+execute(ls) for with-nth would result in the execution of the ls command by fzf. This is an Action Injection vulnerability that leads to arbitrary command execution.
fix #2515