Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Use smarter quoting for ProxyCommand in config-ssh#3755

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 9 commits intomainfrommafredri/fix-coder-configssh-proxycmd-quoting
Aug 30, 2022
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Attempt windows test compat
  • Loading branch information
@mafredri
mafredri committedAug 30, 2022
commit73e6a849d687958343dad55a837bb29ca92b4cf9
15 changes: 13 additions & 2 deletionscli/configssh_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,12 +4,15 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"

"github.com/stretchr/testify/require"
)

// This test tries to mimic the behavior of OpenSSH
// when executing e.g. a ProxyCommand.
func Test_sshConfigExecEscape(t *testing.T) {
t.Parallel()

Expand All@@ -34,7 +37,11 @@ func Test_sshConfigExecEscape(t *testing.T) {
err := os.MkdirAll(dir, 0o755)
require.NoError(t, err)
bin := filepath.Join(dir, "coder")
err = os.WriteFile(bin, []byte("#!/bin/sh\necho yay\n"), 0o755) //nolint:gosec
contents := []byte("#!/bin/sh\necho yay\n")
if runtime.GOOS == "windows" {
contents = []byte("cls\r\n@echo off\r\necho \"yay\"\r\n")
}
err = os.WriteFile(bin, contents, 0o755) //nolint:gosec
require.NoError(t, err)

escaped, err := sshConfigExecEscape(bin)
Expand All@@ -44,7 +51,11 @@ func Test_sshConfigExecEscape(t *testing.T) {
}
require.NoError(t, err)

b, err := exec.Command("/bin/sh", "-c", escaped).Output()
args := []string{"/bin/sh", "-c", escaped}
if runtime.GOOS == "windows" {
args = []string{"cmd.exe", "/c", escaped}
}
b, err := exec.Command(args[0], args[1:]...).Output() //nolint:gosec
require.NoError(t, err)
got := strings.TrimSpace(string(b))
require.Equal(t, "yay", got)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp