검증 규칙 배열 */ // audit:allow core-formrequest-hook-filter reason: 자산 서빙 경로 검증은 파일시스템 // 화이트리스트(SafeModulePath + AllowedModuleFileType)가 유일한 방어선이다. // 확장이 필터로 규칙을 대체할 수 있으면 경로 탈출·임의 파일 읽기가 열린다. public function rules(): array { // 모듈 식별자로부터 기준 경로 구성 (모듈 루트) $identifier = $this->route('identifier'); $basePath = base_path("modules/{$identifier}"); return [ 'identifier' => ['required', 'string'], 'path' => [ 'required', 'string', new SafeModulePath($basePath), new AllowedModuleFileType, ], ]; } /** * 검증을 위한 데이터 준비 */ protected function prepareForValidation(): void { // 라우트 파라미터를 검증 데이터에 병합. // 확장자 없는 모드에서는 파일 경로가 `?file=` 쿼리로 온다 (경로 확장자 회피). $this->merge([ 'identifier' => $this->route('identifier'), 'path' => $this->route('path') ?? $this->query(DualExtensionRoute::FILE_QUERY_PARAM), ]); } /** * 검증 오류 메시지 커스터마이징 * * @return array */ public function messages(): array { return [ 'identifier.required' => __('validation.asset.identifier.required'), 'identifier.string' => __('validation.asset.identifier.string'), 'path.required' => __('validation.asset.path.required'), 'path.string' => __('validation.asset.path.string'), ]; } }