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:
@@ -304,7 +304,20 @@ router.post('/batch', async (req, res) => {
|
||||
|
||||
router.put('/:portId', async (req, res) => {
|
||||
try {
|
||||
const [updated] = await DevicePort.update(req.body, {
|
||||
// 白名单过滤:只允许更新安全字段
|
||||
const ALLOWED_FIELDS = ['portName', 'portType', 'portSpeed', 'status', 'vlanId', 'description', 'connectedDevice', 'macAddress'];
|
||||
const updateData = {};
|
||||
ALLOWED_FIELDS.forEach(field => {
|
||||
if (req.body[field] !== undefined) {
|
||||
updateData[field] = req.body[field];
|
||||
}
|
||||
});
|
||||
|
||||
if (Object.keys(updateData).length === 0) {
|
||||
return res.status(400).json({ error: '没有可更新的字段' });
|
||||
}
|
||||
|
||||
const [updated] = await DevicePort.update(updateData, {
|
||||
where: { portId: req.params.portId },
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user