fix: 修复14个中等问题(安全+稳定性)
后端安全修复: - devices.js: page/pageSize parseInt+范围限制、CSV导入path.basename防路径遍历 - tickets.js: CSV导出收集所有metadata key、评价限制completed状态 - users.js: 重置密码加权限检查(仅管理员或本人) - systemSettings.js: Boolean改显式判断(修复false存储为true) - inventory.js: 空数组Array.isArray检查(修复无法清空目标机房) - statistics.js: 在线率改用runningDevices计算 - operationLogs.js: DATE()改strftime兼容SQLite - devicePorts.js: 端口更新白名单过滤(防修改portId/deviceId) - server.js: 生产环境禁用sync alter 前端修复: - api/index.js: 401优先React Router导航(保留SPA状态) - Scene.jsx: useFrame仅target变化时更新(减少不必要矩阵计算) - vite.config.mjs: 移除Vue插件残留(unplugin-vue-components)
This commit is contained in:
@@ -520,7 +520,9 @@ router.post('/import-preview', async (req, res) => {
|
||||
|
||||
router.get('/', validateQuery(queryDeviceSchema), async (req, res) => {
|
||||
try {
|
||||
const { keyword, status, type, rackId, roomId, page = 1, pageSize = 10, isIdle } = req.query;
|
||||
const { keyword, status, type, rackId, roomId, isIdle } = req.query;
|
||||
const page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
||||
const pageSize = Math.min(100, Math.max(1, parseInt(req.query.pageSize, 10) || 10));
|
||||
const offset = (page - 1) * pageSize;
|
||||
|
||||
// 构建查询条件
|
||||
@@ -1078,8 +1080,12 @@ router.post('/import', async (req, res) => {
|
||||
fs.mkdirSync(path.join(__dirname, '../temp'));
|
||||
}
|
||||
|
||||
// 保存上传的文件
|
||||
const filePath = path.join(__dirname, '../temp', csvFile.name);
|
||||
// 保存上传的文件(使用 path.basename 防止路径遍历)
|
||||
const safeFileName = path.basename(csvFile.name);
|
||||
if (!safeFileName || safeFileName.startsWith('.') || safeFileName !== csvFile.name) {
|
||||
return res.status(400).json({ error: '文件名不合法' });
|
||||
}
|
||||
const filePath = path.join(__dirname, '../temp', safeFileName);
|
||||
await csvFile.mv(filePath);
|
||||
|
||||
// 读取并解析CSV文件(GBK编码)
|
||||
|
||||
Reference in New Issue
Block a user