fix(core,board,ecommerce,page): 중첩 리소스 스코프·계층 무결성 결함 12건 일괄 수정
중첩 라우트의 상위 리소스 ID 를 조회 스코프에 반영하지 않아 A 의 경로로 B 의 하위 리소스를 읽거나 변경할 수 있었다. 방어 위치를 Repository where 절(SSoT)로 통일하고 컨트롤러 사후 비교에 의존하지 않게 했다. 같은 리소스의 형제 엔드포인트가 서로 다른 강도로 검증하던 부분도 맞췄다. 계층 리소스는 자기 자신·자손을 부모로 지정하는 순환을 검증 계층에서 차단하고, 검증을 우회하는 경로(시더/훅/오염 데이터)를 위해 path 재귀에 방문 ID 가드를 뒀다. 설정값이 정하는 깊이 상한을 Service 가 리터럴로 재클램프하던 부분을 제거해 게시판 설정이 실제로 적용되게 했다. 쓰기 경로는 validated 기준으로 좁혀 FormRequest 미정의 필드가 fillable 로 새지 않게 했다. 기존 오염 데이터는 업그레이드 스텝이 정리한다(삭제 없이 최상위로 이동). 재발 방지로 audit 룰 3종을 추가하고, 규정 문서와 트러블슈팅 사례를 함께 갱신했다. 공개 이슈: gnuboard/g7
This commit is contained in:
1 parent
9dda22f8e4
commit
abb40ad210
74 files changed
+3880
-192
No files matched your search
@@ -252,16 +252,20 @@ class CommentRepository implements CommentRepositoryInterface
|
||||
/**
|
||||
* ID로 댓글을 조회합니다.
|
||||
*
|
||||
* $postId 를 전달하면 해당 게시글에 속한 댓글만 조회합니다 (교차 게시글 접근 차단).
|
||||
*
|
||||
* @param string $slug 게시판 슬러그
|
||||
* @param int $id 댓글 ID
|
||||
* @param int|null $postId 상위 게시글 ID (null 이면 게시판 범위 전체)
|
||||
* @return Comment|null 댓글 또는 null
|
||||
*/
|
||||
public function find(string $slug, int $id): ?Comment
|
||||
public function find(string $slug, int $id, ?int $postId = null): ?Comment
|
||||
{
|
||||
$board = Board::where('slug', $slug)->first();
|
||||
|
||||
return Comment::query()
|
||||
->where('board_id', $board?->id)
|
||||
->when($postId !== null, fn ($query) => $query->where('post_id', $postId))
|
||||
->withTrashed()
|
||||
->with(['user'])
|
||||
->find($id);
|
||||
@@ -270,18 +274,22 @@ class CommentRepository implements CommentRepositoryInterface
|
||||
/**
|
||||
* ID로 댓글을 조회하며, 없으면 예외를 발생시킵니다.
|
||||
*
|
||||
* $postId 를 전달하면 해당 게시글에 속한 댓글만 조회합니다 (교차 게시글 접근 차단).
|
||||
*
|
||||
* @param string $slug 게시판 슬러그
|
||||
* @param int $id 댓글 ID
|
||||
* @param int|null $postId 상위 게시글 ID (null 이면 게시판 범위 전체)
|
||||
* @return Comment 댓글 모델
|
||||
*
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function findOrFail(string $slug, int $id): Comment
|
||||
public function findOrFail(string $slug, int $id, ?int $postId = null): Comment
|
||||
{
|
||||
$board = Board::where('slug', $slug)->firstOrFail();
|
||||
|
||||
return Comment::query()
|
||||
->where('board_id', $board->id)
|
||||
->when($postId !== null, fn ($query) => $query->where('post_id', $postId))
|
||||
->withTrashed()
|
||||
->with(['user'])
|
||||
->findOrFail($id);
|
||||
|
||||
+11
-2
@@ -19,6 +19,8 @@ interface CommentRepositoryInterface
|
||||
* @param int $postId 게시글 ID
|
||||
* @param bool $withTrashed 삭제된 댓글 포함 여부 (기본값: false)
|
||||
* @param string $orderDirection 정렬 방향 (ASC 또는 DESC, 기본값: DESC)
|
||||
* @param string|null $scopePermission 스코프 권한 식별자 (null 이면 스코프 필터 미적용)
|
||||
* @param int|null $boardId 게시판 ID (전달 시 Board 재조회 생략)
|
||||
* @return Collection 정렬된 댓글 컬렉션
|
||||
*/
|
||||
public function getByPostId(string $slug, int $postId, bool $withTrashed = false, string $orderDirection = 'DESC', ?string $scopePermission = null, ?int $boardId = null): Collection;
|
||||
@@ -35,22 +37,28 @@ interface CommentRepositoryInterface
|
||||
/**
|
||||
* ID로 댓글을 조회합니다.
|
||||
*
|
||||
* $postId 를 전달하면 해당 게시글에 속한 댓글만 조회합니다 (교차 게시글 접근 차단).
|
||||
*
|
||||
* @param string $slug 게시판 슬러그
|
||||
* @param int $id 댓글 ID
|
||||
* @param int|null $postId 상위 게시글 ID (null 이면 게시판 범위 전체)
|
||||
* @return Comment|null 댓글 모델 또는 null
|
||||
*/
|
||||
public function find(string $slug, int $id): ?Comment;
|
||||
public function find(string $slug, int $id, ?int $postId = null): ?Comment;
|
||||
|
||||
/**
|
||||
* ID로 댓글을 조회하며, 없으면 예외를 발생시킵니다.
|
||||
*
|
||||
* $postId 를 전달하면 해당 게시글에 속한 댓글만 조회합니다 (교차 게시글 접근 차단).
|
||||
*
|
||||
* @param string $slug 게시판 슬러그
|
||||
* @param int $id 댓글 ID
|
||||
* @param int|null $postId 상위 게시글 ID (null 이면 게시판 범위 전체)
|
||||
* @return Comment 댓글 모델
|
||||
*
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function findOrFail(string $slug, int $id): Comment;
|
||||
public function findOrFail(string $slug, int $id, ?int $postId = null): Comment;
|
||||
|
||||
/**
|
||||
* 댓글을 수정합니다.
|
||||
@@ -94,6 +102,7 @@ interface CommentRepositoryInterface
|
||||
* @param string $status 변경할 상태 (blinded/deleted)
|
||||
* @param array $actionLog 작업 이력 데이터
|
||||
* @param string|null $triggerType 트리거 유형 (report, admin, auto_hide 등)
|
||||
* @return Comment 상태가 변경된 댓글 모델
|
||||
*
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user