github-code-scanning[bot] commented on code in PR #7482:
URL: https://github.com/apache/trafficcontrol/pull/7482#discussion_r1183941291


##########
traffic_ops/traffic_ops_golang/servercapability/servercapability.go:
##########
@@ -367,3 +367,157 @@
 
 func (v *TOServerCapability) Create() (error, error, int) { return 
api.GenericCreateNameBasedID(v) }
 func (v *TOServerCapability) Delete() (error, error, int) { return 
api.GenericDelete(v) }
+
+func GetServerCapabilityV5(w http.ResponseWriter, r *http.Request) {
+       var sc tc.ServerCapabilityV5
+       inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
+       tx := inf.Tx
+       if userErr != nil || sysErr != nil {
+               api.HandleErr(w, r, tx.Tx, errCode, userErr, sysErr)
+               return
+       }
+       defer inf.Close()
+
+       // Query Parameters to Database Query column mappings
+       queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
+               "name": {Column: "sc.name", Checker: nil},
+       }
+       if _, ok := inf.Params["orderby"]; !ok {
+               inf.Params["orderby"] = "name"
+       }
+       where, orderBy, pagination, queryValues, errs := 
dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, queryParamsToQueryCols)
+       if len(errs) > 0 {
+               api.HandleErr(w, r, tx.Tx, http.StatusBadRequest, 
util.JoinErrs(errs), nil)
+               return
+       }
+
+       selectQuery := "SELECT name, description, last_updated FROM 
server_capability sc"
+       query := selectQuery + where + orderBy + pagination
+       rows, err := tx.NamedQuery(query, queryValues)

Review Comment:
   ## Database query built from user-controlled sources
   
   This query depends on a [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/trafficcontrol/security/code-scanning/265)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to