-
Notifications
You must be signed in to change notification settings - Fork 0
XSS 방지 #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-0.2
Are you sure you want to change the base?
XSS 방지 #55
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.example.auth.global.config; | ||
|
|
||
| public class JacksonConfig { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.example.auth.global.deserializer; | ||
|
|
||
| public class a { | ||
| } | ||
|
Comment on lines
+3
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 컴파일 오류: 파일명과 클래스명이 일치하지 않습니다. Java에서 public 클래스의 이름은 반드시 파일명과 일치해야 합니다. 현재 파일명은 또한, XSS 방지를 위한 실제 구현 로직이 없습니다. 이 클래스는:
다음과 같이 수정하세요: package com.example.auth.global.deserializer;
-public class a {
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import org.apache.commons.text.StringEscapeUtils;
+import java.io.IOException;
+
+public class XssStringJsonDeserializer extends JsonDeserializer<String> {
+ @Override
+ public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
+ String value = p.getValueAsString();
+ if (value == null) {
+ return null;
+ }
+ // XSS 방지를 위해 HTML 특수문자를 이스케이프 처리
+ return StringEscapeUtils.escapeHtml4(value);
+ }
}
🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빈 클래스로는 XSS 방지 기능이 구현되지 않습니다.
이 클래스는 현재 비어있어 XSS 방지 기능을 제공하지 않습니다. PR 목적이 "XSS 방지"인 것을 고려하면, 다음 사항들이 필요합니다:
@Configuration어노테이션 추가ObjectMapper빈 정의 및 커스텀 XSS deserializer 등록XssStringJsonDeserializer를 Jackson 모듈에 등록다음과 같은 구현을 제안합니다: