Skip to content

Commit

Permalink
clusterinfo: fix ssrf on /topology/alertmanager/{address}/count (#1739)
Browse files Browse the repository at this point in the history
Signed-off-by: mornyx <[email protected]>
Co-authored-by: mornyx <[email protected]>
  • Loading branch information
ti-chi-bot and mornyx authored Sep 25, 2024
1 parent 6f3f972 commit ec6d999
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/apiserver/clusterinfo/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,23 @@ func (s *Service) getGrafanaTopology(c *gin.Context) {
// @Failure 401 {object} rest.ErrorResponse
func (s *Service) getAlertManagerCounts(c *gin.Context) {
address := c.Param("address")
if address == "" {
rest.Error(c, rest.ErrBadRequest.New("address is empty"))
return
}
info, err := topology.FetchAlertManagerTopology(c.Request.Context(), s.params.EtcdClient)
if err != nil {
rest.Error(c, err)
return
}
if info == nil {
rest.Error(c, rest.ErrBadRequest.New("alertmanager not found"))
return
}
if address != fmt.Sprintf("%s:%d", info.IP, info.Port) {
rest.Error(c, rest.ErrBadRequest.New("address not match"))
return
}
cnt, err := fetchAlertManagerCounts(s.lifecycleCtx, address, s.params.HTTPClient)
if err != nil {
rest.Error(c, err)
Expand Down

0 comments on commit ec6d999

Please sign in to comment.