Skip to content

Commit

Permalink
clusterinfo: fix ssrf on /topology/alertmanager/{address}/count (#1738)
Browse files Browse the repository at this point in the history
Signed-off-by: mornyx <[email protected]>
  • Loading branch information
mornyx authored Sep 25, 2024
1 parent 618b5cd commit 55d41b6
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 @@ -291,6 +291,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 55d41b6

Please sign in to comment.