fix(core,board,ecommerce): 조건부 검증 결함 패밀리 일괄 수정 및 실패 안내 노출
여러 화면에서 조건부(FormRequest) 검증이 우회되거나 과도하게 제한되던 결함을 한 계열로 묶어 수정한다. - 검증 규칙 확장 필터 이름 10개를 나머지 92개와 동일 규칙으로 통일 - 설명 길이를 바이트가 아닌 글자 수로 계산(한글 오검출 해소) - 비활성 언어팩 번역 보존한 채 수정 허용 - 알림 템플릿 제목 nullable 존중, 미지원 발송 수단 저장 차단 - 일정/실행 이력 목록 조회 검증 정합 - 게시판 첨부 미사용 시 빈 확장자 통과, new_display_hours/최소 길이 0 허용, 일괄 적용 override_values 범위 검증(SSoT) - 이커머스 클레임 사유 조회 검증, 용어 정정 - 원문 i18n 키 노출 다수 해소, 저장/삭제 실패 시 사유 화면 노출 - 아이콘 크기/다크모드 대비 회귀 수정 번들 확장(모듈3·플러그인6·템플릿2·언어팩5) 버전 new-bump 및 CHANGELOG 반영, ja 언어팩 동기.
This commit is contained in:
1 parent
c001b30a87
commit
7f8fb6870f
288 files changed
+5339
-1049
No files matched your search
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 스케줄 실행 실패 예외
|
||||
*
|
||||
* 저장된 스케줄을 실행하는 시점에 차단 목록에 걸리거나(artisan/shell 화이트리스트, 내부망 URL),
|
||||
* 실행 자체가 실패했을 때 발생합니다. `ScheduleService` 가 이 예외를 잡아 실행 이력에 기록합니다.
|
||||
*/
|
||||
class ScheduleExecutionException extends Exception
|
||||
{
|
||||
/**
|
||||
* 허용되지 않은 Artisan 명령
|
||||
*
|
||||
* @return self 생성된 예외
|
||||
*/
|
||||
public static function artisanNotAllowed(): self
|
||||
{
|
||||
return new self(__('schedule.artisan_not_allowed'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 허용되지 않은 쉘 명령
|
||||
*
|
||||
* @return self 생성된 예외
|
||||
*/
|
||||
public static function shellNotAllowed(): self
|
||||
{
|
||||
return new self(__('schedule.shell_not_allowed'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 쉘 명령 실행 실패
|
||||
*
|
||||
* @param string $errorOutput 프로세스 표준 에러 출력
|
||||
* @param int $exitCode 프로세스 종료 코드
|
||||
* @return self 생성된 예외
|
||||
*/
|
||||
public static function shellCommandFailed(string $errorOutput, int $exitCode): self
|
||||
{
|
||||
return new self($errorOutput !== '' ? $errorOutput : __('schedule.shell_command_failed'), $exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개되지 않은(내부망) URL 호출 차단
|
||||
*
|
||||
* @return self 생성된 예외
|
||||
*/
|
||||
public static function urlNotPublic(): self
|
||||
{
|
||||
return new self(__('schedule.url_not_public'));
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP 요청 실패
|
||||
*
|
||||
* @param int $status 응답 상태 코드
|
||||
* @return self 생성된 예외
|
||||
*/
|
||||
public static function httpRequestFailed(int $status): self
|
||||
{
|
||||
return new self(__('schedule.http_request_failed', ['status' => $status]), $status);
|
||||
}
|
||||
}
|
||||
@@ -1183,7 +1183,7 @@ PHP;
|
||||
return $pharPath;
|
||||
}
|
||||
|
||||
throw new \RuntimeException(__('exceptions.extension.composer_binary_not_found'));
|
||||
throw new \RuntimeException(__('exceptions.vendor.composer_binary_not_found'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,17 +13,17 @@ class RoleMiddleware
|
||||
/**
|
||||
* 특정 역할을 가진 사용자만 접근을 허용합니다.
|
||||
*
|
||||
* @param Request $request HTTP 요청
|
||||
* @param Closure $next 다음 미들웨어
|
||||
* @param string $role 필요한 역할명
|
||||
* @param bool $requireAll 여러 역할시 모두 필요한지 여부
|
||||
* @param Request $request HTTP 요청
|
||||
* @param Closure $next 다음 미들웨어
|
||||
* @param string $role 필요한 역할명
|
||||
* @param bool $requireAll 여러 역할시 모두 필요한지 여부
|
||||
* @return Response HTTP 응답
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string $role, bool $requireAll = true): Response
|
||||
{
|
||||
// 인증되지 않은 사용자
|
||||
if (!Auth::check()) {
|
||||
return ResponseHelper::unauthorized('messages.auth.unauthenticated');
|
||||
if (! Auth::check()) {
|
||||
return ResponseHelper::unauthorized('auth.unauthenticated');
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
@@ -31,16 +31,16 @@ class RoleMiddleware
|
||||
|
||||
// 역할 확인
|
||||
if (count($roles) === 1) {
|
||||
if (!$user->hasRole($roles[0])) {
|
||||
return ResponseHelper::forbidden('messages.auth.role_denied', [
|
||||
'required_role' => $roles[0]
|
||||
if (! $user->hasRole($roles[0])) {
|
||||
return ResponseHelper::forbidden('auth.role_denied', [
|
||||
'required_role' => $roles[0],
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if (!$user->hasRoles($roles, $requireAll)) {
|
||||
return ResponseHelper::forbidden('messages.auth.role_denied', [
|
||||
if (! $user->hasRoles($roles, $requireAll)) {
|
||||
return ResponseHelper::forbidden('auth.role_denied', [
|
||||
'required_roles' => $roles,
|
||||
'require_all' => $requireAll
|
||||
'require_all' => $requireAll,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class AdminIdentityMessageDefinitionIndexRequest extends FormRequest
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -25,7 +25,7 @@ class AdminIdentityMessageDefinitionIndexRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -50,7 +50,7 @@ class AdminIdentityMessageDefinitionIndexRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.identity.message_definition.filter_index_rules',
|
||||
'core.identity.message_definition.index_validation_rules',
|
||||
$rules
|
||||
);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class AdminIdentityMessageDefinitionIndexRequest extends FormRequest
|
||||
/**
|
||||
* 검증 메시지.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string> 검증 오류 메시지 배열
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
|
||||
/**
|
||||
* 라우트 permission 미들웨어가 담당하므로 true 고정.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -37,7 +37,7 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -65,15 +65,13 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.identity.message_definition.filter_store_rules',
|
||||
'core.identity.message_definition.store_validation_rules',
|
||||
$rules,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* provider_id 가 등록된 IDV 프로바이더인지 확인하는 closure 룰.
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
protected function providerExistsRule(): Closure
|
||||
{
|
||||
@@ -91,8 +89,6 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
|
||||
|
||||
/**
|
||||
* scope_value 가 source_type='admin' 인 IdentityPolicy.key 와 일치하는지 확인.
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
protected function adminPolicyKeyRule(): Closure
|
||||
{
|
||||
@@ -113,8 +109,6 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
|
||||
|
||||
/**
|
||||
* (provider_id, scope_type, scope_value) 조합 중복 검사.
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
protected function scopeUniqueRule(): Closure
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ class UpdateIdentityMessageDefinitionRequest extends FormRequest
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 미들웨어에서 검증)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -28,20 +28,22 @@ class UpdateIdentityMessageDefinitionRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙.
|
||||
*
|
||||
* @return array
|
||||
* @return array 필드별 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['sometimes', 'array', new LocaleRequiredTranslatable(maxLength: 200)],
|
||||
'description' => ['sometimes', 'nullable', 'array', new TranslatableField(maxLength: 1000)],
|
||||
// audit:allow formrequest-sometimes-array-min-inert reason: 채널 0개는 유효한 상태가 아니다.
|
||||
// 발송 채널을 모두 해제하면 본인인증 메시지가 전달되지 않으므로 오류를 노출하는 것이 올바른 동작이다.
|
||||
'channels' => ['sometimes', 'array', 'min:1'],
|
||||
'channels.*' => ['string', 'max:20'],
|
||||
'is_active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.identity.message_definition.filter_update_rules',
|
||||
'core.identity.message_definition.update_validation_rules',
|
||||
$rules,
|
||||
$this->route('definition')
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ class UpdateIdentityMessageTemplateRequest extends FormRequest
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -28,7 +28,7 @@ class UpdateIdentityMessageTemplateRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -39,7 +39,7 @@ class UpdateIdentityMessageTemplateRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.identity.message_template.filter_update_rules',
|
||||
'core.identity.message_template.update_validation_rules',
|
||||
$rules,
|
||||
$this->route('template')
|
||||
);
|
||||
|
||||
@@ -9,6 +9,8 @@ class NotificationBatchReadRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -17,6 +19,8 @@ class NotificationBatchReadRequest extends FormRequest
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -26,7 +30,7 @@ class NotificationBatchReadRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.notification.filter_batch_read_rules',
|
||||
'core.notification.batch_read_validation_rules',
|
||||
$rules
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ class NotificationIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -17,6 +19,8 @@ class NotificationIndexRequest extends FormRequest
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -28,7 +32,7 @@ class NotificationIndexRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.notification.filter_index_rules',
|
||||
'core.notification.index_validation_rules',
|
||||
$rules
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class NotificationDefinitionIndexRequest extends FormRequest
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -20,7 +20,7 @@ class NotificationDefinitionIndexRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -36,7 +36,7 @@ class NotificationDefinitionIndexRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.notification_definition.filter_index_rules',
|
||||
'core.notification_definition.index_validation_rules',
|
||||
$rules
|
||||
);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class NotificationDefinitionIndexRequest extends FormRequest
|
||||
/**
|
||||
* 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string> 검증 오류 메시지 배열
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Http\Requests\NotificationDefinition;
|
||||
|
||||
use App\Contracts\Repositories\NotificationDefinitionRepositoryInterface;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\NotificationDefinition;
|
||||
use App\Rules\AvailableNotificationChannel;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateNotificationDefinitionRequest extends FormRequest
|
||||
@@ -10,7 +13,7 @@ class UpdateNotificationDefinitionRequest extends FormRequest
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 미들웨어에서 검증)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -20,22 +23,47 @@ class UpdateNotificationDefinitionRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
* @return array 필드별 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
// audit:allow formrequest-sometimes-array-min-inert reason: 채널 0개는 유효한 상태가 아니다.
|
||||
// 발송 채널을 모두 해제하면 알림이 사라지므로, 저장을 막고 오류를 노출하는 것이 올바른 동작이다.
|
||||
'channels' => ['sometimes', 'array', 'min:1'],
|
||||
'channels.*' => ['string', 'max:50'],
|
||||
// 허용 채널 목록은 config + filter_available_channels 훅으로 런타임 결정되므로
|
||||
// 요청 클래스에 하드코딩하지 않는다. 이미 저장된 채널은 통과시켜, 채널 제공
|
||||
// 플러그인이 비활성화된 뒤에도 기존 레코드 수정이 막히지 않게 한다.
|
||||
'channels.*' => ['string', 'max:50', new AvailableNotificationChannel($this->persistedChannels())],
|
||||
'hooks' => ['sometimes', 'array'],
|
||||
'hooks.*' => ['string', 'max:255'],
|
||||
'is_active' => ['sometimes', 'boolean'],
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.notification_definition.filter_update_rules',
|
||||
'core.notification_definition.update_validation_rules',
|
||||
$rules,
|
||||
$this->route('definition')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정 대상 알림 정의에 이미 저장되어 있는 채널 목록을 반환합니다.
|
||||
*
|
||||
* @return array<int, string> 저장된 채널 식별자 목록
|
||||
*/
|
||||
private function persistedChannels(): array
|
||||
{
|
||||
$definition = $this->route('definition');
|
||||
|
||||
if (! $definition instanceof NotificationDefinition) {
|
||||
$definition = is_numeric($definition)
|
||||
? app(NotificationDefinitionRepositoryInterface::class)->findById((int) $definition)
|
||||
: null;
|
||||
}
|
||||
|
||||
$channels = $definition?->channels;
|
||||
|
||||
return is_array($channels) ? array_values(array_filter($channels, 'is_string')) : [];
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ class NotificationLogIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool 항상 true (권한은 라우트 permission 미들웨어가 담당)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -20,6 +22,8 @@ class NotificationLogIndexRequest extends FormRequest
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed> 검증 규칙 배열
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -37,7 +41,7 @@ class NotificationLogIndexRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.notification_log.filter_index_rules',
|
||||
'core.notification_log.index_validation_rules',
|
||||
$rules
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class UpdateNotificationTemplateRequest extends FormRequest
|
||||
/**
|
||||
* 권한 확인 (미들웨어에서 처리).
|
||||
*
|
||||
* @return bool
|
||||
* @return bool 항상 true (권한은 미들웨어에서 검증)
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
@@ -21,12 +21,14 @@ class UpdateNotificationTemplateRequest extends FormRequest
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
* @return array 필드별 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'subject' => ['required', 'array', new LocaleRequiredTranslatable(maxLength: 500)],
|
||||
// subject 컬럼은 nullable 이다 (제목 개념이 없는 채널이 존재).
|
||||
// 스키마와 정합하도록 미전송/null 을 허용한다.
|
||||
'subject' => ['sometimes', 'nullable', 'array', new LocaleRequiredTranslatable(maxLength: 500)],
|
||||
'body' => ['required', 'array', new LocaleRequiredTranslatable(maxLength: 65535)],
|
||||
'click_url' => ['nullable', 'string', 'max:500'],
|
||||
'recipients' => ['sometimes', 'nullable', 'array'],
|
||||
@@ -38,7 +40,7 @@ class UpdateNotificationTemplateRequest extends FormRequest
|
||||
];
|
||||
|
||||
return HookManager::applyFilters(
|
||||
'core.notification_template.filter_update_rules',
|
||||
'core.notification_template.update_validation_rules',
|
||||
$rules,
|
||||
$this->route('template')
|
||||
);
|
||||
@@ -47,7 +49,7 @@ class UpdateNotificationTemplateRequest extends FormRequest
|
||||
/**
|
||||
* 검증 메시지를 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
* @return array 규칙별 오류 메시지
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use App\Services\NotificationChannelService;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
/**
|
||||
* 알림 채널 식별자 검증 규칙
|
||||
*
|
||||
* 사용 가능한 채널 목록은 config('notification.default_channels') 에
|
||||
* `core.notification.filter_available_channels` 훅으로 모듈/플러그인이 추가한 채널을
|
||||
* 더해 런타임에 결정됩니다. 따라서 허용 목록을 요청 클래스에 하드코딩하면
|
||||
* 플러그인이 등록한 채널이 저장되지 않습니다.
|
||||
*
|
||||
* 이미 저장되어 있던 채널은 통과시킵니다. 채널을 제공하던 플러그인이 비활성화되면
|
||||
* 그 값이 목록 밖으로 나가는데, 이때 기존 레코드 수정 자체가 차단되면 안 되기 때문입니다.
|
||||
* (신규로 알 수 없는 채널을 밀어 넣는 것만 차단합니다)
|
||||
*/
|
||||
class AvailableNotificationChannel implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* AvailableNotificationChannel 생성자
|
||||
*
|
||||
* @param array<int, string> $persistedChannels 대상 레코드에 이미 저장된 채널 목록
|
||||
*/
|
||||
public function __construct(
|
||||
private array $persistedChannels = []
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 검증 규칙 실행
|
||||
*
|
||||
* @param string $attribute 필드명
|
||||
* @param mixed $value 검증 값
|
||||
* @param Closure $fail 실패 콜백
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (! is_string($value) || $value === '') {
|
||||
$fail(__('validation.notification_channel.invalid', ['value' => (string) $value]));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array($value, $this->persistedChannels, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! app(NotificationChannelService::class)->isChannelAvailable($value)) {
|
||||
$fail(__('validation.notification_channel.unavailable', ['value' => $value]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,23 +16,24 @@ class LocaleRequiredTranslatable implements ValidationRule
|
||||
/**
|
||||
* LocaleRequiredTranslatable 생성자
|
||||
*
|
||||
* @param int $maxLength 각 번역의 최대 길이
|
||||
* @param int $minLength 각 번역의 최소 길이 (기본: 0)
|
||||
* @param string|null $requiredLocale 필수 로케일 (null이면 현재 로케일 사용)
|
||||
* @param int $maxLength 각 번역의 최대 길이
|
||||
* @param int $minLength 각 번역의 최소 길이 (기본: 0)
|
||||
* @param string|null $requiredLocale 필수 로케일 (null이면 현재 로케일 사용)
|
||||
* @param bool $strictLocales 지원 목록 밖 로케일 키를 실패로 처리할지 여부
|
||||
*/
|
||||
public function __construct(
|
||||
private int $maxLength = 255,
|
||||
private int $minLength = 0,
|
||||
private ?string $requiredLocale = null
|
||||
private ?string $requiredLocale = null,
|
||||
private bool $strictLocales = false
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 검증 규칙 실행
|
||||
*
|
||||
* @param string $attribute 필드명
|
||||
* @param mixed $value 검증 값
|
||||
* @param Closure $fail 실패 콜백
|
||||
* @return void
|
||||
* @param string $attribute 필드명
|
||||
* @param mixed $value 검증 값
|
||||
* @param Closure $fail 실패 콜백
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
@@ -67,11 +68,20 @@ class LocaleRequiredTranslatable implements ValidationRule
|
||||
|
||||
// 각 언어별 검증
|
||||
foreach ($value as $lang => $text) {
|
||||
// 지원하지 않는 언어 코드
|
||||
// 지원 목록 밖 로케일 키
|
||||
//
|
||||
// app.translatable_locales 는 활성 언어팩 기준으로 부팅마다 덮어써지는 가변 런타임
|
||||
// 값이다. 언어팩을 비활성화하면 기존 레코드에 남아 있던 그 로케일 키 때문에 수정
|
||||
// 자체가 차단되므로, 기본값은 "길이 검증 대상에서 제외하고 통과"로 둔다.
|
||||
// 데이터를 지우지 않으므로 언어팩을 다시 켜면 번역이 그대로 복구된다.
|
||||
if (! in_array($lang, $allowedLanguages)) {
|
||||
$fail(__('validation.translatable.unsupported_language', ['lang' => $lang]));
|
||||
if ($this->strictLocales) {
|
||||
$fail(__('validation.translatable.unsupported_language', ['lang' => $lang]));
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// null이거나 빈 문자열이 아닌 경우에만 검증
|
||||
|
||||
@@ -15,12 +15,14 @@ class TranslatableField implements ValidationRule
|
||||
/**
|
||||
* TranslatableField 생성자
|
||||
*
|
||||
* @param int $maxLength 각 번역의 최대 길이
|
||||
* @param bool $required 최소 하나의 번역 필수 여부
|
||||
* @param int $maxLength 각 번역의 최대 길이
|
||||
* @param bool $required 최소 하나의 번역 필수 여부
|
||||
* @param bool $strictLocales 지원 목록 밖 로케일 키를 실패로 처리할지 여부
|
||||
*/
|
||||
public function __construct(
|
||||
private int $maxLength = 255,
|
||||
private bool $required = false
|
||||
private bool $required = false,
|
||||
private bool $strictLocales = false
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -40,11 +42,20 @@ class TranslatableField implements ValidationRule
|
||||
|
||||
// 각 언어별 검증
|
||||
foreach ($value as $lang => $text) {
|
||||
// 지원하지 않는 언어 코드
|
||||
// 지원 목록 밖 로케일 키
|
||||
//
|
||||
// app.translatable_locales 는 활성 언어팩 기준으로 부팅마다 덮어써지는 가변 런타임
|
||||
// 값이다. 언어팩을 비활성화하면 기존 레코드에 남아 있던 그 로케일 키 때문에 수정
|
||||
// 자체가 차단되므로, 기본값은 "길이 검증 대상에서 제외하고 통과"로 둔다.
|
||||
// 데이터를 지우지 않으므로 언어팩을 다시 켜면 번역이 그대로 복구된다.
|
||||
if (! in_array($lang, $allowedLanguages)) {
|
||||
$fail(__('validation.translatable.unsupported_language', ['lang' => $lang]));
|
||||
if ($this->strictLocales) {
|
||||
$fail(__('validation.translatable.unsupported_language', ['lang' => $lang]));
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// null이거나 빈 문자열이 아닌 경우에만 검증
|
||||
@@ -56,8 +67,8 @@ class TranslatableField implements ValidationRule
|
||||
return;
|
||||
}
|
||||
|
||||
// 최대 길이 초과
|
||||
if (strlen($text) > $this->maxLength) {
|
||||
// 최대 길이 초과 (바이트가 아닌 문자 단위로 계산)
|
||||
if (mb_strlen($text) > $this->maxLength) {
|
||||
$fail(__('validation.translatable.max_length', [
|
||||
'lang' => $lang,
|
||||
'max' => $this->maxLength,
|
||||
|
||||
@@ -9,6 +9,19 @@ use App\Services\TemplateService;
|
||||
|
||||
class TemplateRouteResolver
|
||||
{
|
||||
/**
|
||||
* 템플릿 routes.json 이 아닌 **코어가 직접 소유하는** admin 경로 접두사.
|
||||
*
|
||||
* 레이아웃 편집기는 코어 기능이라 어느 템플릿의 routes.json 에도 선언되지 않는다.
|
||||
* 템플릿 라우트만 보고 판정하면 실제로 동작하는 화면이 HTTP 404 로 서빙되므로
|
||||
* (본문은 SPA 셸이라 화면은 뜨지만 상태 코드만 404), 존재하는 경로로 인정한다.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
private const CORE_ADMIN_ROUTE_PREFIXES = [
|
||||
'/admin/layout-editor',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly TemplateService $templateService,
|
||||
private readonly TemplateManagerInterface $templateManager,
|
||||
@@ -92,6 +105,11 @@ class TemplateRouteResolver
|
||||
*/
|
||||
public function routeExists(string $url, string $type = 'user'): bool
|
||||
{
|
||||
// 코어 소유 admin 경로는 템플릿 routes.json 에 없어도 존재하는 경로다.
|
||||
if ($type === 'admin' && $this->isCoreAdminRoute($url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$loaded = $this->loadActiveRoutes($type);
|
||||
// 템플릿 미설치/로드 실패 시 전 경로 404 차단 — 안전측 폴백 (D-47-3).
|
||||
if ($loaded === null) {
|
||||
@@ -112,6 +130,28 @@ class TemplateRouteResolver
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL 이 코어가 직접 소유하는 admin 경로인지 판정합니다.
|
||||
*
|
||||
* 접두사 뒤에는 경로 구분자(`/`) 또는 문자열 끝만 허용한다 — `/admin/layout-editorX`
|
||||
* 같은 유사 경로가 통과하지 않도록 한다.
|
||||
*
|
||||
* @param string $url 요청 URL 경로
|
||||
* @return bool 코어 소유 경로면 true
|
||||
*/
|
||||
private function isCoreAdminRoute(string $url): bool
|
||||
{
|
||||
$path = '/'.trim(parse_url($url, PHP_URL_PATH) ?? $url, '/');
|
||||
|
||||
foreach (self::CORE_ADMIN_ROUTE_PREFIXES as $prefix) {
|
||||
if ($path === $prefix || str_starts_with($path, $prefix.'/')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 템플릿($type)의 병합 routes 배열을 로드합니다.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Contracts\Repositories\ScheduleRepositoryInterface;
|
||||
use App\Enums\ScheduleResultStatus;
|
||||
use App\Enums\ScheduleTriggerType;
|
||||
use App\Enums\ScheduleType;
|
||||
use App\Exceptions\ScheduleExecutionException;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\Schedule;
|
||||
use App\Models\ScheduleHistory;
|
||||
@@ -14,6 +15,7 @@ use App\Support\OutboundUrlValidator;
|
||||
use App\Support\ScheduleCommandValidator;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -254,14 +256,14 @@ class ScheduleService
|
||||
* @param Schedule $schedule 스케줄
|
||||
* @return array 실행 결과
|
||||
*
|
||||
* @throws Exception 차단목록에 걸린 명령일 때
|
||||
* @throws ScheduleExecutionException 차단목록에 걸린 명령일 때
|
||||
*/
|
||||
private function executeArtisanCommand(Schedule $schedule): array
|
||||
{
|
||||
// 저장 시점 검증 도입 이전 데이터나 DB 직접 수정으로 들어온 값을 방어한다
|
||||
// (isUrlCallAllowed 와 동일 사유 — 실행 직전이 마지막 방어선).
|
||||
if (! ScheduleCommandValidator::isArtisanCommandAllowed($schedule->command)) {
|
||||
throw new Exception(__('schedule.artisan_not_allowed'));
|
||||
throw ScheduleExecutionException::artisanNotAllowed();
|
||||
}
|
||||
|
||||
Artisan::call($schedule->command, [], new BufferedOutput);
|
||||
@@ -278,7 +280,7 @@ class ScheduleService
|
||||
* @param Schedule $schedule 스케줄
|
||||
* @return array 실행 결과
|
||||
*
|
||||
* @throws Exception 실행 실패 시
|
||||
* @throws ScheduleExecutionException 차단목록에 걸렸거나 실행이 실패했을 때
|
||||
*/
|
||||
private function executeShellCommand(Schedule $schedule): array
|
||||
{
|
||||
@@ -287,7 +289,7 @@ class ScheduleService
|
||||
$arguments = ScheduleCommandValidator::tokenizeShellCommand($schedule->command);
|
||||
|
||||
if ($arguments === null || ! ScheduleCommandValidator::isShellCommandAllowed($schedule->command)) {
|
||||
throw new Exception(__('schedule.shell_not_allowed'));
|
||||
throw ScheduleExecutionException::shellNotAllowed();
|
||||
}
|
||||
|
||||
$timeout = $schedule->timeout ?? 60;
|
||||
@@ -297,7 +299,7 @@ class ScheduleService
|
||||
$result = Process::timeout($timeout)->run($arguments);
|
||||
|
||||
if ($result->failed()) {
|
||||
throw new Exception($result->errorOutput() ?: __('schedule.shell_command_failed'), $result->exitCode());
|
||||
throw ScheduleExecutionException::shellCommandFailed($result->errorOutput(), $result->exitCode());
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -312,14 +314,14 @@ class ScheduleService
|
||||
* @param Schedule $schedule 스케줄
|
||||
* @return array 실행 결과
|
||||
*
|
||||
* @throws Exception 호출 실패 시
|
||||
* @throws ScheduleExecutionException 내부망 URL 이거나 호출이 실패했을 때
|
||||
*/
|
||||
private function executeUrlCall(Schedule $schedule): array
|
||||
{
|
||||
// 저장된 URL 이 그대로 서버의 outbound 목적지가 되므로, 실행 직전에도 내부망 주소를 차단한다
|
||||
// (저장 시점 검증 도입 이전 데이터나 DB 직접 수정으로 들어온 값 방어).
|
||||
if (! $this->isUrlCallAllowed($schedule->command)) {
|
||||
throw new Exception(__('schedule.url_not_public'));
|
||||
throw ScheduleExecutionException::urlNotPublic();
|
||||
}
|
||||
|
||||
$timeout = $schedule->timeout ?? 30;
|
||||
@@ -327,7 +329,7 @@ class ScheduleService
|
||||
$response = Http::timeout($timeout)->get($schedule->command);
|
||||
|
||||
if ($response->failed()) {
|
||||
throw new Exception(__('schedule.http_request_failed', ['status' => $response->status()]), $response->status());
|
||||
throw ScheduleExecutionException::httpRequestFailed($response->status());
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -71,7 +71,7 @@ class ResourceFieldDescriber
|
||||
'creator' => '생성자 정보 객체 (uuid/name/email — creator 관계 파생)',
|
||||
'children' => '하위 항목 배열 (계층 트리 — children 관계 파생)',
|
||||
'parent' => '상위 항목 객체 (parent 관계 파생)',
|
||||
'permissions' => '연결된 권한 목록 (id/identifier/name — 역할 경유 권한 관계 파생)',
|
||||
'permissions' => '권한 목록 (각 원소 id/identifier/name — permissions 관계 또는 역할 경유 파생)',
|
||||
'recipient' => '수신자 사용자 객체 (uuid/name/email — recipientUser 관계 파생)',
|
||||
'sender' => '발신자 사용자 객체 (uuid/name/email — senderUser 관계 파생)',
|
||||
'author' => '작성자 사용자 객체 (uuid/name — author 관계 파생)',
|
||||
@@ -106,10 +106,8 @@ class ResourceFieldDescriber
|
||||
|
||||
// 감사/관계 공통 (도메인 무관하게 역할 고정 — 쓰기 응답에서 흔히 등장)
|
||||
'updated_by' => '최종 수정한 사용자 정보 (uuid/name — updated_by 관계 파생, 없으면 null)',
|
||||
'creator' => '생성자 정보 객체 (uuid/name/email — creator 관계 파생)',
|
||||
'user' => '대상 사용자 정보 객체 (uuid/name/email 등 — user 관계 파생)',
|
||||
'roles' => '보유 역할 목록 (각 원소 id/name/permissions — roles 관계 파생)',
|
||||
'permissions' => '권한 목록 (각 원소 identifier/name — permissions 관계 파생)',
|
||||
'avatar' => '아바타 이미지 URL (미등록 시 null)',
|
||||
|
||||
// 인증/토큰 (로그인/토큰 발급 응답)
|
||||
|
||||
Reference in new issue
Block a user