Skip to content

Commit

Permalink
RHINENG-12951: fix for CWE-918
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMraka committed Oct 4, 2024
1 parent 158b4b0 commit a037dea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions turnpike/controllers/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"net/http"
"regexp"
"slices"
"strconv"
"time"

Expand Down Expand Up @@ -293,14 +294,17 @@ func GetManagerPprof(c *gin.Context) {
func pprofHandler(c *gin.Context, address string) {
query := c.Request.URL.RawQuery
param := c.Param("param")
// data, err := getPprof(address, url.QueryEscape(param), query)
data, err := getPprof(address, "", query)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
if slices.Contains([]string{"heap", "profile", "block", "mutex", "trace"}, param) {
data, err := getPprof(address, param, query)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"err": err.Error()})
return
}
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", param))
c.Data(http.StatusOK, "application/octet-stream", data)
return
}
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", param))
c.Data(http.StatusOK, "application/octet-stream", data)
c.Status(http.StatusBadRequest)
}

func getPprof(address, param, query string) ([]byte, error) {
Expand Down

0 comments on commit a037dea

Please sign in to comment.