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


##########
traffic_ops/traffic_ops_golang/topology/topologies.go:
##########
@@ -419,6 +591,282 @@
        return nil, nil, 0
 }
 
+func readTopologies(r *http.Request, useIMS bool) ([]interface{}, error, 
error, int, *time.Time) {
+       var maxTime time.Time
+       var runSecond bool
+       inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
+       if userErr != nil || sysErr != nil {
+               return nil, userErr, sysErr, errCode, &maxTime
+       }
+       defer inf.Close()
+
+       interfaces := make([]interface{}, 0)
+
+       queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
+               "name":        {Column: "t.name"},
+               "description": {Column: "t.description"},
+               "lastUpdated": {Column: "t.last_updated"},
+       }
+
+       where, orderBy, pagination, queryValues, errs := 
dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, queryParamsToQueryCols)
+       if len(errs) > 0 {
+               return nil, util.JoinErrs(errs), nil, http.StatusBadRequest, 
&maxTime
+       }
+
+       if useIMS {
+               runSecond, maxTime = ims.TryIfModifiedSinceQuery(inf.Tx, 
r.Header, queryValues, selectMaxLastUpdatedQuery(where))
+               if !runSecond {
+                       log.Debugln("IMS HIT")
+                       return []interface{}{}, nil, nil, 
http.StatusNotModified, &maxTime
+               }
+               log.Debugln("IMS MISS")
+       } else {
+               log.Debugln("Non IMS request")
+       }
+
+       // Case where we need to run the second query
+       query := selectQuery() + 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/300)



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