coder / vscode-coder

Open any Coder workspace in VS Code with a single click.
MIT License
66 stars 15 forks source link

fix: escape variables in the header command #279

Closed davo-canva closed 4 months ago

davo-canva commented 4 months ago

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.

code-asher commented 4 months ago

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