From e0a6341756852cd44f101dd68ad35e7930afc857 Mon Sep 17 00:00:00 2001 From: limju Date: Tue, 14 Nov 2023 18:06:16 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20batch=20https=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=20=20=20=20=20=20profile=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/xit/core/aop/TraceLoggerAspect.java | 25 +++++++++++- .../src/main/resources/logback-spring.xml | 39 +++++++------------ .../src/main/resources/logback-spring.xml | 38 +++++++----------- .../logback/LogbackMaskingPatternLayout.java | 18 ++------- 4 files changed, 57 insertions(+), 63 deletions(-) diff --git a/mens-api/src/main/java/kr/xit/core/aop/TraceLoggerAspect.java b/mens-api/src/main/java/kr/xit/core/aop/TraceLoggerAspect.java index c2a33d2..bd13fe9 100644 --- a/mens-api/src/main/java/kr/xit/core/aop/TraceLoggerAspect.java +++ b/mens-api/src/main/java/kr/xit/core/aop/TraceLoggerAspect.java @@ -325,14 +325,37 @@ log.info("@@@@@@@@@@@@@@@@@로깅 start : [\n{}\n]",MDC.getCopyOfContextMap()); } } + @SuppressWarnings("unchecked") private JSONObject getParams(HttpServletRequest request) { JSONObject jsonObject = new JSONObject(); Enumeration params = request.getParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); String replaceParam = param.replaceAll("\\.", "-"); - jsonObject.put(replaceParam, request.getParameter(param)); + jsonObject.put(replaceParam, maskingParam(replaceParam, request.getParameter(param))); } return jsonObject; } + + private String maskingParam(final String key, final String value){ + if("juminId".equals(key)) { + if(value.length() == 14) { + return value.replaceAll("([0-9]{6})-([1-4]{1})([0-9]{6})", "$1-$2******"); + } + return value.replaceAll("([0-9]{6})([1-4]{1})([0-9]{6})", "$1$2******"); + } + if("telNo".equals(key)) { + if(value.contains("-")){ + return value.replaceAll("-[0-9]{3,4}-", "-****-"); + }; + return value.replaceAll("([0-9]{3})([0-9]{4})([0-9]{4})", "$1$2****"); + } + if("email".equals(key)) { + return value.replaceAll("[a-z,A-Z,0-9]+@", "******@"); + } + if("name".equals(key)) { + return value.replaceAll("(?<=.{1}).", "*"); + } + return value; + } } diff --git a/mens-api/src/main/resources/logback-spring.xml b/mens-api/src/main/resources/logback-spring.xml index 1a30325..e5ae60d 100644 --- a/mens-api/src/main/resources/logback-spring.xml +++ b/mens-api/src/main/resources/logback-spring.xml @@ -33,8 +33,6 @@ - - @@ -54,13 +52,7 @@ ${FILE_LOG_PATTERN} ${FILE_LOG_CHARSET} - + ${LOG_PATH}/backup/${LOG_FILE}_%d{yyyy-MM-dd}.%i.log.gz @@ -68,14 +60,6 @@ 50 - @@ -98,15 +82,22 @@ - - - + + + + + + \"juminId\"\s*:\s*\"(.*?)\" + \"recveJuminno\"\s*:\s*\"(.*?)\" + \"recevAddr\"\s*:\s*\"(.*?)\" + \"recevDetailAddr\"\s*:\s*\"(.*?)\" + %-5p [%d{ISO8601,UTC}] [%thread] %c: %m%n%rootException + + - --> + diff --git a/mens-batch/src/main/resources/logback-spring.xml b/mens-batch/src/main/resources/logback-spring.xml index 1a30325..1d2806f 100644 --- a/mens-batch/src/main/resources/logback-spring.xml +++ b/mens-batch/src/main/resources/logback-spring.xml @@ -33,8 +33,6 @@ - - @@ -54,13 +52,7 @@ ${FILE_LOG_PATTERN} ${FILE_LOG_CHARSET} - + ${LOG_PATH}/backup/${LOG_FILE}_%d{yyyy-MM-dd}.%i.log.gz @@ -68,14 +60,6 @@ 50 - @@ -98,15 +82,21 @@ - - - + + + + + + \"recveJuminno\"\s*:\s*\"(.*?)\" + \"recevAddr\"\s*:\s*\"(.*?)\" + \"recevDetailAddr\"\s*:\s*\"(.*?)\" + %-5p [%d{ISO8601,UTC}] [%thread] %c: %m%n%rootException + + - --> + diff --git a/mens-core/src/main/java/kr/xit/core/support/logback/LogbackMaskingPatternLayout.java b/mens-core/src/main/java/kr/xit/core/support/logback/LogbackMaskingPatternLayout.java index 5583372..f134c39 100644 --- a/mens-core/src/main/java/kr/xit/core/support/logback/LogbackMaskingPatternLayout.java +++ b/mens-core/src/main/java/kr/xit/core/support/logback/LogbackMaskingPatternLayout.java @@ -1,16 +1,16 @@ package kr.xit.core.support.logback; +import ch.qos.logback.classic.PatternLayout; +import ch.qos.logback.classic.spi.ILoggingEvent; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.IntStream; - /** - * logback log masking *
+ * description : logback log masking
  * 
  *     
  *         
@@ -22,14 +22,6 @@ import java.util.stream.IntStream;
  *         
  *     
  * 
- * 
- */ -/** - *
- * description : logback log에서
- *               1) SQL 기본로그중  "==>  Preparing: " 제외
- *               2) 파라메터 출력 로그 "==> Parameters: " 제외
- *               3) Hibernate SQL 로그 제외 : org.hibernate.SQL org.hibernate.type.descriptor.sql
  * packageName : kr.xit.core.support.logback
  * fileName    : ExcloudLogFilter
  * author      : julim
@@ -42,7 +34,6 @@ import java.util.stream.IntStream;
  * 
* @see ch.qos.logback.core.filter.Filter */ -/* public class LogbackMaskingPatternLayout extends PatternLayout { private Pattern multilinePattern; @@ -50,7 +41,7 @@ public class LogbackMaskingPatternLayout extends PatternLayout { public void addMaskPattern(String maskPattern) { maskPatterns.add(maskPattern); - multilinePattern = Pattern.compile(maskPatterns.stream().collect(Collectors.joining("|")), Pattern.MULTILINE); + multilinePattern = Pattern.compile(String.join("|", maskPatterns), Pattern.MULTILINE); } @Override @@ -74,4 +65,3 @@ public class LogbackMaskingPatternLayout extends PatternLayout { return sb.toString(); } } -*/