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:
HeuJung committed 2026-07-24 16:17:44 +09:00
1 parent 9dda22f8e4
commit abb40ad210
74 files changed
+3880 -192

No files matched your search

@@ -308,9 +308,11 @@ class PluginSettingsControllerTest extends TestCase
$this->createTestPlugin('sirsoft-daum_postcode');
}
// 플러그인이 선언한 설정 스키마의 실제 키를 사용한다.
// 스키마 밖의 키는 검증을 통과하지 못해 저장되지 않는다.
$response = $this->authRequest()->putJson('/api/admin/plugins/sirsoft-daum_postcode/settings', [
'animation' => true,
'autoClose' => false,
'display_mode' => 'popup',
'popup_width' => 640,
]);
$response->assertStatus(200)
@@ -320,14 +322,51 @@ class PluginSettingsControllerTest extends TestCase
$settingsPath = storage_path('app/plugins/sirsoft-daum_postcode/settings/setting.json');
if (File::exists($settingsPath)) {
$savedContent = json_decode(File::get($settingsPath), true);
$this->assertTrue($savedContent['animation'] ?? false);
$this->assertFalse($savedContent['autoClose'] ?? true);
$this->assertSame('popup', $savedContent['display_mode'] ?? null);
$this->assertSame(640, $savedContent['popup_width'] ?? null);
}
// 정리
$this->cleanupTestSettings('sirsoft-daum_postcode');
}
/**
* 스키마에 없는 필드는 저장되지 않음 (mass-assignment 방지)
*
* 과거 구현은 `validated()` 가 비면 `$request->all()` 로 폴백했다. 폴백의 명분이던
* "PluginManager 미등록 플러그인" 은 `PluginSettingsService::save()` 가 이미 false 로
* 차단하므로 도달할 수 없고, 실제로는 스키마 밖 키만 담긴 요청이 그대로 설정 파일에
* 병합되는 경로로만 동작했다.
*/
public function test_update_ignores_fields_outside_settings_schema(): void
{
$pluginInstance = $this->pluginManager->getPlugin('sirsoft-daum_postcode');
if (! $pluginInstance) {
$this->markTestSkipped('sirsoft-daum_postcode plugin not installed');
}
$plugin = Plugin::where('identifier', 'sirsoft-daum_postcode')->first();
if (! $plugin) {
$this->createTestPlugin('sirsoft-daum_postcode');
}
// 스키마에 정의되지 않은 키만 담아 전송 → validated() 가 빈 배열이 되는 조건
$this->authRequest()->putJson('/api/admin/plugins/sirsoft-daum_postcode/settings', [
'injected_field' => 'evil',
'another_unknown' => ['nested' => true],
]);
$settingsPath = storage_path('app/plugins/sirsoft-daum_postcode/settings/setting.json');
if (File::exists($settingsPath)) {
$savedContent = json_decode(File::get($settingsPath), true);
$this->assertArrayNotHasKey('injected_field', $savedContent);
$this->assertArrayNotHasKey('another_unknown', $savedContent);
}
$this->cleanupTestSettings('sirsoft-daum_postcode');
}
// ========================================================================
// layout() 테스트 - 레이아웃 조회
// ========================================================================
@@ -431,7 +470,7 @@ class PluginSettingsControllerTest extends TestCase
}
$response = $this->authRequest()->putJson('/api/admin/plugins/sirsoft-daum_postcode/settings', [
'animation' => true,
'display_mode' => 'popup',
]);
$response->assertStatus(200)
@@ -442,8 +481,8 @@ class PluginSettingsControllerTest extends TestCase
// 응답에 업데이트된 설정이 포함되어 있는지 확인
$data = $response->json('data');
$this->assertIsArray($data);
$this->assertArrayHasKey('animation', $data);
$this->assertTrue($data['animation']);
$this->assertArrayHasKey('display_mode', $data);
$this->assertSame('popup', $data['display_mode']);
// 정리
$this->cleanupTestSettings('sirsoft-daum_postcode');