ibatis 관련 취약점 진단사항 이행

This commit is contained in:
Rinjae
2026-02-10 12:18:27 +09:00
parent de2aea658d
commit 663f05a522
5 changed files with 27 additions and 18 deletions
@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -33,6 +34,16 @@ public class GlobalExceptionController {
.map(SQLException::getMessage)
.orElse("");
errMsg = errMsg + "중복 KEY 에러발생.\n자세한 사항은 관리자에게 문의바랍니다. ";
} else if (e instanceof DataIntegrityViolationException) {
errMsg = "입력값이 올바르지 않습니다. 필수 항목을 확인해주세요.";
} else if (e instanceof DataAccessException) {
errMsg = "데이터베이스 처리 중 오류가 발생했습니다.";
} else if (e instanceof SQLException) {
errMsg = "데이터베이스 처리 중 오류가 발생했습니다.";
}
if (errMsg != null && (errMsg.contains("NestedSQLException") || errMsg.contains("nested exception"))) {
errMsg = "데이터베이스 처리 중 오류가 발생했습니다.";
}
if (request.getServletPath().endsWith(".json")) {
@@ -46,20 +57,21 @@ public class GlobalExceptionController {
}
}
@ExceptionHandler(RuntimeException.class)
public ModelAndView handleBizException(Exception e, HttpServletRequest request, HttpServletResponse response) {
logger.error("GlobalExceptionController] handleBizException ", e);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
if (request.getServletPath().endsWith(".json")) {
HashMap resultMap = new HashMap();
resultMap.put("status", "fail");
resultMap.put("errorMsg", e.getMessage());
ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
return modelAndView;
} else {
return null;
}
}
// 26.02.10 - 웹취약점 관련(시스템 운영정보 노출, Exception 과 보다 먼저 처리되어 필요성이 없는듯하여 주석으로 삭제 처리
// @ExceptionHandler(RuntimeException.class)
// public ModelAndView handleBizException(Exception e, HttpServletRequest request, HttpServletResponse response) {
// logger.error("GlobalExceptionController] handleBizException ", e);
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
//
// if (request.getServletPath().endsWith(".json")) {
// HashMap resultMap = new HashMap();
// resultMap.put("status", "fail");
// resultMap.put("errorMsg", e.getMessage());
// ModelAndView modelAndView = new ModelAndView("jsonView", resultMap);
// return modelAndView;
// } else {
// return null;
// }
// }
}