Skip to content

Commit

Permalink
hide full stacktrace info in error message (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
mornyx authored Sep 18, 2023
1 parent eb87a09 commit e11f2b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions util/rest/context_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"github.com/gin-gonic/gin"
"github.com/joomcode/errorx"

"github.com/pingcap/tidb-dashboard/util/jsonserde/ginadapter"
)
Expand All @@ -16,7 +15,8 @@ import (
// Otherwise there will be no error message written to the client.
// See `ErrorHandlerFn` for more details.
func Error(c *gin.Context, err error) {
_ = c.Error(errorx.EnsureStackTrace(err))
// For security reasons, we need to hide detailed stacktrace info.
_ = c.Error(err) // before: c.Error(errorx.EnsureStackTrace(err))
}

// JSON writes a JSON string to the client with the given status code.
Expand Down
9 changes: 5 additions & 4 deletions util/rest/error_resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ func buildDetailMessage(err error) string {

func NewErrorResponse(err error) ErrorResponse {
return ErrorResponse{
Error: true,
Message: buildSimpleMessage(err),
Code: removeErrorPrefix(buildCode(err)),
FullText: buildDetailMessage(err),
Error: true,
Message: buildSimpleMessage(err),
Code: removeErrorPrefix(buildCode(err)),
// For security reasons, we need to hide detailed stacktrace info.
// FullText: buildDetailMessage(err),
}
}

0 comments on commit e11f2b2

Please sign in to comment.