mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-02 13:01:23 +01:00
Merge pull request #14220 from wy65701436/fix-codeql-quota
fix quota dao sql injection
This commit is contained in:
commit
51c8375425
@ -17,6 +17,7 @@ package dao
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/lib/pq"
|
||||
"strings"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
@ -104,7 +105,7 @@ func listOrderBy(query *q.Query) string {
|
||||
if strings.HasPrefix(sort, prefix) {
|
||||
resource := strings.TrimPrefix(sort, prefix)
|
||||
if types.IsValidResource(types.ResourceName(resource)) {
|
||||
field := fmt.Sprintf("%s->>'%s'", strings.TrimSuffix(prefix, "."), resource)
|
||||
field := fmt.Sprintf("%s->>%s", strings.TrimSuffix(prefix, "."), pq.QuoteLiteral(resource))
|
||||
orderBy = fmt.Sprintf("(%s) %s", castQuantity(field), order)
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user