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


##########
traffic_ops/traffic_ops_golang/coordinate/coordinates.go:
##########
@@ -173,6 +274,199 @@
        return query
 }
 
+const delQuery = `
+DELETE FROM coordinate
+WHERE id = $1
+RETURNING
+       latitude,
+       longitude,
+       name,
+       last_updated
+`
+
 func deleteQuery() string {
        return `DELETE FROM coordinate WHERE id = :id`
 }
+
+// Read is the handler for GET requests made to the /coordinates API (in APIv5
+// and later).
+func Read(w http.ResponseWriter, r *http.Request) {
+       inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
+       tx := inf.Tx.Tx
+       if userErr != nil || sysErr != nil {
+               api.HandleErr(w, r, tx, errCode, userErr, sysErr)
+               return
+       }
+       defer inf.Close()
+
+       cols := map[string]dbhelpers.WhereColumnInfo{
+               "id":   {Column: "c.id", Checker: api.IsInt},
+               "name": {Column: "c.name", Checker: nil},
+       }
+       api.DefaultSort(inf, "name")
+
+       where, orderBy, pagination, queryValues, errs := 
dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, cols)
+       if len(errs) > 0 {
+               errCode = http.StatusBadRequest
+               userErr = util.JoinErrs(errs)
+               api.HandleErr(w, r, tx, errCode, userErr, nil)
+               return
+       }
+
+       query := readQuery + where + orderBy + pagination
+       rows, err := inf.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/275)



-- 
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