Files
Gnuboard7/tests/Playwright/specs/layout-editor/modal-edit-confine.spec.ts
T
HeuJung 71abdeaf60 fix(security): KVE-2026-1914/1915/1919 remediation 전건
위임 관리자(부관리자)가 권한·역할·표현식·비밀 콘텐츠 경계를 우회하던
결함군을 계층 대칭성 원칙으로 전건 차단한다. 약한 경로가 정상 응답을
내보내는 것이 유일한 증상이라, 게이트를 생산 지점 한 곳(SSoT)에 두고
같은 데이터를 내보내는 소비 경로 전부가 그 게이트를 경유하도록 맞췄다.

- 등급 상한(rank ceiling): 슈퍼관리자 보호·역할/사용자 역할 배정(추가·제거
 대칭)·일괄 상태변경·순서변경을 상세 경로와 동일 강도로 재적용. 가드는
 DB 쓰기에 선행하여 거부 시 상태 불변.
- 레이아웃 표현식: new Function/with 실행을 AST 화이트리스트 평가기로 교체.
 비-문자열 computed 키 정규화(normalizeKey)·Object facade(리플렉션 static
 제거)·legacy 접근자 차단. 저장측 검증·정적 검사와 3계층 동형.
- secret 게이트: 비밀글의 댓글·첨부·문의 독립 경로 재적용, hash 파일서빙
 소유권·비밀·발행 상태 검사 통일.
- 신뢰 스크립트 호스트: 확장 선언 기반 + same-origin 브라우저 정규화를
 런타임·저장측·정적검사 3층 동형화.
- 회귀 감지: 단위·Feature·E2E·시나리오 매니페스트 전축 + audit 룰 4종 신설.
2026-08-17 01:45:09 +09:00

96 lines
5.2 KiB
TypeScript

/**
* Layout Editor — 모달 편집 트리 노출 + 딤/DnD confine
*
* sirsoft-basic 은 모든 모달을 partial 파일로 분리한다. 종전엔 `[모달]`·"이 화면의 모달" 그룹이
* 비어 모달을 편집할 경로가 없었고, 모달 편집 진입 시 딤(잠긴 호스트) 영역으로 드래그/드롭이
* 가능했으며, `_user_base` 모달 저장이 extension_point 검증으로 422 였다.
*
* 축 요약(마커 아님 — 평문): edit_mode, url_sync, dnd_confine.
* 효과 요약(마커 아님 — 평문): modal_collection_includes_partial_modals, modal_edit_renders_dim_and_blocker, dnd_handles_confined_to_modal_subtree, modal_edit_exit_clears_dim.
*/
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
const TEMPLATE = 'sirsoft-basic';
const EDITOR_URL = `/admin/layout-editor/${TEMPLATE}`;
// _user_base 호스트의 partial 모달 — 수정 후 트리/편집 노출 대상.
const MODAL_DIRECT_URL = `${EDITOR_URL}?edit=__modal__/notification_delete_all_confirm_modal&host=_user_base`;
async function enterEditor(page: import('@playwright/test').Page, url: string): Promise<void> {
const token = issueToken('core.templates.layouts.edit');
await authenticatePage(page, token);
await page.goto(url);
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
await page.waitForSelector('[data-testid="g7le-toolbar"]', { timeout: 30_000 });
}
test.describe('@layout-editor 모달 편집 confine', () => {
/** @effects modal_collection_includes_partial_modals */
test('편집기 routes 응답이 partial 모달을 수집(트리 노출 SSoT)', async ({ page }) => {
// 백엔드 모달 수집(collectEditorBaseAndModals)이 partial 참조 + 하위 디렉토리까지 읽어
// 모달을 반환하는지 검증 — 트리 [모달]/"이 화면의 모달" 그룹의 데이터 출처. locale 무관.
await enterEditor(page, EDITOR_URL);
const result = await page.evaluate(async (tpl) => {
// 가드 엔드포인트(editor/routes.json)는 Bearer 토큰 필요 — 편집기 buildAuthHeaders 와 동일.
const authToken = localStorage.getItem('auth_token');
const res = await fetch(`/api/admin/templates/${tpl}/editor/routes.json`, {
headers: {
Accept: 'application/json',
...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),
},
credentials: 'same-origin',
});
const body = await res.json();
const modals = body?.data?.modals ?? [];
return {
ok: res.ok,
modalCount: modals.length,
hosts: [...new Set(modals.map((m: { host_layout: string }) => m.host_layout))],
};
}, TEMPLATE);
expect(result.ok).toBe(true);
// 종전엔 0(partial 전부 누락). 이제 1건 이상 + _user_base(base 호스트) 포함.
expect(result.modalCount).toBeGreaterThan(0);
expect(result.hosts).toContain('_user_base');
});
/** @effects modal_edit_renders_dim_and_blocker, dnd_handles_confined_to_modal_subtree */
test('모달 편집 진입 시 딤 음영 + 차단 밴드 + 핸들이 모달 서브트리로 confine', async ({ page }) => {
await enterEditor(page, MODAL_DIRECT_URL);
// 모달 편집 모드 진입 + 딤 음영 마운트 대기.
await expect(page.locator('[data-mode="modal"]')).toBeAttached({ timeout: 30_000 });
await page.waitForSelector('[data-testid="g7le-source-lock-dim"]', { timeout: 30_000 });
// 딤 상호작용 차단 밴드 존재(딤 영역 클릭/드래그 삼킴).
await expect.poll(() => page.locator('[data-testid="g7le-source-lock-block"]').count()).toBeGreaterThan(0);
// 드래그 핸들이 모달 서브트리(편집 대상) 안에만 존재 — 딤 호스트엔 0.
const handleClassification = await page.evaluate(() => {
const titleEl = Array.from(document.querySelectorAll('[data-editor-path]')).find((e) =>
/삭제하시겠습니까|delete/i.test(e.textContent || '')
) as HTMLElement | undefined;
const modalTop = titleEl?.dataset.editorPath?.split('.children.')[0] ?? null;
const handles = Array.from(document.querySelectorAll('[data-testid^="g7le-dnd-handle"]')).map(
(h) => (h.getAttribute('data-testid') || '').replace('g7le-dnd-handle-', '')
);
const outModal = handles.filter(
(p) => !(modalTop && (p === modalTop || p.startsWith(`${modalTop}.`)))
);
return { total: handles.length, outModal: outModal.length, modalTop };
});
expect(handleClassification.total).toBeGreaterThan(0);
expect(handleClassification.outModal).toBe(0); // 딤 호스트엔 핸들 없음
});
/** @effects modal_edit_exit_clears_dim */
test('모달 편집 종료 → 딤 해제 + 편집 모드 이탈', async ({ page }) => {
await enterEditor(page, MODAL_DIRECT_URL);
await expect(page.locator('[data-mode="modal"]')).toBeAttached({ timeout: 30_000 });
await page.waitForSelector('[data-testid="g7le-source-lock-dim"]', { timeout: 30_000 });
// 뒤로가기로 편집 모드 종료(종료 버튼 라벨은 locale 종속이라 popstate 사용).
await page.goBack();
await expect(page.locator('[data-testid="g7le-source-lock-dim"]')).toHaveCount(0);
await expect.poll(() => page.url()).not.toMatch(/edit=__modal__/);
});
});