SSH config writes are not idempotent, and tests write fixture hosts into the user's real ~/.ssh/config (164 duplicate blocks observed)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- networking, testing
调研方向
定位 SSH 配置的写入路径,以及创建 my_cluster fixture 的测试;首先确认哪些测试可以访问 ~/.ssh/config。完成的标准是:重复写入不会创建重复的主机块,生成的条目能够安全地隔离或替换,并且测试使用临时配置,同时保留真实的用户条目。
由索引模型根据 Issue 内容生成。
描述
Summary
clustrix appends entries to the user's real ~/.ssh/config without deduplicating, and it writes test-fixture hosts into that personal config. On my machine this accumulated to 164 identical placeholder blocks.
Evidence
Measured on a real user config (macOS, ~/.ssh/config):
total lines: 1202
total Host entries: 172
Frequency by host (real hostnames redacted):
164 Host my_cluster <- test fixture, repeated 164x
1 Host <gpu-host-alias>
1 Host <slurm-host-alias>
1 Host test_cli
1 Host test_cleanup
1 Host <slurm-host-alias-2>
1 Host <slurm-host>
1 Host <slurm-host-alias-3>
1 Host <institution-domain>
Every duplicate block is byte-identical and self-labelled:
# Clustrix auto-generated entry for my_cluster
Host my_cluster
HostName cluster.example.com
User testuser
IdentityFile ~/.ssh/id_ed25519_clustrix_testuser_my_cluster
IdentitiesOnly yes
cluster.example.com / testuser is a test fixture, not a real host. After removing only the my_cluster blocks, the file went from 1202 lines / 172 Host entries to 52 lines / 8 Host entries, with every genuine entry preserved.
Two distinct bugs
- No deduplication on write. Each run appends a new block for a host that already has one. Nothing detects or replaces the existing entry, so the file grows without bound across runs.
- Tests write to the real user config.
my_cluster→cluster.example.com/testuseris fixture data. A test suite should never mutate~/.ssh/config; it should write to a temp file and point SSH at it via-F/ssh_configpath injection.
Impact
- The user's personal SSH config becomes unmanageable (1202 lines of which ~96% is generated noise).
- Real entries get buried among fixtures, making the file hard to audit.
- Functionally the duplicates are inert — OpenSSH takes the first match for a given
Hostpattern — so this is a hygiene and trust problem rather than a broken-connection problem. But it means clustrix silently rewrites a security-relevant file in the user's home directory.
Suggested fixes
- Make config writes idempotent: look for an existing block for the same
Hostalias and replace it in place, rather than appending. - Delimit generated regions with explicit markers (e.g.
# >>> clustrix managed >>>/# <<< clustrix managed <<<) so the tool can rewrite only its own section and users can see what it owns. - Consider writing to a dedicated
~/.ssh/clustrix_configand having users add a singleInclude clustrix_configline, so clustrix never touches the main file. - In the test suite, redirect all SSH-config writes to a
tmp_pathfixture. No test should be able to modify~/.ssh/config. - Optionally ship a
clustrix ssh-config --prunecommand to clean up configs already affected.
Environment
- clustrix installed from source (repo
master) - macOS, OpenSSH client
- 主要语言
- Python
- 星标
- 10
- 派生
- 4
- 平均合并
- 15 小时 10 分钟
- 30 天内合并 PR
- 2
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ContextLab/clustrix 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
ContextLab/clustrix#170 ·
-
enhancement epic
难度 5/5 一周以上 新手友好度 20/100
ContextLab/clustrix#160 ·
-
难度 5/5 一周以上 新手友好度 35/100
ContextLab/clustrix#155 · 1 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 42/100
ContextLab/clustrix#151 · 5 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
ContextLab/clustrix#146 · 2 条评论 ·
查看 ContextLab/clustrix 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
stephrobert/dsoxlab#238 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
sublimehq/package_control#1780 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 70/100
nwg-piotr/nwg-displays#145 ·