Skip to content

fix(ssh): case-insensitive host matching and DevPod marker backtrack - #779

Merged
skevetter merged 4 commits into
skevetter:mainfrom
lefty01:fix/ssh-config-lowercase-host-devpod-marker
Sep 25, 2026
Merged

skevetter merged 4 commits into
skevetter:mainfrom
lefty01:fix/ssh-config-lowercase-host-devpod-marker

Conversation

@lefty01

@lefty01 lefty01 commented Sep 23, 2026 •

Copy link
Copy Markdown

findInsertPosition had two bugs that corrupted ~/.ssh/config when inserting a new workspace block:

  1. The Host keyword check was case-sensitive (strings.HasPrefix(..., "Host")), so lowercase 'host' entries — which are equally valid per SSH config syntax — were invisible to the scanner. It would skip past all of them and land on the first uppercase 'Host' keyword, which could be inside an already-present DevPod block.

  2. '# DevPod Start ' marker lines were counted as plain comment lines in the commentLines backtrack counter. When the first Host found was preceded by such a marker, the backtrack subtracted 1 and placed the insertion point inside the existing block, gluing the new block's start marker onto the previous host entry line.

Fix 1: use strings.HasPrefix(strings.ToLower(trimmed), "host ") so that both 'Host' and 'host' (and 'HOST' etc.) are recognised.

Fix 2: exclude lines matching MarkerStartPrefix / MarkerEndPrefix from the commentLines counter so DevPod marker lines are never treated as backtrack candidates.

Also fix the pre-existing test case 'Host addition to existing config with DevPod host' which had a mismatched End marker ('# DevPod End testhost' instead of '# DevPod End existingtesthost'), and add two new regression test cases:

  • Host addition with lowercase host entries
  • Host addition does not corrupt existing DevPod block followed by plain host

Summary by CodeRabbit

  • Bug Fixes
    • SSH configuration updates now recognize Host and Match section headers regardless of capitalization or formatting, and place new workspace entries before existing sections and their associated comments or options.
    • Existing DevPod configuration blocks are preserved when workspace entries are added, helping keep your current SSH settings intact.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 9d0cc64f-e675-4feb-9c0e-cc55ce3b61f3

📥 Commits

Reviewing files that changed from the base of the PR and between 8ca80bc and 4d2cc47.

📒 Files selected for processing (4)
  • .github/workflows/pr-ci.yml
  • .github/workflows/pre-commit.yml
  • pkg/ssh/config.go
  • pkg/ssh/config_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

SSH configuration insertion now recognizes Host and Match directives across casing and separators. The CI workflows separate Windows kind.exe download and verification from cluster setup, and pin the installed goimports version.

Changes

SSH Configuration

Layer / File(s) Summary
SSH section detection and insertion
pkg/ssh/config.go, pkg/ssh/config_test.go
Section detection recognizes Host and Match directives across casing and separators. Tests check insertion positions and preservation of existing DevPod blocks.

Windows kind Setup

Layer / File(s) Summary
Download and verify kind.exe
.github/workflows/pr-ci.yml
A separate Windows step retries the download up to three times, verifies the SHA-256 hash, and adds the runner temp directory to GITHUB_PATH. Cluster setup retains its process-local PATH setup and cluster creation.

Pre-commit Tool Version

Layer / File(s) Summary
Pin goimports version
.github/workflows/pre-commit.yml
The workflow installs goimports@v0.49.0 instead of goimports@latest.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4d2cc

The supplied evidence does not identify a change that needs correction before merging. Proceed with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary SSH configuration changes: case-insensitive host matching and corrected DevPod marker backtracking. It is concise and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

Warning

⚠️ This pull request shows signs of AI-generated slop (description_diff_mismatch). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@skevetter

Copy link
Copy Markdown
Owner

will review when status checks are passing

findInsertPosition had two bugs that corrupted ~/.ssh/config when
inserting a new workspace block:

1. The Host keyword check was case-sensitive (strings.HasPrefix(...,
   "Host")), so lowercase 'host' entries — which are equally valid per
   SSH config syntax — were invisible to the scanner. It would skip past
   all of them and land on the first uppercase 'Host' keyword, which
   could be inside an already-present DevPod block.

2. '# DevPod Start <name>' marker lines were counted as plain comment
   lines in the commentLines backtrack counter. When the first Host
   found was preceded by such a marker, the backtrack subtracted 1 and
   placed the insertion point inside the existing block, gluing the new
   block's start marker onto the previous host entry line.

Fix 1: use strings.HasPrefix(strings.ToLower(trimmed), "host ") so
that both 'Host' and 'host' (and 'HOST' etc.) are recognised.

Fix 2: exclude lines matching MarkerStartPrefix / MarkerEndPrefix from
the commentLines counter so DevPod marker lines are never treated as
backtrack candidates.

Also fix the pre-existing test case 'Host addition to existing config
with DevPod host' which had a mismatched End marker
('# DevPod End testhost' instead of '# DevPod End existingtesthost'),
and add two new regression test cases:
- Host addition with lowercase host entries
- Host addition does not corrupt existing DevPod block followed by
  plain host
@lefty01
lefty01 force-pushed the fix/ssh-config-lowercase-host-devpod-marker branch from 73e1052 to ee7913e Compare September 23, 2026 20:23
- Break long string literals (>120 chars) in new test cases into
  multi-line concatenations to satisfy the lll linter.
- Let gofmt normalize struct field alignment to satisfy gci formatter.
@github-actions github-actions Bot added size/l and removed size/m labels Sep 23, 2026
@lefty01

lefty01 commented Sep 24, 2026

Copy link
Copy Markdown
Author

not sure about the three ci fails ... can I fix it or is it a setup problem?

@skevetter

Copy link
Copy Markdown
Owner

not sure about the three ci fails ... can I fix it or is it a setup problem?

This is a setup problem on my end. Things grew stale. I'm taking a look into it.

Just for my own interest, is there a reason that you have a preference for DevPod over Devsy for your current setup? What I mean to say is I think there might be more fixes in Devsy than what exists in DevPod today.

…acement

- Add sshConfigKeyword and isSSHSectionStart helpers to recognize Host
  and Match section keywords case-insensitively with space, tab, or '='.
- Avoid splitting existing DevPod blocks by including preceding comments
  and '# DevPod Start' markers in the backtrack.
- Remove skipConfigContainsCheck test escape hatch and restore the
  contiguous config assertion.
- Add test variants for casing, delimiters, HostName false-positive,
  Match section boundaries, and block integrity.

Signed-off-by: Samuel K <skevetter@pm.me>
- Pin goimports to v0.49.0 in pre-commit.yml for Go 1.25 toolchain
  compatibility.
- Download kind.exe on Windows using PowerShell Invoke-WebRequest with
  bounded retry and SHA256 checksum verification.

Signed-off-by: Samuel K <skevetter@pm.me>
@lefty01

lefty01 commented Sep 25, 2026

Copy link
Copy Markdown
Author

Things grew stale. I'm taking a look into it.

thx

came from vs code plugin via devcontainer cli to devpod. trying Devsy next seems like the right thing to do ;) I'll give it a try maybe checking directly if this deficiency with the corrupted ssh config exits there as well (same code right?).

@skevetter
skevetter merged commit 278b45a into skevetter:main Sep 25, 2026
75 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants