github-code-scanning[bot] commented on code in PR #7570:
URL: https://github.com/apache/trafficcontrol/pull/7570#discussion_r1223565360
##########
traffic_ops/traffic_ops_golang/deliveryservice/request/comment/comments.go:
##########
@@ -186,3 +199,257 @@
func deleteQuery() string {
return `DELETE FROM deliveryservice_request_comment WHERE id = :id`
}
+
+// Get is used to read the DeliveryServiceRequestCommentV5 entities from the
database.
+func Get(w http.ResponseWriter, r *http.Request) {
+ var maxTime time.Time
+ var runSecond bool
+ 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()
+
+ api.DefaultSort(inf, "xmlId")
+ cols := map[string]dbhelpers.WhereColumnInfo{
+ "authorId": dbhelpers.WhereColumnInfo{Column:
"dsrc.author_id"},
+ "author": dbhelpers.WhereColumnInfo{Column:
"a.username"},
+ "deliveryServiceRequestId": dbhelpers.WhereColumnInfo{Column:
"dsrc.deliveryservice_request_id"},
+ "id": dbhelpers.WhereColumnInfo{Column:
"dsrc.id", Checker: api.IsInt},
+ }
+
+ 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
+ }
+
+ if inf.Config.UseIMS {
+ runSecond, maxTime = ims.TryIfModifiedSinceQuery(inf.Tx,
r.Header, queryValues, selectMaxLastUpdatedQuery(where, orderBy, pagination))
+ 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")
+ }
+
+ deliveryServiceRequestComments := []tc.DeliveryServiceRequestCommentV5{}
+ 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/277)
--
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]