Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SH Command: add support for local port forwarding #37

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

GGonryun
Copy link
Contributor

@GGonryun GGonryun commented Feb 24, 2024

This PR introduces support for port forwarding to our SSH command. Yargs does not expose an "example" parameter that can be used to show the optimal format for the -L argument, so instead I added a small example in the description portion of the option.

image

Example usage: p0 ssh <instance> -L <local_socket>:<remote_socket>

An empty -L argument such as p0 ssh <instance> -L is treated as an error. An incorrectly formatted argument returns an error:

Local port forward should be in the format `local_port:remote_port`

A separate ticket was created to support using an interactive command and port forwarding at the same time:

Currently an error message is displayed: https://linear.app/p0-security/issue/ENG-1653/p0-cli-ssh-support-executing-commands-with-port-forwarding

Invalid arguments. Specify either a command or port forwarding, not both.

A separate ticket was created to display an error if the user attempts to open a port that is not allowed locally: https://linear.app/p0-security/issue/ENG-1654/show-an-error-if-invalid-local-port-is-selected-when-port-forwarding

Copy link

linear bot commented Feb 24, 2024

@GGonryun GGonryun self-assigned this Feb 24, 2024
@GGonryun GGonryun marked this pull request as ready for review February 24, 2024 01:38
Copy link
Contributor

@nbrahms nbrahms left a comment

Choose a reason for hiding this comment

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

Probably good as a first iteration; but I think we also need to support running a command / opening a shell AND port forwarding at the same time.

src/commands/ssh.ts Outdated Show resolved Hide resolved
src/plugins/aws/ssm.ts Outdated Show resolved Hide resolved
src/plugins/aws/ssm.ts Outdated Show resolved Hide resolved
@GGonryun GGonryun force-pushed the miguelcampos/eng-1594-support-port-forwarding branch from 44aebc2 to 0ce2b44 Compare February 26, 2024 23:30
@GGonryun GGonryun merged commit 62a6769 into main Feb 26, 2024
3 checks passed
@GGonryun GGonryun deleted the miguelcampos/eng-1594-support-port-forwarding branch February 26, 2024 23:38
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.

2 participants