보안 감사 결과 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>
90 lines
2.9 KiB
JavaScript
90 lines
2.9 KiB
JavaScript
// /js/manage-project.js
|
|
|
|
// The ensureAuthenticated, API, and getAuthHeaders functions are now handled by the global api-helper.js
|
|
|
|
function createRow(item, cols, delHandler) {
|
|
const tr = document.createElement('tr');
|
|
cols.forEach(key => {
|
|
const td = document.createElement('td');
|
|
td.textContent = item[key];
|
|
tr.appendChild(td);
|
|
});
|
|
const delBtn = document.createElement('button');
|
|
delBtn.textContent = '삭제';
|
|
delBtn.className = 'btn-delete';
|
|
delBtn.onclick = () => delHandler(item);
|
|
const td = document.createElement('td');
|
|
td.appendChild(delBtn);
|
|
tr.appendChild(td);
|
|
return tr;
|
|
}
|
|
|
|
const projectForm = document.getElementById('projectForm');
|
|
projectForm?.addEventListener('submit', async e => {
|
|
e.preventDefault();
|
|
const body = {
|
|
job_no: document.getElementById('job_no').value.trim(),
|
|
project_name: document.getElementById('project_name').value.trim(),
|
|
contract_date: document.getElementById('contract_date').value,
|
|
due_date: document.getElementById('due_date').value,
|
|
delivery_method: document.getElementById('delivery_method').value.trim(),
|
|
site: document.getElementById('site').value.trim(),
|
|
pm: document.getElementById('pm').value.trim()
|
|
};
|
|
|
|
if (!body.project_name || !body.job_no) {
|
|
return alert('필수 항목을 입력하세요.');
|
|
}
|
|
|
|
try {
|
|
const result = await apiPost('/projects', body);
|
|
if (result.success) {
|
|
alert('✅ 등록 완료');
|
|
projectForm.reset();
|
|
loadProjects();
|
|
} else {
|
|
alert('❌ 실패: ' + (result.error || '알 수 없는 오류'));
|
|
}
|
|
} catch (err) {
|
|
alert('🚨 서버 오류: ' + err.message);
|
|
}
|
|
});
|
|
|
|
async function loadProjects() {
|
|
const tbody = document.getElementById('projectTableBody');
|
|
tbody.innerHTML = '<tr><td colspan="9">불러오는 중...</td></tr>';
|
|
try {
|
|
const result = await apiGet('/projects');
|
|
|
|
tbody.innerHTML = '';
|
|
|
|
if (result.success && Array.isArray(result.data)) {
|
|
result.data.forEach(item => {
|
|
const row = createRow(item, [
|
|
'project_id', 'job_no', 'project_name', 'contract_date',
|
|
'due_date', 'delivery_method', 'site', 'pm'
|
|
], async p => {
|
|
if (!confirm('삭제하시겠습니까?')) return;
|
|
try {
|
|
const delRes = await apiDelete(`/projects/${p.project_id}`);
|
|
if (delRes.success) {
|
|
alert('✅ 삭제 완료');
|
|
loadProjects();
|
|
} else {
|
|
alert('❌ 삭제 실패: ' + (delRes.error || '알 수 없는 오류'));
|
|
}
|
|
} catch (err) {
|
|
alert('🚨 삭제 중 오류: ' + err.message);
|
|
}
|
|
});
|
|
tbody.appendChild(row);
|
|
});
|
|
} else {
|
|
tbody.innerHTML = '<tr><td colspan="9">데이터 형식 오류</td></tr>';
|
|
}
|
|
} catch (err) {
|
|
tbody.innerHTML = '<tr><td colspan="9">로드 실패: ' + err.message + '</td></tr>';
|
|
}
|
|
}
|
|
|
|
window.addEventListener('DOMContentLoaded', loadProjects); |