Skip to content

feat: --nvim-cmd, --enable-automap-ports, and --ssh-arg - #37

Merged
mikew merged 5 commits into
mainfrom
new-branch-1754235386
Aug 4, 2025
Merged

feat: --nvim-cmd, --enable-automap-ports, and --ssh-arg#37
mikew merged 5 commits into
mainfrom
new-branch-1754235386

Conversation

@mikew

@mikew mikew commented Aug 3, 2025

Copy link
Copy Markdown
Owner

Closes #36

@mikew mikew changed the title feat: --nvim-cmd and --ssh-arg feat: --nvim-cmd, --enable-automap-ports, and --ssh-arg Aug 4, 2025
@mikew
mikew requested a review from Copilot August 4, 2025 22:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds three new command-line flags to enhance SSH connectivity and Neovim command customization: --nvim-cmd for specifying custom Neovim commands, --enable-automap-ports for controlling automatic port mapping, and --ssh-arg for passing additional SSH arguments.

Key changes include:

  • Added support for custom SSH arguments and Neovim command specification
  • Made automatic port mapping configurable through a new flag
  • Enhanced SSH command construction with proper argument separation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/context/main.go Added new context fields for AutomapPorts, SshArgs, and NvimCmd
src/client/main.go Implemented CLI flags and conditional port mapping logic
src/nvim_helpers/main.go Modified remote command building to use configurable Neovim command
src/nvrh_binary_ssh/main.go Enhanced SSH argument handling with proper command separation
README.md Updated documentation with new command options

Comment on lines +27 to +28
if c.Ctx.SshArgs != nil && len(c.Ctx.SshArgs) > 0 {
args = append(args, c.Ctx.SshArgs...)

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

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

Adding the -- separator is good for security, but the SSH arguments are inserted before the endpoint which could allow argument injection. Consider validating SSH arguments or placing them after the endpoint to prevent potential command injection.

Suggested change
if c.Ctx.SshArgs != nil && len(c.Ctx.SshArgs) > 0 {
args = append(args, c.Ctx.SshArgs...)
// Validate SSH arguments to prevent argument injection
if c.Ctx.SshArgs != nil && len(c.Ctx.SshArgs) > 0 {
validArgs := validateSshArgs(c.Ctx.SshArgs)
args = append(args, validArgs...)

Copilot uses AI. Check for mistakes.
Comment thread src/client/main.go
Name: "enable-automap-ports",
Usage: "Enable automatic port mapping",
EnvVars: []string{"NVRH_CLIENT_AUTOMAP_PORTS"},
Value: true,

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The default value of true for enable-automap-ports could be surprising to users since it enables potentially resource-intensive functionality by default. Consider defaulting to false for safer behavior.

Suggested change
Value: true,
Value: false,

Copilot uses AI. Check for mistakes.
Comment thread src/nvim_helpers/main.go
envPairsString = strings.Join(nvrhContext.RemoteEnv, " ")
}

nvimCmd := strings.Join(nvrhContext.NvimCmd, " ")

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

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

Joining command arguments with spaces without proper escaping could lead to command injection if the arguments contain special characters. Consider using proper shell escaping or validation for the NvimCmd arguments.

Copilot uses AI. Check for mistakes.
@mikew
mikew merged commit ea961c3 into main Aug 4, 2025
2 checks passed
@mikew
mikew deleted the new-branch-1754235386 branch August 4, 2025 22:47
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.

Custom nvim command

2 participants