fix(core,board,ecommerce,page,gdpr,ckeditor5,kginicis,admin_basic,basic): 목록 조회·검증 계층 정비 및 감사 지적 전건 처리

목록 조회 성능 축(깊은 OFFSET·정렬·색인)과 그 검증 계층에서 계획서 전수검수와 3회에 걸친
감사가 지적한 항목을 처리했다. 세부 경위는 의 각 회차 문서에 있다.

검증 계층 — 컨트롤러가 base Request 를 직접 주입받던 확장 13곳을 전용 FormRequest 로 옮겼다.
옮기면서 기존 동작 계약은 그대로 두었다: 상한 초과 limit 을 거부하지 않고 상한까지 반환하던
공개 API, per_page 를 범위로 조정하던 관리자 목록, 미지원 period 를 year 로 해석하던 인기글
목록 모두 종전과 같은 응답을 낸다. 상한/폴백을 rules 로 승격시키면 200 이던 응답이 422 가
되어 기존 링크가 깨지므로, 규칙은 타입만 닫고 클램프·폴백은 접근자가 맡는다. period 는
접근자가 닫힌 집합만 반환해 캐시 키 공간도 함께 닫힌다.

ckeditor5 이미지 업로드만 ResponseHelper 봉투를 쓰지 않는다. 응답을 파싱하는 주체가 CDN 으로
로드되는 상위 CKEditor5 43.3.1 의 SimpleUploadAdapter 라 규약을 바꿀 수 없어, 각 응답 지점에
사유를 명시한 면제를 부착하고 근거를 API 문서에 남겼다.

하네스 — 룰 5개의 대상 경로 패턴이 매처와 맞지 않아 번들 확장 컨트롤러가 검사 대상에서
통째로 빠져 있었다. 패턴을 고치자 확장 위반 17건이 드러나 전건 처리했다. severity 오타가
요약 집계 양쪽에 안 잡혀 "0 error" 로 보고되던 문제도 런너 사전 검증으로 막았다.

정렬 게이트 대조 하네스는 관계 정렬 변형만 쓰는 저장소를 탐지하지 못한 채 통과시키고 있었다.
탐지·제외·인자 파싱을 함께 고치고 단위 테스트를 신설했다.
This commit is contained in:
HeuJung committed 2026-08-02 15:29:29 +09:00
1 parent 5f4a733b3b
commit b10e89bef0
276 files changed
+12519 -1438

No files matched your search

@@ -92,12 +92,20 @@ class SortableColumnsGateContractTest extends TestCase
$path = str_replace('\\', '/', $file->getPathname());
$relative = ltrim(str_replace(str_replace('\\', '/', $root), '', $path), '/');
// 트레이트 본체와 테스트 코드는 호출처가 아니다
if (str_contains($relative, '/tests/') || str_contains($relative, 'Concerns/ResolvesSortSpec.php')) {
// 트레이트 본체와 테스트 코드는 호출처가 아니다.
// 파일명을 하나씩 나열하면 트레이트가 늘 때마다 목록이 낡으므로 디렉토리로 제외한다
// (`Repositories/Concerns/` 는 정렬·페이지네이션 트레이트 본체 자리다).
if (str_contains($relative, '/tests/') || str_contains($relative, 'Repositories/Concerns/')) {
continue;
}
if (str_contains((string) file_get_contents($path), '$this->resolveSortSpec(')) {
$content = (string) file_get_contents($path);
// 관계 정렬 변형(`resolveSortSpecWithRelated`)만 쓰는 저장소도 호출처다.
// `resolveSortSpec(` 만 찾으면 뒤에 `WithRelated` 가 붙은 호출을 놓쳐, 그 저장소는
// 게이트 대조 자체에 도달하지 못한 채 조용히 통과한다.
if (str_contains($content, '$this->resolveSortSpec(')
|| str_contains($content, '$this->resolveSortSpecWithRelated(')) {
$found[] = $relative;
}
}
@@ -138,29 +146,60 @@ class SortableColumnsGateContractTest extends TestCase
{
$columns = [];
// resolveSortSpec 의 두 번째 인자 — self::CONST 또는 인라인 배열
// resolveSortSpec 의 두 번째 인자 — self::CONST 또는 인라인 배열.
// `resolveSortSpec\(` 는 `(` 를 요구하므로 `resolveSortSpecWithRelated(` 와 겹치지 않는다.
preg_match_all('/resolveSortSpec\(\s*\$\w+\s*,\s*(self::(\w+)|\[[^\]]*\])/s', $content, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$literal = $match[1];
$columns = array_merge($columns, $this->literalColumns($content, $match[1], $match[2] ?? '', false));
}
if (str_starts_with($literal, 'self::')) {
$constName = $match[2];
// 관계 정렬 변형 — 두 번째(자기 테이블 컬럼) + 세 번째(관계 컬럼 맵) 인자를 모두 읽는다.
// 세 번째를 빼면 관계 정렬로만 허용된 컬럼이 "저장소에 없음" 으로 오판된다.
preg_match_all(
'/resolveSortSpecWithRelated\(\s*\$\w+\s*,\s*(self::(\w+)|\[[^\]]*\])\s*,\s*(self::(\w+)|\[.*?\])\s*,/s',
$content,
$relatedMatches,
PREG_SET_ORDER
);
if (! preg_match('/const\s+'.preg_quote($constName, '/').'\s*=\s*\[(.*?)\];/s', $content, $constMatch)) {
continue;
}
$literal = $constMatch[1];
}
preg_match_all("/'([a-zA-Z0-9_]+)'/", $literal, $columnMatches);
$columns = array_merge($columns, $columnMatches[1]);
foreach ($relatedMatches as $match) {
$columns = array_merge($columns, $this->literalColumns($content, $match[1], $match[2] ?? '', false));
// 관계 맵은 `'정렬키' => [model/foreign_key/column]` 구조라 최상위 키만 정렬키다
$columns = array_merge($columns, $this->literalColumns($content, $match[3], $match[4] ?? '', true));
}
return array_values(array_unique($columns));
}
/**
* 인자 리터럴(상수 참조 포함)에서 컬럼명을 추출합니다.
*
* @param string $content 파일 내용 (상수 본문 조회용)
* @param string $literal 인자 리터럴 (`self::CONST` 또는 인라인 배열)
* @param string $constName 상수명 (`self::` 형태일 때)
* @param bool $keysOnly true 면 `'키' => [...]` 의 최상위 키만 취함
* @return array<int, string> 추출된 컬럼명
*/
private function literalColumns(string $content, string $literal, string $constName, bool $keysOnly): array
{
if (str_starts_with($literal, 'self::')) {
if (! preg_match('/const\s+'.preg_quote($constName, '/').'\s*=\s*\[(.*?)\];/s', $content, $constMatch)) {
return [];
}
$literal = $constMatch[1];
}
// 최상위 키만 — 중첩 배열의 내부 키/값(model, foreign_key, column …)을 정렬 허용 컬럼으로
// 오인하면 저장소 허용 목록이 실제보다 넓어져 게이트 대조가 거짓 통과한다.
$pattern = $keysOnly ? "/'([a-zA-Z0-9_]+)'\s*=>\s*\[/" : "/'([a-zA-Z0-9_]+)'/";
preg_match_all($pattern, $literal, $columnMatches);
return $columnMatches[1];
}
/**
* FormRequest 에서 sort_by 허용 값을 추출합니다.
*