fix: 安全加固与修复 lib/__init__.py 错误导入#5
Open
FMVPJet wants to merge 1 commit intobadseal:mainfrom
Open
Conversation
1. 守护进程/隧道信息文件权限加固:目录设置 0o700,信息文件设置 0o600, 防止同机其他用户读取端口和 PID 信息 2. 临时密码脚本异常清理:_create_password_script() 加 try/except, 异常时自动关闭 fd 并删除含密码的临时文件 3. 修复 lib/__init__.py:移除对不存在的 client.py 和 config.py 的引用, 替换为实际存在的模块(config_v3, native_ssh_client, paramiko_client 等) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ssh_daemon.py,ssh_tunnel.py):目录 0o700,文件 0o600,防止同机其他用户读取paramiko_client.py):_create_password_script()加 try/except,异常时自动关闭 fd 并删除含密码的临时文件lib/__init__.py:移除对不存在的client.py和config.py的引用,替换为实际存在的模块Details
1. 信息文件权限加固
ssh_daemon.py和ssh_tunnel.py在/tmp/下创建的信息文件(含端口、PID)之前使用默认权限(0o644),同机其他用户可读取并连接守护进程。修复:
os.makedirs()加mode=0o700+os.chmod(dir, 0o700)os.chmod(path, 0o600)2. 临时密码脚本异常清理
paramiko_client.py的_create_password_script()在写入密码到临时文件时,如果发生异常会残留含密码的文件。修复:
os.fdopen接管的 fdfd = -1标记 fd 已被接管,避免 double close3. 修复 lib/init.py
__init__.py引用了不存在的client.py和config.py,导致import lib时触发ModuleNotFoundError。修复:更新为实际存在的模块(
config_v3,native_ssh_client,paramiko_client,cluster,sftp_transfer,utils)。Test plan
import lib验证通过