fix: 审计修复 — diagnose/file-diff 端点静默吞错改为 logger.debug/warning

B1: diagnose 磁盘和路径检查 except:pass 改为 logger.debug()
B2: file-diff SSH失败无日志改为 logger.warning()

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-05-29 22:11:06 +08:00
parent 5958c21048
commit 0cbda8c840
+6 -7
View File
@@ -538,10 +538,8 @@ async def diagnose_push(
result["disk_used_pct"] = int(parts[4].replace("%", "")) # e.g. 72
except ValueError:
pass
except Exception:
pass
# 3. Target path existence + permissions
except Exception as e:
logger.debug(f"Diagnose disk check failed for server {payload.server_id}: {e}")
try:
r = await exec_ssh_command(server, f"ls -ld {safe_dest} 2>&1", timeout=10)
if r["exit_code"] == 0:
@@ -552,8 +550,8 @@ async def diagnose_push(
else:
result["path_exists"] = False
result["errors"].append(f"目标路径不存在: {dest}")
except Exception:
pass
except Exception as e:
logger.debug(f"Diagnose path check failed for server {payload.server_id}: {e}")
# 4. Write test
if result["path_exists"]:
@@ -675,8 +673,9 @@ async def file_diff(
else:
# File doesn't exist on remote — treat as empty (all local lines are additions)
remote_exists = False
except Exception:
except Exception as e:
# SSH failed — report error
logger.warning(f"File diff remote read failed for server {payload.server_id}: {e}")
remote_exists = None
# Compute unified diff