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

properly escape . in host -> ssh conversion#421

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
Merged
Show file tree
Hide file tree
Changes fromall commits
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
2 changes: 2 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,8 @@

## Unreleased

- Fix bug where checking for overridden properties incorrectly converted host name pattern to regular expression.

## [v1.3.9](https://github.com/coder/vscode-coder/releases/tag/v1.3.9) (2024-12-12)

- Only show a login failure dialog for explicit logins (and not autologins).
Expand Down
36 changes: 36 additions & 0 deletionssrc/sshSupport.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,3 +68,39 @@ Host coder-v?code--*
ProxyCommand: '/tmp/coder --header="X-BAR=foo" coder.dev',
})
})

it("properly escapes meaningful regex characters", () => {
const properties = computeSSHProperties(
"coder-vscode.dev.coder.com--matalfi--dogfood",
`Host *
StrictHostKeyChecking yes

# ------------START-CODER-----------
# This section is managed by coder. DO NOT EDIT.
#
# You should not hand-edit this section unless you are removing it, all
# changes will be lost when running "coder config-ssh".
#
Host coder.*
StrictHostKeyChecking=no
UserKnownHostsFile=/dev/null
ProxyCommand /usr/local/bin/coder --global-config "/Users/matifali/Library/Application Support/coderv2" ssh --stdio --ssh-host-prefix coder. %h
# ------------END-CODER------------

# --- START CODER VSCODE dev.coder.com ---
Host coder-vscode.dev.coder.com--*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
ProxyCommand "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/dev.coder.com/bin/coder-darwin-arm64" vscodessh --network-info-dir "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/net" --session-token-file "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/dev.coder.com/session" --url-file "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/dev.coder.com/url" %h
# --- END CODER VSCODE dev.coder.com ---%

`,
)

expect(properties).toEqual({
StrictHostKeyChecking: "yes",
ProxyCommand:
'"/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/dev.coder.com/bin/coder-darwin-arm64" vscodessh --network-info-dir "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/net" --session-token-file "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/dev.coder.com/session" --url-file "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/dev.coder.com/url" %h',
UserKnownHostsFile: "/dev/null",
})
})
5 changes: 4 additions & 1 deletionsrc/sshSupport.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,8 +85,11 @@ export function computeSSHProperties(host: string, config: string): Record<strin
if (!config) {
return
}

// In OpenSSH * matches any number of characters and ? matches exactly one.
if (!new RegExp("^" + config?.Host.replace(/\*/g, ".*").replace(/\?/g, ".") + "$").test(host)) {
if (
!new RegExp("^" + config?.Host.replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".") + "$").test(host)
) {
return
}
Object.assign(merged, config.properties)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp