Skip to content

fix: use shlex.join for safe command construction in snap-preseed plugin#325

Draft
Copilot wants to merge 16 commits intomainfrom
copilot/sub-pr-320-another-one
Draft

fix: use shlex.join for safe command construction in snap-preseed plugin#325
Copilot wants to merge 16 commits intomainfrom
copilot/sub-pr-320-another-one

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

Command construction in get_build_commands mixed manual double-quote wrapping with string concatenation, combining the model assert path and install dir into a single list element — fragile for paths with spaces or shell-special characters.

Changes

  • snap_preseed_plugin.py: Split model assert and install dir into separate cmd list items; replace " ".join(cmd) with shlex.join(cmd) for safe shell quoting
  • test_snap_preseed_plugin.py: Update expected strings to match shlex.join output (empty model assert → ''; model.assert → unquoted)

Before:

cmd.append(f'"{options.snap_preseed_model_assert}" {self._part_info.part_install_dir}')
return [" ".join(cmd)]

After:

cmd.append(options.snap_preseed_model_assert)
cmd.append(str(self._part_info.part_install_dir))
return [shlex.join(cmd)]

Copilot AI changed the title [WIP] [WIP] Address feedback on snap prepare-image plugins PR fix: use shlex.join for safe command construction in snap-preseed plugin Apr 21, 2026
Copilot AI requested a review from lengau April 21, 2026 20:16
Base automatically changed from work/classic-snap-prepare-image-plugin to main April 24, 2026 14:04
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