Swagger에 광주은행 OAuth 2.0 API 문서 업데이트 및 XSS 방지 처리 추가

This commit is contained in:
Rinjae
2026-02-25 19:22:47 +09:00
parent 220b4f3cfd
commit 1ed6630261
4 changed files with 76 additions and 27 deletions
-14
View File
@@ -415,18 +415,4 @@ var jsonlint = (function(){
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parser = jsonlint;
exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }
exports.main = function commonjsMain(args) {
if (!args[1])
throw new Error('Usage: '+args[0]+' FILE');
if (typeof process !== 'undefined') {
var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
} else {
var cwd = require("file").path(require("file").cwd());
var source = cwd.join(args[1]).read({charset: "utf-8"});
}
return exports.parser.parse(source);
}
if (typeof module !== 'undefined' && require.main === module) {
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
}
}
@@ -1,12 +1,48 @@
const customPopups = {
/**
* HTML 새니타이저 - 허용된 태그만 통과시키고 나머지는 제거
* XSS 방지를 위해 script, event handler 등 위험 요소를 제거합니다.
* @param {string} input - 새니타이즈할 문자열
* @returns {string} 새니타이즈된 HTML 문자열
*/
_sanitizeHtml: function (input) {
if (!input) return '';
var allowedTags = ['br', 'strong', 'b', 'em', 'i', 'span', 'p'];
var div = document.createElement('div');
div.innerHTML = input;
// script, style, iframe, object, embed, form 등 위험 요소 제거
var dangerousTags = div.querySelectorAll('script, style, iframe, object, embed, form, link, meta, base');
for (var i = dangerousTags.length - 1; i >= 0; i--) {
dangerousTags[i].parentNode.removeChild(dangerousTags[i]);
}
// 허용되지 않은 태그는 텍스트 노드로 대체
var allElements = div.querySelectorAll('*');
for (var j = allElements.length - 1; j >= 0; j--) {
var el = allElements[j];
if (allowedTags.indexOf(el.tagName.toLowerCase()) === -1) {
var textNode = document.createTextNode(el.textContent);
el.parentNode.replaceChild(textNode, el);
} else {
// 허용된 태그라도 모든 속성 제거 (on* 이벤트 핸들러 등 방지)
while (el.attributes.length > 0) {
el.removeAttribute(el.attributes[0].name);
}
}
}
return div.innerHTML;
},
/**
* 알림 팝업 표시
* @param {string} message - 알림 메시지
* @param {Function} callback - 확인 버튼 클릭 시 호출되는 콜백 (선택사항)
*/
showAlert: function (message, callback) {
// 메시지 설정
$('#customAlertMessage').html(message);
// 메시지 설정 (XSS 방지를 위해 새니타이즈)
$('#customAlertMessage').html(customPopups._sanitizeHtml(message));
// 팝업 표시 (modal 구조 사용)
$('#customAlert').show();
@@ -100,9 +136,9 @@ const customPopups = {
const onConfirm = options.onConfirm;
const onCancel = options.onCancel;
// 팝업 내용 설정
// 팝업 내용 설정 (XSS 방지를 위해 새니타이즈)
$('#passwordPopupTitle').text(title);
$('#passwordPopupMessage').html(message);
$('#passwordPopupMessage').html(customPopups._sanitizeHtml(message));
// 입력 필드 및 에러 초기화
$('#passwordPopupInput').val('').removeClass('error');
@@ -215,8 +251,8 @@ const customPopups = {
* @param {Function} callback - 버튼 클릭 시 호출되는 콜백 (파라미터: boolean - true는 확인, false는 취소)
*/
showConfirm: function (message, callback) {
// 메시지 설정
$('#customConfirmMessage').html(message);
// 메시지 설정 (XSS 방지를 위해 새니타이즈)
$('#customConfirmMessage').html(customPopups._sanitizeHtml(message));
// 팝업 표시 (modal 구조 사용)
$('#customConfirm').show();
@@ -302,7 +338,7 @@ const customPopups = {
$(document).off('keydown.customConfirmEsc');
},
showEmailValidationPopup: function (message, onConvertCallback, onChangeEmailCallback) {
$('#emailValidationPopupMessage').html(message);
$('#emailValidationPopupMessage').html(customPopups._sanitizeHtml(message));
$('#emailValidationPopup').css('display', 'flex');
$('#emailConvertButton').one('click', function () {
@@ -320,7 +356,7 @@ const customPopups = {
});
},
showEmailResendPopup: function (message, loginId) {
$('#emailResendMessage').html(message);
$('#emailResendMessage').html(customPopups._sanitizeHtml(message));
$('#userLoginId').val(loginId);
$('#emailResend').show();
},