fix: Phase 1 audit - ssh_key columns String(500) -> Text for RSA key support

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Your Name
2026-05-23 16:07:24 +08:00
parent 6108d69b24
commit c08e2a2242
2 changed files with 24 additions and 2 deletions
@@ -0,0 +1,20 @@
# Phase 1 补充走读修复
**日期**: 2026-05-23
**批次**: Phase 1Step 05 遗留代码补充全文走读)
## 覆盖文件
| 文件 | 结论 |
|------|------|
| `server/infrastructure/telegram/__init__.py` | ✅ CLEANF2c-04/F2d-04 修复均正确) |
| `server/domain/models/__init__.py` | 🔴 F1-01 修复 |
| `server/background/script_execution_flush.py` | ✅ CLEAN |
| `server/api/health.py` | ✅ CLEAN |
| `server/infrastructure/database/ssh_session_repo.py` | ✅ CLEAN |
## 修复
| ID | 文件:行 | 级 | 说明 |
|----|---------|----|----|
| F1-01 | `domain/models/__init__.py:79-80` | P2 | `ssh_key_private`/`ssh_key_public` 列类型从 `String(500)` 改为 `Text`Fernet 加密的 RSA 4096 私钥约 4300+ 字符,超出 String(500) 会在 MySQL 严格模式下报 DataError |
+4 -2
View File
@@ -76,8 +76,10 @@ class Server(Base):
auth_method = Column(String(20), default="key", comment="认证方式: key/password")
password = Column(String(255), nullable=True, comment="SSH密码(加密存储)")
ssh_key_path = Column(String(500), nullable=True, comment="SSH私钥路径")
ssh_key_private = Column(String(500), nullable=True, comment="加密后的私钥内容")
ssh_key_public = Column(String(500), nullable=True, comment="公钥内容")
# Text columns: RSA 4096 private key PEM is ~3.2 KB; Fernet-encrypted ~4.3 KB.
# String(500) would cause DataError in MySQL strict mode for large keys.
ssh_key_private = Column(Text, nullable=True, comment="加密后的私钥内容(Fernet)")
ssh_key_public = Column(Text, nullable=True, comment="公钥内容")
ssh_key_configured = Column(Boolean, default=False, comment="是否已配置SSH Key")
agent_port = Column(Integer, default=8601, comment="Agent API端口")
agent_api_key = Column(String(255), nullable=True, comment="Agent API密钥")