T09 · Insecure Skill Coding Practices
- Location
scripts/move_with_log.py:64- Finding
Protected directories are not enforced during file move and trash operations
- Content
View full analysis
{dst}") return 0 except (OSError, shutil.Error) as e: log_operation(log_file, "move", src, dst, "error", str(e)) print(f"ERROR: 移动失败: {src} -> {dst}", file=sys.stderr) return 1 def do_trash(log_file, filepath): """移到回收站(跨平台)""" if not os.path.exists(filepath): log_operation(log_file, "trash", filepath, "trash", "error", "文件不存在") print(f"ERROR: 文件不存在: {filepath}", file=sys.stderr) return 1 try: import send2trash send2trash.send2trash(filepath) log_operation(log_file, "trash", filepath, "trash", "ok") print(f"OK: {filepath} -> 回收站") return 0 except ImportError: # send2trash 未安装,尝试系统命令 log_operation(log_file, "trash", filepath, "trash", "error", "send2trash 未安装") print("ERROR: send2trash 未安装,请运行: pip install send2trash", file=sys.stderr) return 1 except OSError as e: log_operation(log_file, "trash", filepath, "trash", "error", str(e)) print(f"ERROR: 移到回收站失败: {filepath}", file=sys.stderr) return 1 ``` ### Technical Analysis The move ...[truncated 1667 chars]- Remediation
View remediation
