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
generate_ssh_config can delete user content from ~/.ssh/config when the managed markers are orphaned #31
generate_ssh_config with target: "user_ssh_config" can silently delete user-written content from ~/.ssh/config. That breaks the README's promise that content outside the markers is never touched, and ~/.ssh/config is a file people care about a lot.
Evidence
src/sshconfig.ts:43-55 (applyManagedBlock) looks for the firstBEGIN and the firstEND. If only one marker exists (the user deleted # END tailscale-mcp by hand, a merge went wrong, a dotfiles sync dropped a line), it treats the config as having no managed block and appends a new one. The orphaned BEGIN stays behind. On the next run, the first BEGIN (the orphan) pairs with the new END, and everything between them is replaced.
Repro against dist/sshconfig.js:
letcfg="Host a\n HostName a\n# BEGIN tailscale-mcp\nHost keepme\n HostName important\n";letr1=applyManagedBlock(cfg,body);// keepme still presentletr2=applyManagedBlock(r1,body);// keepme GONE
Output: keepme after run1: true after run2: false.
The same thing happens when END comes before BEGIN, or when there are duplicate marker pairs.
Suggested approach
Parse the markers strictly: require exactly one BEGIN line and exactly one END line after it, each matched as a whole line (not with indexOf anywhere in the file).
If the markers are malformed (orphaned, reversed, or duplicated), refuse to write and return a structured error (e.g. SSH_CONFIG_MARKERS_CORRUPT) that names the line numbers and tells the user how to fix it.
Add tests for orphan BEGIN, orphan END, reversed, duplicate pairs, and markers inside a comment line.
Done when
No input to applyManagedBlock can ever drop a byte outside a well-formed marker pair (a property-style test is ideal).
Malformed markers produce a structured error and leave the file untouched.
Activity
fix: ssh-config safety, macOS CLI resolution, share paths, test typec…