fix(security): 배포본 소스맵 노출 차단 + 관리자 설정 탭 지연로딩 + 동반 결함 수정
## 소스맵 노출 차단 (공개 이슈 )
배포본에 .map 이 포함돼 원본 TS/TSX 전문(sourcesContent, 한글 주석 포함)이
그대로 노출됐다. 생성·서빙·저장소 유입 3계층을 모두 막는다.
- 빌드 config 15곳(코어 3 + _bundled 12): sourcemap 하드코딩 제거.
G7_BUILD_SOURCEMAP 판정식으로 교체 — 미설정(로컬 npm run build)이면 생성해
개발 디버깅 경험을 보존하고, 0 이면 미생성.
- Build{Core,Module,Plugin,Template}Command: 죽어 있던 --production 플래그 복구.
$productionMode 를 콘솔 문자열에만 쓰고 npm 프로세스에 env 를 넘기지 않아
산출물이 개발 빌드와 동일했다. runNpmCommand 에 $env 를 추가해 주입
(--watch 에는 미주입). Symfony Process 는 부모 환경에 병합하므로 PATH 유실 없음.
- Allowed{Module,Plugin}FileType / {Module,Plugin}Service::getMimeType:
허용 확장자 map 제거 — 익명 200 서빙 차단(템플릿은 원래 미허용, 3종 정책 일치).
- ExtensionBundleService: CSS 번들의 /*# sourceMappingURL=... */ strip 추가.
CSS 는 블록 주석이라 JS 의 //# 패턴으로는 검출되지 않던 구멍.
- 추적 .map 13개 삭제 + .gitignore 전역 *.map 규칙(경로 한정 시 새 확장에서 누락).
실측: 산출 JS 의 sourceMappingURL 13 → 0, 추적 .map 13 → 0,
확장 디렉토리 npm run build 는 여전히 map 생성(개발 경험 회귀 없음).
## 관리자 환경설정 탭 지연 로딩
코어/이커머스/게시판 환경설정 화면이 진입 즉시 전 탭의 데이터소스를 한꺼번에
호출했다. 각 데이터소스에 활성 탭 조건(if)을 걸어 해당 탭에서만 fetch 하도록
변경하고, 결제 플러그인 3종의 테스트모드 상태 조회도 주문설정 탭으로 한정.
## 동반 결함 수정 (무관 결함 — 재발 방지 목적으로 같은 세션 처리)
- 나이스페이먼츠: 체크아웃 캐시 프리페치가 라우트를 가리지 않아 플러그인 번들이
로드되는 모든 페이지(홈/게시판/로그인)에서 주문서를 조회 → 비회원 매번 422.
형제 플러그인(kginicis)의 기존 가드 패턴을 적용해 체크아웃 경로로 한정.
- admin smoke 8건: 대부분 구현이 아니라 테스트 결함이었다 — URL 오타(단수 board),
존재하지 않는 권한키, 앱 로케일이 en 인데 한국어 라벨 로케이터, DataGrid 버튼을
먼저 잡던 휴리스틱 로케이터. 레이아웃에는 sticky className / 안정 id 를 부여.
- PHPDoc ↔ Pint 충돌 3건: 설명 없는 @param 은 no_superfluous_phpdoc_tags 가
삭제해 audit phpdoc-public-method 와 무한 충돌. 한국어 설명을 붙여 양쪽 충족
(리스너 3종의 설명 누락 메서드도 전수 보강).
- Log::spy 500 3건: spy 가 Log::channel('activity') 를 null 로 만들고
logActivity 가 null->info 로 \Error → 같은 줄 catch(\Exception) 은 못 잡아
통과. 운영에선 채널이 항상 로거이므로 제품 무결 → 테스트에 activity 채널
보존 헬퍼 추가.
- NhnKcpApiServiceTest 5건: 스텁이 Unix 바이너리만 만들어 Windows 분기
(pp_cli_exe.exe)에서만 실패. #!/bin/sh 는 Windows 실행 불가 → 파일 내 기존
컨벤션대로 skip 가드.
## 테스트
- 소스맵 범위 130 passed (신규: BuildCommandSourcemapEnv, NoSourcemapArtifacts,
ExtensionBundleService CSS strip, Allowed*FileType 반전, 자산 서빙 거부)
- 결제 3플러그인 505 passed / 0 failed (skipped 9 = Windows 전용 CLI, 사유 명시)
- 나이스페이먼츠 프론트 38 passed (가드 제거 시 red 실증 후 복원)
- E2E: production-sourcemap-exposure.spec.ts 6건 + 시나리오 매니페스트
버전: sirsoft-admin_basic 1.0.2 → 1.0.3, sirsoft-board 1.0.1 → 1.0.2
(각 manifest/package/lock/composer 동기화). 코어 7.0.4 는 미출시 누적.
This commit is contained in:
1 parent
84ca40f0d8
commit
90f154ecc0
132 files changed
+10069
-312
No files matched your search
+41
-24
@@ -3,8 +3,10 @@
|
||||
namespace Plugins\Sirsoft\PayKginicis\Tests\Feature\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\PluginSettingsService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Modules\Sirsoft\Ecommerce\Database\Factories\OrderFactory;
|
||||
use Modules\Sirsoft\Ecommerce\Database\Factories\OrderPaymentFactory;
|
||||
use Modules\Sirsoft\Ecommerce\Enums\OrderStatusEnum;
|
||||
@@ -20,6 +22,21 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
|
||||
private const TEST_SIGN_KEY = 'SU5JTElURV9UUklQTEVERVNfS0VZU1RS';
|
||||
|
||||
/**
|
||||
* 애플리케이션 로그를 spy 로 감시하되 `activity` 채널은 실제 로거로 유지합니다.
|
||||
*
|
||||
* `Log::spy()` 단독 사용 시 `Log::channel('activity')` 가 null 을 반환하고,
|
||||
* 결제 완료 훅이 태우는 활동 로그가 null 에 `info()` 를 호출해 \Error 로 죽는다.
|
||||
* (`ResolvesActivityLogType::logActivity` 의 catch 는 \Exception 만 잡아 통과시킴)
|
||||
*/
|
||||
private function spyApplicationLogKeepingActivityChannel(): void
|
||||
{
|
||||
$activityChannel = Log::channel('activity');
|
||||
|
||||
Log::spy();
|
||||
Log::shouldReceive('channel')->with('activity')->andReturn($activityChannel);
|
||||
}
|
||||
|
||||
private function makeAuthorizeResponse(string $tid, string $moid, int $amount, string $resultCode = '0000', array $overrides = []): array
|
||||
{
|
||||
return array_merge([
|
||||
@@ -46,7 +63,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
|
||||
$order = OrderFactory::new()->create([
|
||||
'user_id' => $user->id,
|
||||
'order_number' => 'ORD-TEST-' . random_int(10000, 99999),
|
||||
'order_number' => 'ORD-TEST-'.random_int(10000, 99999),
|
||||
'order_status' => OrderStatusEnum::PENDING_ORDER,
|
||||
'currency' => 'KRW',
|
||||
'currency_snapshot' => self::krwCurrencySnapshot(),
|
||||
@@ -97,11 +114,11 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
'redirect_fail_url' => '/shop/checkout',
|
||||
];
|
||||
|
||||
$settingsMock = $this->createMock(\App\Services\PluginSettingsService::class);
|
||||
$settingsMock = $this->createMock(PluginSettingsService::class);
|
||||
$settingsMock->method('get')
|
||||
->willReturn(array_merge($defaults, $overrides));
|
||||
|
||||
$this->app->instance(\App\Services\PluginSettingsService::class, $settingsMock);
|
||||
$this->app->instance(PluginSettingsService::class, $settingsMock);
|
||||
}
|
||||
|
||||
private function makeCallbackParams(string $moid, int $totPrice, array $overrides = []): array
|
||||
@@ -109,7 +126,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
return array_merge([
|
||||
'resultCode' => '0000',
|
||||
'resultMsg' => '성공',
|
||||
'authToken' => 'AUTH_TOKEN_' . uniqid(),
|
||||
'authToken' => 'AUTH_TOKEN_'.uniqid(),
|
||||
'authUrl' => 'https://fcstdpay.inicis.com/api/payAuth',
|
||||
// idc_name 은 KG 이니시스가 success 콜백에 항상 포함시키는 IDC 식별자.
|
||||
// 컨트롤러가 isValidIdcAuthUrl 화이트리스트 검증에 사용 (SSRF 방어).
|
||||
@@ -127,7 +144,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$order = $this->createTestOrder(50000);
|
||||
$this->mockPluginSettings();
|
||||
|
||||
$tid = 'TID_' . uniqid();
|
||||
$tid = 'TID_'.uniqid();
|
||||
$params = $this->makeCallbackParams($order->order_number, 50000);
|
||||
|
||||
Http::fake([
|
||||
@@ -163,7 +180,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$order = $this->createTestOrder(50000);
|
||||
$this->mockPluginSettings();
|
||||
|
||||
$tid = 'TID_EASYPAY_' . uniqid();
|
||||
$tid = 'TID_EASYPAY_'.uniqid();
|
||||
$params = $this->makeCallbackParams($order->order_number, 50000);
|
||||
|
||||
Http::fake([
|
||||
@@ -306,7 +323,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$order = $this->createTestOrder(50000);
|
||||
$this->mockPluginSettings();
|
||||
|
||||
$tid = 'TID_POST_COMMIT_' . uniqid();
|
||||
$tid = 'TID_POST_COMMIT_'.uniqid();
|
||||
$params = $this->makeCallbackParams($order->order_number, 50000);
|
||||
|
||||
$orderService = $this->createMock(OrderProcessingService::class);
|
||||
@@ -316,7 +333,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$orderService->expects($this->once())
|
||||
->method('completePayment')
|
||||
->willReturnCallback(function (Order $callbackOrder, array $paymentData, ?int $paidAmount) use ($tid): void {
|
||||
\Illuminate\Support\Facades\DB::transaction(function () use ($callbackOrder, $paymentData, $paidAmount, $tid): void {
|
||||
DB::transaction(function () use ($callbackOrder, $paymentData, $paidAmount, $tid): void {
|
||||
$callbackOrder->forceFill([
|
||||
'order_status' => OrderStatusEnum::PAYMENT_COMPLETE,
|
||||
'total_paid_amount' => $paidAmount,
|
||||
@@ -477,7 +494,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$this->markVbankIssued($order, 'VBANK_TID_LOG', '1234567890');
|
||||
$this->mockPluginSettings();
|
||||
|
||||
Log::spy();
|
||||
$this->spyApplicationLogKeepingActivityChannel();
|
||||
|
||||
$response = $this->post('/plugins/sirsoft-pay_kginicis/payment/vbank-notify', $this->makeVbankNotifyPayload([
|
||||
'no_tid' => 'VBANK_TID_LOG',
|
||||
@@ -500,7 +517,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$order = $this->createTestOrder(50000);
|
||||
$this->mockPluginSettings();
|
||||
|
||||
$tid = 'MOBILE_TID_' . uniqid();
|
||||
$tid = 'MOBILE_TID_'.uniqid();
|
||||
|
||||
Http::fake([
|
||||
'fcmobile.inicis.com/smart/payReq.ini' => Http::response(http_build_query([
|
||||
@@ -521,7 +538,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
]), 200),
|
||||
]);
|
||||
|
||||
$response = $this->post('/plugins/sirsoft-pay_kginicis/payment/mobile/callback?' . http_build_query([
|
||||
$response = $this->post('/plugins/sirsoft-pay_kginicis/payment/mobile/callback?'.http_build_query([
|
||||
'orderId' => $order->order_number,
|
||||
'selectedPaymentMethod' => 'kginicis_naverpay',
|
||||
]), [
|
||||
@@ -560,7 +577,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$order = $this->createTestOrder(50000);
|
||||
$this->mockPluginSettings();
|
||||
|
||||
$tid = 'MOBILE_TID_POST_COMMIT_' . uniqid();
|
||||
$tid = 'MOBILE_TID_POST_COMMIT_'.uniqid();
|
||||
|
||||
$orderService = $this->createMock(OrderProcessingService::class);
|
||||
$orderService->method('findByOrderNumber')
|
||||
@@ -569,7 +586,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$orderService->expects($this->once())
|
||||
->method('completePayment')
|
||||
->willReturnCallback(function (Order $callbackOrder, array $paymentData, ?int $paidAmount) use ($tid): void {
|
||||
\Illuminate\Support\Facades\DB::transaction(function () use ($callbackOrder, $paymentData, $paidAmount, $tid): void {
|
||||
DB::transaction(function () use ($callbackOrder, $paymentData, $paidAmount, $tid): void {
|
||||
$callbackOrder->forceFill([
|
||||
'order_status' => OrderStatusEnum::PAYMENT_COMPLETE,
|
||||
'total_paid_amount' => $paidAmount,
|
||||
@@ -660,7 +677,7 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
$this->markVbankIssued($order, 'MOBILE_VBANK_TID_LOG', '1234567890');
|
||||
$this->mockPluginSettings();
|
||||
|
||||
Log::spy();
|
||||
$this->spyApplicationLogKeepingActivityChannel();
|
||||
|
||||
$response = $this->post('/plugins/sirsoft-pay_kginicis/payment/mobile/vbank-notify', [
|
||||
'P_STATUS' => '02',
|
||||
@@ -731,16 +748,16 @@ class PaymentCallbackControllerTest extends PluginTestCase
|
||||
private function makeVbankNotifyPayload(array $overrides = []): array
|
||||
{
|
||||
return array_merge([
|
||||
'no_tid' => 'VBANK_TID_' . uniqid(),
|
||||
'no_oid' => 'ORD-TEST-VBANK',
|
||||
'id_merchant' => 'INIpayTest',
|
||||
'dt_trans' => now()->format('Ymd'),
|
||||
'tm_trans' => now()->format('His'),
|
||||
'cd_bank' => '04',
|
||||
'no_vacct' => '1234567890',
|
||||
'amt_input' => '30000',
|
||||
'no_tid' => 'VBANK_TID_'.uniqid(),
|
||||
'no_oid' => 'ORD-TEST-VBANK',
|
||||
'id_merchant' => 'INIpayTest',
|
||||
'dt_trans' => now()->format('Ymd'),
|
||||
'tm_trans' => now()->format('His'),
|
||||
'cd_bank' => '04',
|
||||
'no_vacct' => '1234567890',
|
||||
'amt_input' => '30000',
|
||||
'nm_inputbank' => '국민은행',
|
||||
'nm_input' => '홍길동',
|
||||
'nm_input' => '홍길동',
|
||||
], $overrides);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user