security: 遗留清零——aiModel密钥永不下发/搜索正则注入转义/排行榜limit封顶且去openid/删除重复shop-items路由/登录入参强转防对象注入/sessionKey默认不返回
This commit is contained in:
@@ -6,6 +6,7 @@ const { ipLocation } = require('../utils/iploc')
|
||||
const { authMiddleware, requirePermission } = require('../middleware/auth')
|
||||
const ApiResponse = require('../utils/response')
|
||||
const logger = require('../utils/logger')
|
||||
const { escapeRegExp } = require('../utils/escapeRegex')
|
||||
|
||||
// 所有管理路由都需要认证
|
||||
router.use(authMiddleware)
|
||||
@@ -138,7 +139,7 @@ router.get('/users', requirePermission('users:read'), async (req, res) => {
|
||||
const query = {}
|
||||
|
||||
if (search) {
|
||||
query.nickName = { $regex: search, $options: 'i' }
|
||||
query.nickName = { $regex: escapeRegExp(search), $options: 'i' }
|
||||
}
|
||||
|
||||
if (dimCompleted) {
|
||||
@@ -743,7 +744,7 @@ router.get('/ai-chat/quota-list', requirePermission('user:read'), async (req, re
|
||||
try {
|
||||
const { page = 1, pageSize = 10, keyword = '' } = req.query
|
||||
|
||||
const query = keyword ? { openid: { $regex: keyword, $options: 'i' } } : {}
|
||||
const query = keyword ? { openid: { $regex: escapeRegExp(keyword), $options: 'i' } } : {}
|
||||
|
||||
const [list, total] = await Promise.all([
|
||||
AIChatQuota.find(query)
|
||||
@@ -854,9 +855,9 @@ router.get('/feedback', requirePermission('feedback:read'), async (req, res) =>
|
||||
if (priority) query.priority = priority
|
||||
if (search) {
|
||||
query.$or = [
|
||||
{ title: { $regex: search, $options: 'i' } },
|
||||
{ content: { $regex: search, $options: 'i' } },
|
||||
{ userName: { $regex: search, $options: 'i' } }
|
||||
{ title: { $regex: escapeRegExp(search), $options: 'i' } },
|
||||
{ content: { $regex: escapeRegExp(search), $options: 'i' } },
|
||||
{ userName: { $regex: escapeRegExp(search), $options: 'i' } }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1124,7 +1125,7 @@ router.get('/login-logs', requirePermission('user:read'), async (req, res) => {
|
||||
router.get('/trends', requirePermission('trend:read'), async (req, res) => {
|
||||
try {
|
||||
const { page = 1, limit = 20, keyword = '' } = req.query
|
||||
const query = keyword ? { title: { $regex: keyword, $options: 'i' } } : {}
|
||||
const query = keyword ? { title: { $regex: escapeRegExp(keyword), $options: 'i' } } : {}
|
||||
const total = await Trend.countDocuments(query)
|
||||
const items = await Trend.find(query).sort({ newsDate: -1, createdAt: -1 })
|
||||
.skip((parseInt(page) - 1) * parseInt(limit)).limit(parseInt(limit)).lean()
|
||||
@@ -1271,7 +1272,7 @@ router.get('/vpay/orders', requirePermission('orders:read'), async (req, res) =>
|
||||
const { page = 1, limit = 20, status = '', keyword = '' } = req.query
|
||||
const query = {}
|
||||
if (status) query.status = status
|
||||
if (keyword) query.orderNo = { $regex: keyword, $options: 'i' }
|
||||
if (keyword) query.orderNo = { $regex: escapeRegExp(keyword), $options: 'i' }
|
||||
const total = await Order.countDocuments(query)
|
||||
const items = await Order.find(query)
|
||||
.sort({ createdAt: -1 })
|
||||
@@ -1432,7 +1433,7 @@ router.get('/vpay/ledger', requirePermission('orders:read'), async (req, res) =>
|
||||
const { page = 1, limit = 20, type = '', keyword = '' } = req.query
|
||||
const query = {}
|
||||
if (type) query.type = type
|
||||
if (keyword) query.openid = { $regex: keyword, $options: 'i' }
|
||||
if (keyword) query.openid = { $regex: escapeRegExp(keyword), $options: 'i' }
|
||||
const total = await CoinLedger.countDocuments(query)
|
||||
const items = await CoinLedger.find(query)
|
||||
.sort({ createdAt: -1 })
|
||||
|
||||
Reference in New Issue
Block a user