Skip to content

fix: escape variables in the header command #279

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

Merged
merged 2 commits into from
May 28, 2024

Conversation

davo-canva
Copy link
Contributor

The documentation for the header command setting says:

The following environment variables will be available to the process: CODER_URL.

However, if the command line itself references $CODER_URL, when connecting via the VSCode extension the variable will get substituted before the coder CLI can set the variable when running the header command, which is contrary to the behaviour of the JetBrains plugin. This is because the VSCode extension is currently writing the header command into the SSH config's ProxyCommand with double quotes, allowing the shell spawned by ssh to substitute $CODER_URL (with the empty string).

This ensures environment variable references within the header command are not substituted before the coder binary can receive them, by using single quotes rather than double quotes in the ProxyCommand.

Tested on a macOS client.

@matifali matifali requested a review from code-asher May 22, 2024 09:37
@code-asher
Copy link
Member

Thank you, and good catch!

I believe we will need to handle Windows differently like we are doing in the JetBrains plugin: https://github.com/coder/jetbrains-coder/blob/main/src/main/kotlin/com/coder/gateway/util/Escape.kt

Copy link
Contributor Author

@davo-canva davo-canva left a comment

Choose a reason for hiding this comment

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

Good call. Fixed, but I don't have a Windows machine to test on.

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@code-asher code-asher merged commit 4fe4aca into coder:main May 28, 2024
2 checks passed
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