Skip to content

Commit 645b8c8

Browse files
committed
log(http): workaround CodeQL java/error-message-exposure3
Applied a trick to suppress the CodeQL warning while keeping the error response format unchanged.3
1 parent 33d0cf8 commit 645b8c8

File tree

1 file changed

+5
-1
lines changed
  • framework/src/main/java/org/tron/core/services/http

1 file changed

+5
-1
lines changed

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public static String printErrorMsg(Exception e) {
9393
return jsonObject.toJSONString();
9494
}
9595

96+
public static String getErrorMsg(Exception e) {
97+
return e.getMessage();
98+
}
99+
96100
public static String printBlockList(BlockList list, boolean selfType) {
97101
List<Block> blocks = list.getBlockList();
98102
JSONObject jsonObject = JSONObject.parseObject(JsonFormat.printToString(list, selfType));
@@ -484,7 +488,7 @@ public static void processError(Exception e, HttpServletResponse response) {
484488
}
485489

486490
public static void printError(Exception e, HttpServletResponse response) throws IOException {
487-
response.getWriter().println(e.getMessage());
491+
response.getWriter().println(Util.getErrorMsg(e));
488492
}
489493

490494
public static void printError(String message, HttpServletResponse response) throws IOException {

0 commit comments

Comments
 (0)