Skip to content

Commit 529b122

Browse files
TEZ-4741: ProfileOutputServlet: require instrumentation ACL to read profiler output
1 parent 74bb821 commit 529b122

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

tez-common/src/main/java/org/apache/tez/common/web/ProfileOutputServlet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import javax.servlet.http.HttpServletRequest;
3030
import javax.servlet.http.HttpServletResponse;
3131

32+
import org.apache.hadoop.http.HttpServer2;
3233
import org.apache.hadoop.yarn.webapp.MimeType;
3334

3435
import org.eclipse.jetty.servlet.DefaultServlet;
@@ -40,6 +41,11 @@ public class ProfileOutputServlet extends DefaultServlet {
4041
public static final String FILE_QUERY_PARAM = "file";
4142

4243
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
44+
if (!HttpServer2.isInstrumentationAccessAllowed(this.getServletContext(), request, response)) {
45+
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
46+
writeMessage(response, ProfileServlet.ACCESS_DENIED_MESSAGE);
47+
return;
48+
}
4349
String queriedFile = request.getParameter(FILE_QUERY_PARAM);
4450
if (queriedFile == null) {
4551
writeMessage(response, "Run the profiler to be able to receive its output");

tez-common/src/main/java/org/apache/tez/common/web/ProfileServlet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public class ProfileServlet extends HttpServlet {
9999
private static final String ALLOWED_METHODS = "GET";
100100
private static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
101101
private static final String CONTENT_TYPE_TEXT = "text/plain; charset=utf-8";
102+
103+
public static final String ACCESS_DENIED_MESSAGE = "Unauthorized: Instrumentation access is not allowed!";
102104
private static final String ASYNC_PROFILER_HOME_ENV = "ASYNC_PROFILER_HOME";
103105
private static final String ASYNC_PROFILER_HOME_SYSTEM_PROPERTY = "async.profiler.home";
104106
private static final int DEFAULT_DURATION_SECONDS = 10;
@@ -165,7 +167,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
165167
if (!HttpServer2.isInstrumentationAccessAllowed(this.getServletContext(), request, response)) {
166168
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
167169
setResponseHeader(response);
168-
out.println("Unauthorized: Instrumentation access is not allowed!");
170+
out.println(ACCESS_DENIED_MESSAGE);
169171
out.close();
170172
return;
171173
}

0 commit comments

Comments
 (0)