HBASE-27792 Guard Master/RS Dump Servlet behind admin walls (#5176)

This commit is contained in:
Nihal Jain 2023-04-25 09:42:01 +05:30 committed by Rajeshbabu Chintaguntla
parent 1b603fad1a
commit 4800976ae3
2 changed files with 8 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.http.HttpServer;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.ServerManager;
import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
@ -46,6 +47,9 @@ public class MasterDumpServlet extends StateDumpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(), request, response)) {
return;
}
HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER);
assert master != null : "No Master in context!";

View File

@ -25,6 +25,7 @@ import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.http.HttpServer;
import org.apache.hadoop.hbase.ipc.CallQueueInfo;
import org.apache.hadoop.hbase.monitoring.StateDumpServlet;
import org.apache.hadoop.hbase.monitoring.TaskMonitor;
@ -42,6 +43,9 @@ public class RSDumpServlet extends StateDumpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(), request, response)) {
return;
}
HRegionServer hrs =
(HRegionServer) getServletContext().getAttribute(HRegionServer.REGIONSERVER);
assert hrs != null : "No RS in context!";