fix: 보안 취약점 수정 및 XSS 방지 적용
## 백엔드 보안 수정 - 하드코딩된 비밀번호 및 JWT 시크릿 폴백 제거 - SQL Injection 방지를 위한 화이트리스트 검증 추가 - 인증 미적용 API 라우트에 requireAuth 미들웨어 적용 - CSRF 보호 미들웨어 구현 (csrf.js) - 파일 업로드 보안 유틸리티 추가 (fileUploadSecurity.js) - 비밀번호 정책 검증 유틸리티 추가 (passwordValidator.js) ## 프론트엔드 XSS 방지 - api-base.js에 전역 escapeHtml() 함수 추가 - 17개 주요 JS 파일에 escapeHtml 적용: - tbm.js, daily-patrol.js, daily-work-report.js - task-management.js, workplace-status.js - equipment-detail.js, equipment-management.js - issue-detail.js, issue-report.js - vacation-common.js, worker-management.js - safety-report-list.js, nonconformity-list.js - project-management.js, workplace-management.js ## 정리 - 백업 폴더 및 빈 파일 삭제 - SECURITY_GUIDE.md 문서 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,7 @@ exports.createProject = asyncHandler(async (req, res) => {
|
||||
|
||||
logger.info('프로젝트 생성 요청', { name: projectData.name });
|
||||
|
||||
const id = await new Promise((resolve, reject) => {
|
||||
projectModel.create(projectData, (err, lastID) => {
|
||||
if (err) reject(new DatabaseError('프로젝트 생성 중 오류가 발생했습니다'));
|
||||
else resolve(lastID);
|
||||
});
|
||||
});
|
||||
const id = await projectModel.create(projectData);
|
||||
|
||||
// 프로젝트 캐시 무효화
|
||||
await cache.invalidateCache.project();
|
||||
@@ -44,12 +39,7 @@ exports.createProject = asyncHandler(async (req, res) => {
|
||||
* 전체 프로젝트 조회
|
||||
*/
|
||||
exports.getAllProjects = asyncHandler(async (req, res) => {
|
||||
const rows = await new Promise((resolve, reject) => {
|
||||
projectModel.getAll((err, data) => {
|
||||
if (err) reject(new DatabaseError('프로젝트 목록 조회 중 오류가 발생했습니다'));
|
||||
else resolve(data);
|
||||
});
|
||||
});
|
||||
const rows = await projectModel.getAll();
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
@@ -62,12 +52,7 @@ exports.getAllProjects = asyncHandler(async (req, res) => {
|
||||
* 활성 프로젝트만 조회 (작업보고서용)
|
||||
*/
|
||||
exports.getActiveProjects = asyncHandler(async (req, res) => {
|
||||
const rows = await new Promise((resolve, reject) => {
|
||||
projectModel.getActiveProjects((err, data) => {
|
||||
if (err) reject(new DatabaseError('활성 프로젝트 목록 조회 중 오류가 발생했습니다'));
|
||||
else resolve(data);
|
||||
});
|
||||
});
|
||||
const rows = await projectModel.getActiveProjects();
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
@@ -86,12 +71,7 @@ exports.getProjectById = asyncHandler(async (req, res) => {
|
||||
throw new ValidationError('유효하지 않은 프로젝트 ID입니다');
|
||||
}
|
||||
|
||||
const row = await new Promise((resolve, reject) => {
|
||||
projectModel.getById(id, (err, data) => {
|
||||
if (err) reject(new DatabaseError('프로젝트 조회 중 오류가 발생했습니다'));
|
||||
else resolve(data);
|
||||
});
|
||||
});
|
||||
const row = await projectModel.getById(id);
|
||||
|
||||
if (!row) {
|
||||
throw new NotFoundError('프로젝트를 찾을 수 없습니다');
|
||||
@@ -116,12 +96,7 @@ exports.updateProject = asyncHandler(async (req, res) => {
|
||||
|
||||
const data = { ...req.body, project_id: id };
|
||||
|
||||
const changes = await new Promise((resolve, reject) => {
|
||||
projectModel.update(data, (err, ch) => {
|
||||
if (err) reject(new DatabaseError('프로젝트 수정 중 오류가 발생했습니다'));
|
||||
else resolve(ch);
|
||||
});
|
||||
});
|
||||
const changes = await projectModel.update(data);
|
||||
|
||||
if (changes === 0) {
|
||||
throw new NotFoundError('프로젝트를 찾을 수 없습니다');
|
||||
@@ -149,12 +124,7 @@ exports.removeProject = asyncHandler(async (req, res) => {
|
||||
throw new ValidationError('유효하지 않은 프로젝트 ID입니다');
|
||||
}
|
||||
|
||||
const changes = await new Promise((resolve, reject) => {
|
||||
projectModel.remove(id, (err, ch) => {
|
||||
if (err) reject(new DatabaseError('프로젝트 삭제 중 오류가 발생했습니다'));
|
||||
else resolve(ch);
|
||||
});
|
||||
});
|
||||
const changes = await projectModel.remove(id);
|
||||
|
||||
if (changes === 0) {
|
||||
throw new NotFoundError('프로젝트를 찾을 수 없습니다');
|
||||
|
||||
Reference in New Issue
Block a user