KISA 신고 4건(KVE-2026-1886/1887/1893/1894)을 검증하고, 미수정 2건과 동종 결함 전수 조사에서 나온 결함을 함께 조치했다. 권한 게이트 (KVE-2026-1893) - NHN KCP 관리자 주문 연동 7경로가 admin 보유 여부만 보고 세부 권한을 보지 않아, 업무 권한 없는 관리자가 주문번호·결제정보·수령인 연락처를 조회하고 에스크로 배송등록까지 할 수 있었다. 조회는 orders.read, 등록은 orders.update, 설정성 경로는 settings.read 로 게이트해 다른 PG 연동과 강도를 맞췄다. - 마케팅 채널 저장은 코어 플러그인 설정과 같은 저장소를 덮어쓰는 우회 경로라 core.plugins.update 를 부착했다. 첨부 해시 노출 (KVE-2026-1894 잔재) - 비밀글의 썸네일 URL 이 목록·상세 응답에 그대로 실려 첨부 해시가 노출됐다. 이미지 서빙은 이미 차단돼 있었으나 식별값 자체가 나갔다. 첨부 목록과 같은 게이트를 써서 값만 가리고 필드는 유지한다. 경쟁 조건 (KVE-2026-1886 + 전수 조사) - 쿠폰 차감을 조회 후 갱신에서 조건부 UPDATE 로 바꿔 1회 제한 쿠폰의 동시 사용을 막고, 선점당한 주문은 409 로 되돌린다. - 라이브 병렬 재현에서 그 롤백이 동작하지 않는 것을 확인했다. Action 훅 기본값이 큐 래핑 + afterCommit 이라 금전 처리가 호출자 커밋 뒤에 실행되고 있었다. 쿠폰·적립금 차감/복원 5개 구독에 sync 를 선언했고, 회귀 테스트는 손 등록이 아니라 실제 등록 경로를 태워 고정했다. - 동시 부분취소의 취소 누적 컬럼 lost update, 적립 lot 의 read-modify-write, 주문옵션당 적립 lot 중복 생성을 각각 행 잠금·컬럼 연산·유니크 제약으로 막았다. 기설치본의 중복 lot 은 인덱스 생성 전에 금액을 합산해 한 줄로 통합한다. 규정·문서 - sync 판정 기준을 hooks.md 에 명문화하고 /AGENTS.md Listener 표와 coverage manifest 에 반영했다. 같은 증상을 다시 만났을 때의 진단 경로를 트러블슈팅 사례로 남겼다.
116 lines
4.1 KiB
PHP
116 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Sirsoft\Board\Tests\Unit\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Modules\Sirsoft\Board\Http\Resources\PostResource;
|
|
use Modules\Sirsoft\Board\Models\Attachment;
|
|
use Modules\Sirsoft\Board\Models\Post;
|
|
use Modules\Sirsoft\Board\Tests\BoardTestCase;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
|
|
/**
|
|
* PostResource 썸네일 URL 호출측 회귀 테스트 (#100 URL 조립 단일화)
|
|
*
|
|
* previewUrlForSlug() 헬퍼 자체가 아니라 **호출측**(PostResource
|
|
* getThumbnailUrlFromRelations)이 slug 인자를 올바르게 전달해 응답 문자열이
|
|
* 기존과 동일하게 직렬화되는지 고정합니다 — 헬퍼 출력만 고정하면 인자 전달
|
|
* 오류(슬러그 누락 등)가 전부 green 으로 통과합니다.
|
|
*/
|
|
class PostResourceThumbnailUrlTest extends BoardTestCase
|
|
{
|
|
/**
|
|
* 이미지 첨부를 가진 게시글을 생성합니다.
|
|
*
|
|
* @param string $mimeType 첨부 MIME 타입
|
|
* @return array{post: Post, attachment: Attachment} 게시글/첨부
|
|
*/
|
|
private function createPostWithAttachment(string $mimeType, array $postAttributes = []): array
|
|
{
|
|
$postId = $this->createTestPost($postAttributes);
|
|
|
|
$attachment = Attachment::create([
|
|
'board_id' => $this->board->id,
|
|
'post_id' => $postId,
|
|
'original_filename' => 'thumb.jpg',
|
|
'stored_filename' => 'stored-thumb.jpg',
|
|
'disk' => 'modules',
|
|
'path' => 'attachments/thumb.jpg',
|
|
'mime_type' => $mimeType,
|
|
'size' => 100,
|
|
'collection' => 'attachments',
|
|
'order' => 0,
|
|
]);
|
|
|
|
$post = Post::with(['thumbnailAttachment', 'board'])->findOrFail($postId);
|
|
|
|
return ['post' => $post, 'attachment' => $attachment];
|
|
}
|
|
|
|
/**
|
|
* @effects board_response_strings_unchanged
|
|
*/
|
|
#[Test]
|
|
public function thumbnail_serializes_preview_url_with_board_slug(): void
|
|
{
|
|
['post' => $post, 'attachment' => $attachment] = $this->createPostWithAttachment('image/jpeg');
|
|
|
|
$response = (new PostResource($post))->toArray(Request::create('/'));
|
|
|
|
$this->assertSame(
|
|
'/api/modules/sirsoft-board/boards/'.$this->board->slug.'/attachment/'.$attachment->hash.'/preview',
|
|
$response['thumbnail'],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @effects board_response_strings_unchanged
|
|
*/
|
|
#[Test]
|
|
public function thumbnail_is_null_for_non_image_attachment(): void
|
|
{
|
|
['post' => $post] = $this->createPostWithAttachment('application/pdf');
|
|
|
|
$response = (new PostResource($post))->toArray(Request::create('/'));
|
|
|
|
$this->assertNull($response['thumbnail']);
|
|
}
|
|
|
|
/**
|
|
* 비밀글의 썸네일 URL은 열람 권한이 없으면 방출되지 않아야 합니다 (KVE-2026-1894).
|
|
*
|
|
* 서빙은 막혀 있어 이미지가 보이지는 않지만, URL 에 실린 첨부 해시 자체가
|
|
* 목록·상세 응답으로 나가 있었다. 필드는 남기고 값만 가린다.
|
|
*
|
|
* @effects secret_post_thumbnail_hash_not_exposed
|
|
*/
|
|
#[Test]
|
|
public function thumbnail_is_null_for_secret_post_without_permission(): void
|
|
{
|
|
['post' => $post] = $this->createPostWithAttachment('image/jpeg', ['is_secret' => true]);
|
|
|
|
$response = (new PostResource($post))->toArray(Request::create('/'));
|
|
|
|
$this->assertArrayHasKey('thumbnail', $response, 'thumbnail 키 자체는 유지되어야 합니다.');
|
|
$this->assertNull($response['thumbnail']);
|
|
}
|
|
|
|
/**
|
|
* 비밀글이 아니면 썸네일 URL이 그대로 유지되어야 합니다 (선택적 차단 회귀 방지).
|
|
*
|
|
* @effects secret_post_thumbnail_hash_not_exposed
|
|
*/
|
|
#[Test]
|
|
public function thumbnail_is_preserved_for_non_secret_post(): void
|
|
{
|
|
['post' => $post, 'attachment' => $attachment] = $this->createPostWithAttachment('image/jpeg');
|
|
|
|
$response = (new PostResource($post))->toArray(Request::create('/'));
|
|
|
|
$this->assertSame(
|
|
'/api/modules/sirsoft-board/boards/'.$this->board->slug.'/attachment/'.$attachment->hash.'/preview',
|
|
$response['thumbnail'],
|
|
);
|
|
}
|
|
}
|