security: 보안 강제 시스템 구축 + 하드코딩 비밀번호 제거

보안 감사 결과 CRITICAL 2건, HIGH 5건 발견 → 수정 완료 + 자동화 구축.

[보안 수정]
- issue-view.js: 하드코딩 비밀번호 → crypto.getRandomValues() 랜덤 생성
- pushSubscriptionController.js: ntfy 비밀번호 → process.env.NTFY_SUB_PASSWORD
- DEPLOY-GUIDE.md/PROGRESS.md/migration SQL: 평문 비밀번호 → placeholder
- docker-compose.yml/.env.example: NTFY_SUB_PASSWORD 환경변수 추가

[보안 강제 시스템 - 신규]
- scripts/security-scan.sh: 8개 규칙 (CRITICAL 2, HIGH 4, MEDIUM 2)
  3모드(staged/all/diff), severity, .securityignore, MEDIUM 임계값
- .githooks/pre-commit: 로컬 빠른 피드백
- .githooks/pre-receive-server.sh: Gitea 서버 최종 차단
  bypass 거버넌스([SECURITY-BYPASS: 사유] + 사용자 제한 + 로그)
- SECURITY-CHECKLIST.md: 10개 카테고리 자동/수동 구분
- docs/SECURITY-GUIDE.md: 운영자 가이드 (워크플로우, bypass, FAQ)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-04-10 09:44:21 +09:00
parent bbffa47a9d
commit ba9ef32808
257 changed files with 786 additions and 18 deletions

View File

@@ -0,0 +1,225 @@
/**
* Work Analysis API Client Module
* 작업 분석 관련 모든 API 호출을 관리하는 모듈
*/
class WorkAnalysisAPIClient {
constructor() {
this.baseURL = window.API_BASE_URL || 'http://localhost:30005/api';
}
/**
* 기본 API 호출 메서드
* @param {string} endpoint - API 엔드포인트
* @param {string} method - HTTP 메서드
* @param {Object} data - 요청 데이터
* @returns {Promise<Object>} API 응답
*/
async apiCall(endpoint, method = 'GET', data = null) {
try {
const config = {
method,
headers: {
'Content-Type': 'application/json',
}
};
if (data && method !== 'GET') {
config.body = JSON.stringify(data);
}
const response = await fetch(`${this.baseURL}${endpoint}`, config);
const result = await response.json();
if (!response.ok) {
throw new Error(result.message || `HTTP ${response.status}`);
}
return result;
} catch (error) {
console.error(` API 실패: ${this.baseURL}${endpoint}`, error);
throw error;
}
}
/**
* 날짜 범위 파라미터 생성
* @param {string} startDate - 시작일
* @param {string} endDate - 종료일
* @param {Object} additionalParams - 추가 파라미터
* @returns {URLSearchParams} URL 파라미터
*/
createDateParams(startDate, endDate, additionalParams = {}) {
const params = new URLSearchParams({
start: startDate,
end: endDate,
...additionalParams
});
return params;
}
// ========== 기본 통계 API ==========
/**
* 기본 통계 조회
*/
async getBasicStats(startDate, endDate, projectId = null) {
const params = this.createDateParams(startDate, endDate,
projectId ? { project_id: projectId } : {}
);
return await this.apiCall(`/work-analysis/stats?${params}`);
}
/**
* 일별 추이 조회
*/
async getDailyTrend(startDate, endDate, projectId = null) {
const params = this.createDateParams(startDate, endDate,
projectId ? { project_id: projectId } : {}
);
return await this.apiCall(`/work-analysis/daily-trend?${params}`);
}
/**
* 작업자별 통계 조회
*/
async getWorkerStats(startDate, endDate, projectId = null) {
const params = this.createDateParams(startDate, endDate,
projectId ? { project_id: projectId } : {}
);
return await this.apiCall(`/work-analysis/worker-stats?${params}`);
}
/**
* 프로젝트별 통계 조회
*/
async getProjectStats(startDate, endDate) {
const params = this.createDateParams(startDate, endDate);
return await this.apiCall(`/work-analysis/project-stats?${params}`);
}
// ========== 상세 분석 API ==========
/**
* 프로젝트별-작업유형별 분석
*/
async getProjectWorkTypeAnalysis(startDate, endDate, limit = 2000) {
const params = this.createDateParams(startDate, endDate, { limit });
return await this.apiCall(`/work-analysis/project-worktype-analysis?${params}`);
}
/**
* 최근 작업 데이터 조회
*/
async getRecentWork(startDate, endDate, limit = 2000) {
const params = this.createDateParams(startDate, endDate, { limit });
return await this.apiCall(`/work-analysis/recent-work?${params}`);
}
/**
* 오류 분석 데이터 조회
*/
async getErrorAnalysis(startDate, endDate) {
const params = this.createDateParams(startDate, endDate);
return await this.apiCall(`/work-analysis/error-analysis?${params}`);
}
// ========== 배치 API 호출 ==========
/**
* 여러 API를 병렬로 호출
* @param {Array} apiCalls - API 호출 배열
* @returns {Promise<Array>} 결과 배열
*/
async batchCall(apiCalls) {
const promises = apiCalls.map(async ({ name, method, ...args }) => {
try {
const result = await this[method](...args);
return { name, success: true, data: result };
} catch (error) {
console.warn(` ${name} API 오류:`, error);
return { name, success: false, error: error.message, data: null };
}
});
const results = await Promise.all(promises);
return results.reduce((acc, result) => {
acc[result.name] = result;
return acc;
}, {});
}
/**
* 차트 데이터를 위한 배치 호출
*/
async getChartData(startDate, endDate, projectId = null) {
return await this.batchCall([
{
name: 'dailyTrend',
method: 'getDailyTrend',
startDate,
endDate,
projectId
},
{
name: 'workerStats',
method: 'getWorkerStats',
startDate,
endDate,
projectId
},
{
name: 'projectStats',
method: 'getProjectStats',
startDate,
endDate
},
{
name: 'errorAnalysis',
method: 'getErrorAnalysis',
startDate,
endDate
}
]);
}
/**
* 프로젝트 분포 분석을 위한 배치 호출
*/
async getProjectDistributionData(startDate, endDate) {
return await this.batchCall([
{
name: 'projectWorkType',
method: 'getProjectWorkTypeAnalysis',
startDate,
endDate
},
{
name: 'workerStats',
method: 'getWorkerStats',
startDate,
endDate
},
{
name: 'recentWork',
method: 'getRecentWork',
startDate,
endDate
}
]);
}
}
// 전역 인스턴스 생성
window.WorkAnalysisAPI = new WorkAnalysisAPIClient();
// 하위 호환성을 위한 전역 함수
window.apiCall = (endpoint, method, data) => {
return window.WorkAnalysisAPI.apiCall(endpoint, method, data);
};
// Export는 브라우저 환경에서 제거됨