You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ssh): read single-quoted and escaped-space SSH config paths like OpenSSH - #50976
Your ~/.ssh/config tells your computer how to reach other machines. Paths in it can contain spaces if you wrap them in quotes or put a backslash before the space. Orca read some of those lines differently from the real ssh program, so it could miss hosts or point at the wrong key file. Now Orca reads the file the same way ssh does, so the host list and key paths match what actually works.
What Changed
Before:
Include '~/.ssh/my configs/a' (single quotes) and Include ~/.ssh/my\ configs/b (escaped space) loaded no hosts.
Host 'quoted-key' was imported as the alias 'quoted-key', quotes included.
IdentityFile '/keys/my key' came out as '/keys/my.
Host team#1 was cut down to team, because any # started a comment.
After: all of these resolve the same way ssh -G resolves them.
Mechanism:
There were two tokenizers. splitOpenSshArguments in ssh-config-parser.ts only knew " quotes. splitQuotedArguments in ssh-config-include-expander.ts also only knew ", and it ignored \ , \\ and \'.
Both are replaced by one shared splitOpenSshArguments in the new src/main/ssh/config/ssh-config-arguments.ts, modeled on OpenSSH argv_split (misc.c, called from readconf.c). '...' and "..." both quote. \\, \", \' and unquoted \ are escapes. Any other backslash stays literal, so Windows paths are unchanged (fix(ssh): preserve literal backslashes in quoted SSH config paths #50411). An unquoted # starts a comment only at the start of a token, so Host team#1 and Include ~/.ssh/t#1 keep their #.
The shared function lives in its own file because the parser already imports the Include expander.
Why
Follow-up to #50411, which aligned backslash handling with argv_split but left out single quotes and the second tokenizer. With one shared tokenizer, Include lines can't drift from the other directives again. ssh-g-config-resolution.ts's splitIncludeArguments is intentionally left alone. It has a different contract: it returns null when it is unsure.
N/A. This is a config-parser change, and the only visible effect is which SSH hosts and key paths Orca imports. The before/after parser output is in Testing below.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
The new case in ssh-config-loader.test.ts covers a single-quoted Include, an escaped-space Include, a single-quoted Host and IdentityFile that contain ", and team#1 followed by a trailing # comment.
On main it fails, and the other 8 cases pass. Main returns host 'quoted-key' and IdentityFile '/keys/my, cuts team#1 down to team, and loses both included hosts.
With this change it passes 9/9. All of src/main/ssh/ passes (12 files, 49 tests).
Ran real ssh -G -F (OpenSSH_10.5p1, macOS) on scratch configs: the Include spellings, Host 'quoted-key' x#y, and IdentityFile edge cases (a'b, f#g, h\ i, C:\keys\l, #x). The parser matches ssh in every case.
Ran a differential fuzz of about 160k random strings against a JS port of argv_split. The only mismatch is an empty quote right before # (""#x), which also diverges on main.
The original author also tested on Windows 10 with OpenSSH_for_Windows 9.5p1 and Git's OpenSSH 10.0p2.
oxlint, oxfmt --check, the anti-slop and native-plugin oxlint configs, ast-grep, and the changed-code quality gate are all clean on the touched files.
Performance
None, because the tokenizer still makes a single pass over each line, with no new I/O, subprocess or polling. It runs in the main process only when the SSH config loads (host picker, import or reconcile, and alias claims behind a 5 s TTL cache). Median of 3 runs of parseSshConfig, main vs this PR:
typical 60-host config: 0.131 vs 0.133 ms
20k hosts: 28.3 vs 27.4 ms
one 200k-pattern Host line: 36.3 vs 35.7 ms
quote-heavy config: 10.0 vs 8.3 ms
Risk
Level: Low
An unescaped ' in a config value is now a quote and a # inside a token is now literal, as in OpenSSH. A config that relied on the old reading was already read differently by ssh itself.
If Orca previously imported a host under a wrong alias ('foo', or team from team#1), the next reconcile adds the correctly named host once. The old entry stays until the user deletes it.
Hosts from single-quoted or escaped-space Include files now appear.
ProxyCommand keeps its raw text, as before.
To back it out, revert this commit.
Review
Original fix by @Pr1p in #50976. The maintainer follow-up adds the token-boundary # handling and its test.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
This parsing change behaves the same on every platform: OpenSSH tokenizes identically on every OS, and Windows backslash path separators stay literal.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
No actionable comments were generated in the recent review.
Walkthrough
The change adds splitOpenSshArguments and uses it to parse SSH config scalar values, host patterns, and Include arguments. The parser handles quoted text, selected escapes, unquoted comments, and whitespace. A loader test covers single-quoted and escaped-space Include paths, a single-quoted host pattern, and a single-quoted identity path containing double quotes.
Severity of issue fixed: Medium
Merge Risk: Minimal · up to 8e85e
SSH config parsing now follows OpenSSH for single-quoted values and escaped-space Include paths, and a # inside a path no longer truncates it. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: SSH config parsing of single-quoted paths and escaped-space paths now follows OpenSSH. It matches the changeset, which adds a shared splitOpenSshArguments tokenizer th…
Description check
The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #50975), Visual Proof (N/A with reason), Testing with checkboxes and manual Windows verific…
Linked Issues check
Issue #50975 requires Orca to read SSH config Include and IdentityFile values as OpenSSH does for single quotes and backslash-escaped spaces. At head, src/main/ssh/config/ssh-config-arguments.ts expor…
Out of Scope Changes check
The changed tokenizer in ssh-config-arguments.ts serves #50975. Its # boundary rule keeps values such as team#1 and ~/.ssh/t#1 intact, which keeps the shared tokenizer consistent with the values the P…
Full details: Title check
Explanation
The title names the main change: SSH config parsing of single-quoted paths and escaped-space paths now follows OpenSSH. It matches the changeset, which adds a shared splitOpenSshArguments tokenizer that handles single quotes and escaped spaces. The title is specific and uses the conventional fix(ssh) prefix.
Full details: Description check
Explanation
The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #50975), Visual Proof (N/A with reason), Testing with checkboxes and manual Windows verification, Performance, Risk with level and back-out plan, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist. It explains the before and after behavior with a table and states the mechanism. Minor gaps: the template's Testing section asks for the platforms tested, and the description covers Windows only, which is stated. The Visual Proof N/A is justified. Overall the description is mostly complete.
Full details: Linked Issues check
Explanation
Issue #50975 requires Orca to read SSH config Include and IdentityFile values as OpenSSH does for single quotes and backslash-escaped spaces. At head, src/main/ssh/config/ssh-config-arguments.ts exports splitOpenSshArguments. It treats '...' and "..." as quotes, each literal inside the other. It treats ", ', \, and unquoted <space> as escapes, and keeps other backslashes literal. It also starts a comment at an unquoted # only when the current token is empty, so team#1 stays one argument. The previous assessment found that the Include expander and the parser both call this function. The incremental diff from the previous reviewed head could not be read, so the head file was checked directly. It confirms the tokenizer behavior described in the PR. The three forms in the issue table (single-quoted Include, escaped-space Include, single-quoted IdentityFile) are covered. The PR's ssh-config-loader.test.ts case was not opened, so its fail-on-revert claim rests on the PR description. The verdict does not depend on that claim. No coding requirement remains unmet.
Full details: Out of Scope Changes check
Explanation
The changed tokenizer in ssh-config-arguments.ts serves #50975. Its # boundary rule keeps values such as team#1 and ~/.ssh/t#1 intact, which keeps the shared tokenizer consistent with the values the PR claims to preserve. The Include expander and the parser now use this one tokenizer, which matches the issue's single-tokenizer scope. The PR keeps ProxyCommand as raw text and leaves ssh-g-config-resolution.ts unchanged. The issue does not require either change. The incremental diff could not be read, so the review of the newest changes relies on the head file and the summary. No unrelated change is evident.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 324f2679-553e-4fbc-84d2-d6d27b32f66f
Commits
Reviewing files that changed from the base of the PR and between e3cd23b and 8e85e48.
Files selected for processing: 2
src/main/ssh/config/ssh-config-arguments.ts
src/main/ssh/config/ssh-config-loader.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Recognize comments only between arguments.
For Include ~/.ssh/my\ configs/team#1.conf, the tokenizer consumes the escaped space but truncates the pathname at #. The Include expander then checks ~/.ssh/my configs/team, so the included hosts do not load.
OpenSSH 9.5p1 recognizes a comment before starting an argument; it preserves # inside an argument. Track whether an argument has started before applying this condition. Keep whitespace-separated trailing comments excluded. (raw.githubusercontent.com)
…OpenSSH
OpenSSH tokenizes config lines with argv_split, where '...' quotes like
"..." and "\ " escapes a space. Orca's parser only knew double quotes,
and Include lines used a second tokenizer without escapes, so hosts from
`Include '~/.ssh/my configs/*'` or `Include ~/.ssh/my\ configs/*`
vanished and `IdentityFile '~/.ssh/my key'` became `'~/.ssh/my`.
Share one argv_split-compatible tokenizer between both, and treat # as a
comment only at a token boundary so `Host team#1` and
`Include ~/.ssh/t#1` keep the # literally, as ssh does.
Fixesstablyai#50975
Co-authored-by: Neil <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Your
~/.ssh/configtells your computer how to reach other machines. Paths in it can contain spaces if you wrap them in quotes or put a backslash before the space. Orca read some of those lines differently from the realsshprogram, so it could miss hosts or point at the wrong key file. Now Orca reads the file the same waysshdoes, so the host list and key paths match what actually works.What Changed
Before:
Include '~/.ssh/my configs/a'(single quotes) andInclude ~/.ssh/my\ configs/b(escaped space) loaded no hosts.Host 'quoted-key'was imported as the alias'quoted-key', quotes included.IdentityFile '/keys/my key'came out as'/keys/my.Host team#1was cut down toteam, because any#started a comment.After: all of these resolve the same way
ssh -Gresolves them.Mechanism:
splitOpenSshArgumentsinssh-config-parser.tsonly knew"quotes.splitQuotedArgumentsinssh-config-include-expander.tsalso only knew", and it ignored\,\\and\'.splitOpenSshArgumentsin the newsrc/main/ssh/config/ssh-config-arguments.ts, modeled on OpenSSHargv_split(misc.c, called from readconf.c).'...'and"..."both quote.\\,\",\'and unquoted\are escapes. Any other backslash stays literal, so Windows paths are unchanged (fix(ssh): preserve literal backslashes in quoted SSH config paths #50411). An unquoted#starts a comment only at the start of a token, soHost team#1andInclude ~/.ssh/t#1keep their#.Why
Follow-up to #50411, which aligned backslash handling with
argv_splitbut left out single quotes and the second tokenizer. With one shared tokenizer,Includelines can't drift from the other directives again.ssh-g-config-resolution.ts'ssplitIncludeArgumentsis intentionally left alone. It has a different contract: it returnsnullwhen it is unsure.Linked Issue
Fixes #50975
Visual Proof
N/A. This is a config-parser change, and the only visible effect is which SSH hosts and key paths Orca imports. The before/after parser output is in Testing below.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
The new case in
ssh-config-loader.test.tscovers a single-quotedInclude, an escaped-spaceInclude, a single-quotedHostandIdentityFilethat contain", andteam#1followed by a trailing# comment.'quoted-key'and IdentityFile'/keys/my, cutsteam#1down toteam, and loses both included hosts.src/main/ssh/passes (12 files, 49 tests).Ran real
ssh -G -F(OpenSSH_10.5p1, macOS) on scratch configs: the Include spellings,Host 'quoted-key' x#y, and IdentityFile edge cases (a'b,f#g,h\ i,C:\keys\l,#x). The parser matches ssh in every case.Ran a differential fuzz of about 160k random strings against a JS port of
argv_split. The only mismatch is an empty quote right before#(""#x), which also diverges on main.The original author also tested on Windows 10 with OpenSSH_for_Windows 9.5p1 and Git's OpenSSH 10.0p2.
oxlint,
oxfmt --check, the anti-slop and native-plugin oxlint configs, ast-grep, and the changed-code quality gate are all clean on the touched files.Performance
None, because the tokenizer still makes a single pass over each line, with no new I/O, subprocess or polling. It runs in the main process only when the SSH config loads (host picker, import or reconcile, and alias claims behind a 5 s TTL cache). Median of 3 runs of
parseSshConfig, main vs this PR:Risk
Level: Low
'in a config value is now a quote and a#inside a token is now literal, as in OpenSSH. A config that relied on the old reading was already read differently bysshitself.'foo', orteamfromteam#1), the next reconcile adds the correctly named host once. The old entry stays until the user deletes it.ProxyCommandkeeps its raw text, as before.Review
Original fix by @Pr1p in #50976. The maintainer follow-up adds the token-boundary
#handling and its test.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
This parsing change behaves the same on every platform: OpenSSH tokenizes identically on every OS, and Windows backslash path separators stay literal.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)