提交 7677f219 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

修复sql注入安全隐患 感谢@Tom4t0提交漏洞

上级 f11c0eec
......@@ -76,11 +76,22 @@ func (apiService *ApiService) GetAPIInfoList(api system.SysApi, info request.Pag
db = db.Limit(limit).Offset(offset)
if order != "" {
var OrderStr string
if desc {
OrderStr = order + " desc"
} else {
OrderStr = order
// 设置有效排序key 防止sql注入
// 感谢 Tom4t0 提交漏洞信息
orderMap := make(map[string]bool, 5)
orderMap["id"] = true
orderMap["path"] = true
orderMap["api_group"] = true
orderMap["description"] = true
orderMap["method"] = true
if orderMap[order] {
if desc {
OrderStr = order + " desc"
} else {
OrderStr = order
}
}
err = db.Order(OrderStr).Find(&apiList).Error
} else {
err = db.Order("api_group").Find(&apiList).Error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册