You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "github-code-scanning[bot] (via GitHub)" <gi...@apache.org> on 2023/07/03 16:08:18 UTC
[GitHub] [trafficcontrol] github-code-scanning[bot] commented on a diff in pull request #7612: Fixes Divisions V5 apis to respond with RFC3339 date/time Format
github-code-scanning[bot] commented on code in PR #7612:
URL: https://github.com/apache/trafficcontrol/pull/7612#discussion_r1251078222
##########
traffic_ops/traffic_ops_golang/division/divisions.go:
##########
@@ -137,3 +143,238 @@
func deleteQuery() string {
return `DELETE FROM division WHERE id=:id`
}
+
+func GetDivisions(w http.ResponseWriter, r *http.Request) {
+ var runSecond bool
+ var maxTime time.Time
+ 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{
+ "id": {Column: "d.id", Checker: nil},
+ "name": {Column: "d.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
+ }
+
+ if inf.Config.UseIMS {
+ runSecond, maxTime = ims.TryIfModifiedSinceQuery(tx, r.Header, queryValues, selectMaxLastUpdatedQuery(where))
+ if !runSecond {
+ log.Debugln("IMS HIT")
+ api.AddLastModifiedHdr(w, maxTime)
+ w.WriteHeader(http.StatusNotModified)
+ return
+ }
+ log.Debugln("IMS MISS")
+ } else {
+ log.Debugln("Non IMS request")
+ }
+
+ selectQuery := "SELECT id, name, last_updated FROM division d"
+ 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/285)
--
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: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org