fix(security): 예약 작업·언어팩·인스톨러의 차단목록을 허용목록으로 전환
KISA 신고포상제 접수 3건(KVE-2026-1677/1678/1679)의 공통 원인은 하나다 — "위험한 것을 골라 막았고, 목록 밖으로 우회됐다". 세 지점 모두 판정을 뒤집는다. 예약 작업 Artisan (KVE-2026-1679) 차단 9개 / 허용 229개였던 구조를 허용목록으로 바꾸고 명령마다 허용 옵션을 선언한다. 검증 과정에서 보고서보다 짧은 경로를 추가로 발견했다 — 검증기는 preg_split 의 첫 토큰을 명령명으로 봤지만 실행부는 문자열째 넘겼고, parameters 가 비면 Laravel 이 StringInput 으로 재파싱한다. 따옴표 한 쌍이면 차단목록의 tinker 가 그대로 실행됐다 (마커 파일로 확인). 파서를 엄격 형태 하나로 고정하고 실행은 (명령명, 인자배열)로 넘겨 재해석 지점 자체를 없앴다. 언어팩 (KVE-2026-1678) 위험 함수 11개를 정규식으로 나열하던 검사를 토큰 상태기계로 교체해 "번역 배열만" 통과시킨다. 목록에 없는 함수도, 함수 이름을 아예 쓰지 않는 형태도 원리적으로 막힌다. 파일 형식·PHP 위치·심볼릭 링크도 화이트리스트로 뒤집었다. 활성 승격이 require 배선의 필수 조건이므로 설치와 활성화의 권한 경계를 네 설치 경로 전부에 같은 강도로 건다 — 경로별 면제는 곧 우회로가 되기 때문이다. 화면은 운영자의 활성화 권한을 보고 auto_activate 를 실을지 결정하므로 재설치 흐름은 그대로 동작한다. 인스톨러 (KVE-2026-1677) 실행 바이너리 자리에 인자가 들어가는 것을 형태 규칙으로 차단한다. escapeshellarg 는 "하나의 인자" 임만 보장할 뿐 그 인자가 실행 파일인지 스크립트인지는 보장하지 않는다. 판정을 의존성 0 공용 정책으로 모아 진단 API·설치 워커·저장 시점이 같은 규칙을 쓴다. stat 은 호출하지 않는다 — 접근이 제한된 서버에서 정상 경로가 거부되던 회귀를 재발시키지 않기 위함이다. 검증: 백엔드 392건 + 프론트 7건 green(skip 1, symlink 미지원 환경). PoC 마커로 red 를 먼저 확보하고, 수정 후 stash 역회귀로 다시 red 가 되는 것까지 확인했다.
This commit is contained in:
1 parent
30867e0e0b
commit
4b6adf4788
45 files changed
+4382
-301
No files matched your search
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\LanguagePack;
|
||||
|
||||
use App\Services\LanguagePack\LanguagePackPhpArrayValidator;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* 언어팩 PHP 파일 문법 검사기 테스트.
|
||||
*
|
||||
* KVE-2026-1678: 언어팩의 PHP 파일은 활성화되면 `require` 되어 그대로 실행된다. 기존 검사는
|
||||
* 위험 함수 11개를 정규식으로 나열해 막았고, 목록에 없는 함수·문법으로 전부 우회됐다.
|
||||
* 본 검사기는 "번역 배열만" 통과시키는 화이트리스트 문법이므로, 우회 매트릭스는
|
||||
* **함수 이름이 아니라 문법 형태**를 축으로 전개한다.
|
||||
*
|
||||
* DB·프레임워크 부팅이 필요 없는 순수 판정 유틸이라 PHPUnit\Framework\TestCase 를 직접 상속한다.
|
||||
*/
|
||||
class LanguagePackPhpArrayValidatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* 번역 배열만 담은 정상 파일은 통과한다 (기존 자산 비파괴).
|
||||
*
|
||||
* @param string $source PHP 소스
|
||||
*
|
||||
* @scenario vector=php_syntax_validator, actor_permission=cli_system
|
||||
*
|
||||
* @effects translation_array_files_are_accepted
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('safeSourceProvider')]
|
||||
public function it_accepts_translation_array_files(string $source): void
|
||||
{
|
||||
$violation = LanguagePackPhpArrayValidator::inspect($source);
|
||||
|
||||
$this->assertNull(
|
||||
$violation,
|
||||
'정상 언어팩 파일이 거부됨: '.($violation['reason'] ?? '').' — '.$source
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 번역 배열 외의 문법은 전부 거부한다.
|
||||
*
|
||||
* 기존 블록리스트가 놓치던 함수들(`file_put_contents` `fopen` `call_user_func` `assert`
|
||||
* 백틱)과, 함수 이름을 아예 쓰지 않는 우회(문자열 리터럴 호출·가변 변수·heredoc·
|
||||
* 닫는 태그 뒤 인라인 코드)를 같은 규칙 하나로 막는지 확인한다.
|
||||
*
|
||||
* @param string $source PHP 소스
|
||||
* @param string $vector 우회 수법 (실패 메시지용)
|
||||
*
|
||||
* @scenario vector=php_syntax_validator, actor_permission=cli_system
|
||||
*
|
||||
* @effects function_calls_are_rejected_regardless_of_name, name_free_bypasses_are_rejected
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('unsafeSourceProvider')]
|
||||
public function it_rejects_anything_that_is_not_a_translation_array(string $source, string $vector): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
LanguagePackPhpArrayValidator::isSafe($source),
|
||||
"차단되어야 하는 소스가 통과함 ({$vector}): {$source}"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 깨진 소스는 파싱 단계에서 조기 거부한다.
|
||||
*
|
||||
* @scenario vector=php_syntax_validator, actor_permission=cli_system
|
||||
*
|
||||
* @effects broken_and_oversized_sources_are_rejected_early
|
||||
*/
|
||||
#[Test]
|
||||
public function it_rejects_sources_that_do_not_parse(): void
|
||||
{
|
||||
$violation = LanguagePackPhpArrayValidator::inspect('<?php return [ ;');
|
||||
|
||||
$this->assertNotNull($violation);
|
||||
$this->assertSame('parse_error', $violation['reason']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 크기 상한을 넘는 소스는 파서를 돌리지 않고 거부한다.
|
||||
*/
|
||||
#[Test]
|
||||
public function it_rejects_sources_over_the_size_limit(): void
|
||||
{
|
||||
$source = '<?php return ['.str_repeat("'a' => 'b', ", 200000).'];';
|
||||
|
||||
$this->assertGreaterThan(LanguagePackPhpArrayValidator::MAX_BYTES, strlen($source));
|
||||
|
||||
$violation = LanguagePackPhpArrayValidator::inspect($source);
|
||||
|
||||
$this->assertNotNull($violation);
|
||||
$this->assertSame('file_too_large', $violation['reason']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 중첩 깊이 상한을 넘는 배열은 거부한다.
|
||||
*/
|
||||
#[Test]
|
||||
public function it_rejects_arrays_deeper_than_the_depth_limit(): void
|
||||
{
|
||||
$depth = LanguagePackPhpArrayValidator::MAX_DEPTH + 5;
|
||||
$source = '<?php return '.str_repeat('[', $depth).str_repeat(']', $depth).';';
|
||||
|
||||
$this->assertFalse(LanguagePackPhpArrayValidator::isSafe($source));
|
||||
}
|
||||
|
||||
/**
|
||||
* 위반 지점의 줄 번호를 보고한다 (운영자가 어느 줄을 고쳐야 하는지 알 수 있어야 한다).
|
||||
*
|
||||
* @scenario vector=php_syntax_validator, actor_permission=cli_system
|
||||
*
|
||||
* @effects violation_line_is_reported
|
||||
*/
|
||||
#[Test]
|
||||
public function it_reports_the_line_of_the_violation(): void
|
||||
{
|
||||
$source = "<?php\n\nreturn [\n 'a' => 'b',\n 'c' => system('id'),\n];\n";
|
||||
|
||||
$violation = LanguagePackPhpArrayValidator::inspect($source);
|
||||
|
||||
$this->assertNotNull($violation);
|
||||
$this->assertSame(5, $violation['line']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 통과해야 하는 소스 목록.
|
||||
*
|
||||
* @return array<string, array{string}>
|
||||
*/
|
||||
public static function safeSourceProvider(): array
|
||||
{
|
||||
return [
|
||||
'빈 배열' => ["<?php\n\nreturn [];\n"],
|
||||
'단순 문자열 배열' => ["<?php\n\nreturn ['hello' => 'こんにちは'];\n"],
|
||||
'중첩 배열' => ["<?php\nreturn ['a' => ['b' => ['c' => 'd']]];\n"],
|
||||
'숫자 키' => ["<?php\nreturn [0 => 'zero', 1 => 'one'];\n"],
|
||||
'키 없는 항목' => ["<?php\nreturn ['first', 'second'];\n"],
|
||||
'후행 쉼표' => ["<?php\nreturn [\n 'a' => 'b',\n];\n"],
|
||||
'declare 프리픽스' => ["<?php\n\ndeclare(strict_types=1);\n\nreturn ['a' => 'b'];\n"],
|
||||
'문자열 리터럴 연결' => ["<?php\nreturn ['a' => 'long '.'message'];\n"],
|
||||
'숫자·bool·null' => ["<?php\nreturn ['n' => 1, 'f' => 1.5, 'neg' => -3, 't' => true, 'f2' => false, 'x' => null];\n"],
|
||||
'주석 포함' => ["<?php\n// 인사말\nreturn [\n /* 그룹 */ 'a' => 'b', // 항목\n];\n"],
|
||||
'array() 레거시 문법' => ["<?php\nreturn array('a' => 'b');\n"],
|
||||
'닫는 태그 포함' => ["<?php\nreturn ['a' => 'b'];\n?>\n"],
|
||||
'이스케이프 포함 문자열' => ["<?php\nreturn ['a' => 'It\\'s ok', 'b' => \"tab\\there\"];\n"],
|
||||
'대문자 상수 표기' => ["<?php\nreturn ['a' => TRUE, 'b' => NULL];\n"],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 차단되어야 하는 소스 목록.
|
||||
*
|
||||
* @return array<string, array{string, string}>
|
||||
*/
|
||||
public static function unsafeSourceProvider(): array
|
||||
{
|
||||
return [
|
||||
// 기존 블록리스트가 잡던 것
|
||||
'eval' => ["<?php\neval(\$_GET['c']);\nreturn [];\n", '기존 목록 — eval'],
|
||||
// 기존 블록리스트가 놓치던 것
|
||||
'file_put_contents' => ["<?php\nfile_put_contents('/tmp/g7','x');\nreturn [];\n", '목록 누락 — 파일 쓰기'],
|
||||
'fopen/fwrite' => ["<?php\n\$h = fopen('/tmp/g7','w');\nfwrite(\$h,'x');\nreturn [];\n", '목록 누락 — 스트림'],
|
||||
'unlink' => ["<?php\nunlink('/etc/passwd');\nreturn [];\n", '목록 누락 — 삭제'],
|
||||
'call_user_func' => ["<?php\ncall_user_func('system','id');\nreturn [];\n", '목록 누락 — 간접 호출'],
|
||||
'assert' => ["<?php\nassert(\"system('id')\");\nreturn [];\n", '목록 누락 — assert'],
|
||||
'백틱 실행 연산자' => ["<?php\n\$o = `id`;\nreturn [];\n", '목록 누락 — 백틱'],
|
||||
'file_get_contents 반환' => ["<?php\nreturn ['a' => file_get_contents('/etc/passwd')];\n", '목록 누락 — 값 자리 호출'],
|
||||
|
||||
// 함수 이름을 쓰지 않는 우회 (블록리스트로는 원리적으로 불가)
|
||||
'문자열 리터럴 호출' => ["<?php\nreturn [('system')('id')];\n", '이름 없는 호출 — 토큰 집합 검사 우회'],
|
||||
'가변 변수 호출' => ["<?php\n\$a='system';\$a('id');\nreturn [];\n", '가변 변수'],
|
||||
'변수 사용' => ["<?php\nreturn ['a' => \$GLOBALS['x']];\n", '변수'],
|
||||
'heredoc 보간' => ["<?php\n\$x = <<<EOT\n{\$_GET['c']}\nEOT;\nreturn [];\n", 'heredoc'],
|
||||
'닫는 태그 뒤 인라인 코드' => ["<?php\nreturn [];\n?>\n<?php system('id');\n", '닫는 태그 뒤 두 번째 블록'],
|
||||
'닫는 태그 뒤 출력' => ["<?php\nreturn [];\n?>\nleaked\n", '닫는 태그 뒤 인라인 출력'],
|
||||
'new 객체' => ["<?php\nreturn ['a' => new \\stdClass];\n", 'new'],
|
||||
'상수 참조' => ["<?php\nreturn ['a' => PHP_OS];\n", '상수 — 정보 노출'],
|
||||
'삼항 연산' => ["<?php\nreturn ['a' => 1 > 0 ? 'y' : 'n'];\n", '연산자'],
|
||||
'함수 선언' => ["<?php\nfunction g7_evil(){ system('id'); }\nreturn [];\n", '함수 선언'],
|
||||
'클래스 선언' => ["<?php\nclass Evil { }\nreturn [];\n", '클래스 선언'],
|
||||
'use 문' => ["<?php\nuse App\\Models\\User;\nreturn [];\n", 'use'],
|
||||
'return 없음' => ["<?php\n\$a = 1;\n", 'return 부재'],
|
||||
'return 뒤 추가 구문' => ["<?php\nreturn [];\nsystem('id');\n", 'return 뒤 잔여 토큰'],
|
||||
'단축 에코 태그' => ["<?= system('id') ?>\n", '단축 태그'],
|
||||
'선행 인라인 HTML' => ["leaked\n<?php\nreturn [];\n", '여는 태그 앞 출력'],
|
||||
'괄호 그룹화' => ["<?php\nreturn ('a');\n", '괄호 — array 뒤가 아님'],
|
||||
'declare 위장' => ["<?php\ndeclare(ticks=1);\nreturn [];\n", 'declare 다른 지시자'],
|
||||
'스프레드' => ["<?php\nreturn [...\$a];\n", '스프레드 연산자'],
|
||||
'함수 호출을 키로' => ["<?php\nreturn [system('id') => 'x'];\n", '키 자리 호출'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace Tests\Unit\Services\LanguagePack;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\LanguagePack\LanguagePackPhpArrayValidator;
|
||||
use App\Services\LanguagePackService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
use ZipArchive;
|
||||
|
||||
@@ -53,7 +54,7 @@ class LanguagePackSecurityTest extends TestCase
|
||||
private function makeZip(array $files): string
|
||||
{
|
||||
$zipPath = $this->tempDir.DIRECTORY_SEPARATOR.uniqid('pack_', true).'.zip';
|
||||
$zip = new ZipArchive();
|
||||
$zip = new ZipArchive;
|
||||
$zip->open($zipPath, ZipArchive::CREATE);
|
||||
foreach ($files as $name => $content) {
|
||||
$zip->addFromString($name, $content);
|
||||
@@ -109,7 +110,9 @@ class LanguagePackSecurityTest extends TestCase
|
||||
$file = new UploadedFile($zip, 'pack.zip', 'application/zip', null, true);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessageMatches('/허용되지 않/u');
|
||||
// 판정이 "위험 함수 목록" 에서 "번역 배열만 허용" 으로 바뀌었으므로 메시지도 바뀐다.
|
||||
// 이 테스트의 의도(backend 안의 eval 이 차단된다)는 그대로 유지한다.
|
||||
$this->expectExceptionMessageMatches('/번역 배열만/u');
|
||||
|
||||
$this->service->installFromFile($file, false, null);
|
||||
}
|
||||
@@ -130,4 +133,238 @@ class LanguagePackSecurityTest extends TestCase
|
||||
// 활성 디렉토리 정리
|
||||
File::deleteDirectory(base_path('lang-packs/test-core-ja'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 블록리스트가 놓치던 페이로드가 설치 단계에서 거부된다.
|
||||
*
|
||||
* KVE-2026-1678 주 시나리오. 정규식 블록리스트는 위험 함수 11개만 봤기 때문에
|
||||
* `file_put_contents` 한 줄로 우회됐고, 활성화되면 `require` 되어 그대로 실행됐다.
|
||||
*
|
||||
* @param string $payload backend PHP 파일 내용
|
||||
* @param string $vector 우회 수법 (실패 메시지용)
|
||||
*
|
||||
* @scenario vector=assert_security_rules, actor_permission=cli_system
|
||||
*
|
||||
* @effects install_rejects_php_that_is_not_a_translation_array
|
||||
*/
|
||||
#[DataProvider('blocklistBypassPayloadProvider')]
|
||||
public function test_install_rejects_payloads_the_old_blocklist_missed(string $payload, string $vector): void
|
||||
{
|
||||
$zip = $this->makeZip([
|
||||
'language-pack.json' => $this->validManifestJson(),
|
||||
'backend/ja/messages.php' => $payload,
|
||||
]);
|
||||
|
||||
$file = new UploadedFile($zip, 'pack.zip', 'application/zip', null, true);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
try {
|
||||
$this->service->installFromFile($file, false, null);
|
||||
} finally {
|
||||
// 거부되지 않고 설치되었다면 잔여물을 남기지 않는다.
|
||||
File::deleteDirectory(base_path('lang-packs/test-core-ja'));
|
||||
}
|
||||
|
||||
$this->fail("차단되어야 하는 페이로드가 설치됨 ({$vector})");
|
||||
}
|
||||
|
||||
/**
|
||||
* 허용 확장자 밖의 파일은 거부된다 (대소문자 무관).
|
||||
*
|
||||
* 이전 판정은 `str_ends_with($absolute, '.php')` 라 `EVIL.PHP` 를 PHP 로 보지 않았고,
|
||||
* `.phar` `.phtml` 처럼 실행 가능한 다른 확장자도 아무 검사 없이 통과했다.
|
||||
*
|
||||
* @param string $path ZIP 안의 파일 경로
|
||||
* @param string $reason 차단 사유 (실패 메시지용)
|
||||
*
|
||||
* @scenario vector=assert_security_rules, actor_permission=cli_system
|
||||
*
|
||||
* @effects install_rejects_files_outside_the_extension_whitelist
|
||||
*/
|
||||
#[DataProvider('disallowedFilePathProvider')]
|
||||
public function test_install_rejects_files_outside_the_extension_whitelist(string $path, string $reason): void
|
||||
{
|
||||
$zip = $this->makeZip([
|
||||
'language-pack.json' => $this->validManifestJson(),
|
||||
'backend/ja/messages.php' => "<?php\nreturn [];\n",
|
||||
$path => "<?php\nsystem('id');\n",
|
||||
]);
|
||||
|
||||
$file = new UploadedFile($zip, 'pack.zip', 'application/zip', null, true);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
try {
|
||||
$this->service->installFromFile($file, false, null);
|
||||
} finally {
|
||||
File::deleteDirectory(base_path('lang-packs/test-core-ja'));
|
||||
}
|
||||
|
||||
$this->fail("차단되어야 하는 파일이 설치됨 ({$reason}): {$path}");
|
||||
}
|
||||
|
||||
/**
|
||||
* manifest 의 locale 과 다른 디렉토리에 놓인 PHP 는 거부된다.
|
||||
*
|
||||
* @scenario vector=assert_security_rules, actor_permission=cli_system
|
||||
*
|
||||
* @effects install_rejects_php_outside_the_declared_locale_directory
|
||||
*/
|
||||
public function test_install_rejects_php_in_a_different_locale_directory(): void
|
||||
{
|
||||
$zip = $this->makeZip([
|
||||
'language-pack.json' => $this->validManifestJson(),
|
||||
'backend/ko/messages.php' => "<?php\nreturn [];\n",
|
||||
]);
|
||||
|
||||
$file = new UploadedFile($zip, 'pack.zip', 'application/zip', null, true);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessageMatches('/backend/i');
|
||||
|
||||
try {
|
||||
$this->service->installFromFile($file, false, null);
|
||||
} finally {
|
||||
File::deleteDirectory(base_path('lang-packs/test-core-ja'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 정상 언어팩 구성(declare 프리픽스·문자열 연결·중첩 배열·json·md)은 그대로 설치된다.
|
||||
*
|
||||
* 확장(`modules/`·`plugins/`) 의 lang 파일에 실제로 나타나는 형태이므로
|
||||
* 이 케이스가 깨지면 기존 자산이 설치 불가가 된다.
|
||||
*
|
||||
* @scenario vector=assert_security_rules, actor_permission=cli_system
|
||||
*
|
||||
* @effects install_accepts_real_world_translation_files
|
||||
*/
|
||||
public function test_install_accepts_real_world_translation_files(): void
|
||||
{
|
||||
$zip = $this->makeZip([
|
||||
'language-pack.json' => $this->validManifestJson(),
|
||||
'backend/ja/messages.php' => "<?php\n\ndeclare(strict_types=1);\n\nreturn [\n 'a' => 'long '.'message',\n 'nested' => ['x' => ['y' => 1, 'z' => null]],\n];\n",
|
||||
'frontend/ja.json' => '{"hello":"こんにちは"}',
|
||||
'README.md' => "# pack\n",
|
||||
]);
|
||||
|
||||
$file = new UploadedFile($zip, 'pack.zip', 'application/zip', null, true);
|
||||
|
||||
$pack = $this->service->installFromFile($file, false, null);
|
||||
|
||||
$this->assertSame('test-core-ja', $pack->identifier);
|
||||
|
||||
File::deleteDirectory(base_path('lang-packs/test-core-ja'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 심볼릭 링크가 포함된 패키지는 거부된다 (패키지 밖 파일을 끌어들이는 통로 차단).
|
||||
*
|
||||
* @scenario vector=assert_security_rules, actor_permission=cli_system
|
||||
*
|
||||
* @effects install_rejects_packages_containing_symlinks
|
||||
*/
|
||||
public function test_install_rejects_packages_containing_symlinks(): void
|
||||
{
|
||||
$packageRoot = $this->tempDir.DIRECTORY_SEPARATOR.'symlink_pack';
|
||||
File::ensureDirectoryExists($packageRoot.DIRECTORY_SEPARATOR.'backend'.DIRECTORY_SEPARATOR.'ja');
|
||||
File::put($packageRoot.DIRECTORY_SEPARATOR.'language-pack.json', $this->validManifestJson());
|
||||
File::put($packageRoot.DIRECTORY_SEPARATOR.'backend'.DIRECTORY_SEPARATOR.'ja'.DIRECTORY_SEPARATOR.'messages.php', "<?php\nreturn [];\n");
|
||||
|
||||
$target = $this->tempDir.DIRECTORY_SEPARATOR.'outside.json';
|
||||
File::put($target, '{}');
|
||||
|
||||
if (! @symlink($target, $packageRoot.DIRECTORY_SEPARATOR.'linked.json')) {
|
||||
$this->markTestSkipped('이 환경에서는 심볼릭 링크를 만들 수 없어 (권한 부족) 링크 거부를 실측할 수 없다.');
|
||||
}
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
$this->invokeAssertSecurityRules($packageRoot, json_decode($this->validManifestJson(), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장소에 동봉된 번들 언어팩 전부가 새 검사를 통과한다.
|
||||
*
|
||||
* 회귀 방지의 핵심 — 검사를 조인 결과로 기존 자산이 설치 불가가 되면 안 된다.
|
||||
* 번들에도 같은 검사를 적용하기로 했으므로(검사 경로 단일화) 전수로 확인한다.
|
||||
*
|
||||
* @scenario vector=assert_security_rules, actor_permission=cli_system
|
||||
*
|
||||
* @effects every_bundled_pack_passes_the_new_validator
|
||||
*/
|
||||
public function test_all_bundled_packs_pass_the_validator(): void
|
||||
{
|
||||
$root = base_path('lang-packs/_bundled');
|
||||
|
||||
$this->assertDirectoryExists($root);
|
||||
|
||||
$files = [];
|
||||
foreach (File::allFiles($root) as $file) {
|
||||
if (strtolower($file->getExtension()) === 'php') {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNotEmpty($files, '번들 언어팩 PHP 파일이 하나도 수집되지 않았다 — 전수 검사가 공전한다');
|
||||
|
||||
$violations = [];
|
||||
foreach ($files as $path) {
|
||||
$violation = LanguagePackPhpArrayValidator::inspectFile($path);
|
||||
|
||||
if ($violation !== null) {
|
||||
$violations[] = str_replace($root, '', $path)." (line {$violation['line']}: {$violation['reason']})";
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame([], $violations, '번들 언어팩이 새 검사에서 거부됨: '.implode(', ', $violations));
|
||||
}
|
||||
|
||||
/**
|
||||
* private 보안 검사를 직접 호출합니다 (ZIP 으로는 심볼릭 링크를 넣을 수 없다).
|
||||
*
|
||||
* @param string $packageRoot 패키지 루트
|
||||
* @param array<string, mixed> $manifest manifest 데이터
|
||||
*/
|
||||
private function invokeAssertSecurityRules(string $packageRoot, array $manifest): void
|
||||
{
|
||||
$method = new \ReflectionMethod($this->service, 'assertSecurityRules');
|
||||
$method->invoke($this->service, $packageRoot, $manifest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기존 정규식 블록리스트가 놓치던 페이로드 목록.
|
||||
*
|
||||
* @return array<string, array{string, string}>
|
||||
*/
|
||||
public static function blocklistBypassPayloadProvider(): array
|
||||
{
|
||||
return [
|
||||
'file_put_contents' => ["<?php\nfile_put_contents('/tmp/g7_lp_proof','x');\nreturn [];\n", '파일 쓰기'],
|
||||
'fopen + fwrite' => ["<?php\n\$h=fopen('/tmp/g7_lp_proof','w');fwrite(\$h,'x');\nreturn [];\n", '스트림'],
|
||||
'call_user_func' => ["<?php\ncall_user_func('system','id');\nreturn [];\n", '간접 호출'],
|
||||
'assert' => ["<?php\nassert(\"system('id')\");\nreturn [];\n", 'assert'],
|
||||
'백틱' => ["<?php\n\$o=`id`;\nreturn [];\n", '백틱 실행 연산자'],
|
||||
'문자열 리터럴 호출' => ["<?php\nreturn [('system')('id')];\n", '이름 없는 호출'],
|
||||
'닫는 태그 뒤 코드' => ["<?php\nreturn [];\n?>\n<?php system('id');\n", '두 번째 PHP 블록'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 허용 확장자 밖이라 거부되어야 하는 파일 경로 목록.
|
||||
*
|
||||
* @return array<string, array{string, string}>
|
||||
*/
|
||||
public static function disallowedFilePathProvider(): array
|
||||
{
|
||||
return [
|
||||
'대문자 확장자' => ['backend/ja/EVIL.PHP', '확장자 판정이 대소문자를 구분하면 통과한다'],
|
||||
'phar' => ['backend/ja/evil.phar', '실행 가능한 아카이브'],
|
||||
'phtml' => ['backend/ja/evil.phtml', 'PHP 템플릿 확장자'],
|
||||
'php5' => ['backend/ja/evil.php5', '레거시 PHP 확장자'],
|
||||
'확장자 없음' => ['backend/ja/htaccess_like', '확장자 화이트리스트 밖'],
|
||||
'루트 PHP' => ['evil.php', 'backend 밖 PHP'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,14 @@ namespace Tests\Unit\Services\LanguagePack;
|
||||
|
||||
use App\Enums\LanguagePackScope;
|
||||
use App\Enums\LanguagePackStatus;
|
||||
use App\Exceptions\LanguagePackOperationException;
|
||||
use App\Extension\HookManager;
|
||||
use App\Models\LanguagePack;
|
||||
use App\Services\LanguagePack\LanguagePackRegistry;
|
||||
use App\Services\LanguagePackService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -225,7 +229,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->makePack('sirsoft', 'ja', LanguagePackStatus::Active->value);
|
||||
$this->registry->invalidate();
|
||||
|
||||
\Illuminate\Support\Facades\DB::table('modules')->insert([
|
||||
DB::table('modules')->insert([
|
||||
'identifier' => 'gnuboard7-hello_module',
|
||||
'name' => 'Hello',
|
||||
'vendor' => 'gnuboard7',
|
||||
@@ -249,7 +253,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->makePack('sirsoft', 'ja', LanguagePackStatus::Active->value);
|
||||
$this->registry->invalidate();
|
||||
|
||||
\Illuminate\Support\Facades\DB::table('modules')->insert([
|
||||
DB::table('modules')->insert([
|
||||
'identifier' => 'gnuboard7-hello_module',
|
||||
'name' => 'Hello',
|
||||
'vendor' => 'gnuboard7',
|
||||
@@ -274,7 +278,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->makePack('sirsoft', 'ja', LanguagePackStatus::Active->value);
|
||||
$this->registry->invalidate();
|
||||
|
||||
\Illuminate\Support\Facades\DB::table('modules')->insert([
|
||||
DB::table('modules')->insert([
|
||||
'identifier' => 'gnuboard7-hello_module',
|
||||
'name' => 'Hello',
|
||||
'vendor' => 'gnuboard7',
|
||||
@@ -411,7 +415,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->assertFileExists($installedDir.'/seed/permissions.json');
|
||||
|
||||
// cleanup — 활성 디렉토리 제거 (RefreshDatabase 와 별개)
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($installedDir);
|
||||
File::deleteDirectory($installedDir);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,7 +449,257 @@ class LanguagePackServiceTest extends TestCase
|
||||
'재설치 시 자기 자신을 슬롯 충돌로 오인하여 active → installed 로 강등되면 안 됨 (회귀)');
|
||||
|
||||
// cleanup
|
||||
\Illuminate\Support\Facades\File::deleteDirectory(base_path('lang-packs/g7-core-ja'));
|
||||
File::deleteDirectory(base_path('lang-packs/g7-core-ja'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 자동 활성화는 `activated` 훅을 정확히 한 번만 발화한다.
|
||||
*
|
||||
* 이전 구현은 설치 트랜잭션에서 status 를 직접 active 로 쓴 뒤 훅을 발화했고,
|
||||
* 활성화 경로(activate)도 같은 훅을 발화해 두 경로가 공존했다. 활성화를 activate()
|
||||
* 한 곳으로 모았으므로 발화도 한 번이어야 한다 — 두 번 발화되면 훅 구독자가
|
||||
* 캐시 재생성·알림 등을 중복 수행한다.
|
||||
*
|
||||
* @scenario vector=finalize_install_activation, actor_permission=cli_system
|
||||
*
|
||||
* @effects activated_hook_fires_exactly_once_on_auto_activate
|
||||
*/
|
||||
public function test_activated_hook_fires_exactly_once_on_auto_activate(): void
|
||||
{
|
||||
$bundledPath = base_path('lang-packs/_bundled/g7-core-ja');
|
||||
if (! is_dir($bundledPath) || ! is_file($bundledPath.'/language-pack.json')) {
|
||||
$this->markTestSkipped('g7-core-ja 번들이 아직 빌드되지 않음 — build-language-pack-ja.cjs 실행 후 재시도');
|
||||
}
|
||||
|
||||
$fired = 0;
|
||||
HookManager::addAction('core.language_packs.activated', function () use (&$fired) {
|
||||
$fired++;
|
||||
});
|
||||
|
||||
try {
|
||||
$pack = $this->service->installFromBundled('g7-core-ja', autoActivate: true);
|
||||
|
||||
$this->assertSame(LanguagePackStatus::Active->value, $pack->status);
|
||||
$this->assertSame(1, $fired, 'activated 훅이 정확히 1회 발화되지 않음');
|
||||
} finally {
|
||||
HookManager::clearAction('core.language_packs.activated');
|
||||
File::deleteDirectory(base_path('lang-packs/g7-core-ja'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 같은 슬롯에 이미 다른 활성 팩이 있으면 자동 활성화를 건너뛴다 (기존 동작 유지).
|
||||
*
|
||||
* 활성화를 activate() 경유로 바꾸면서 슬롯이 점유된 경우 예외가 새로 터지지 않아야 한다 —
|
||||
* 설치 자체는 성공하고 상태만 installed 로 남는 것이 기존 동작이다.
|
||||
*
|
||||
* @scenario vector=finalize_install_activation, actor_permission=cli_system
|
||||
*
|
||||
* @effects auto_activate_skipped_when_slot_occupied
|
||||
*/
|
||||
public function test_auto_activate_skipped_when_slot_occupied(): void
|
||||
{
|
||||
$bundledPath = base_path('lang-packs/_bundled/g7-core-ja');
|
||||
if (! is_dir($bundledPath) || ! is_file($bundledPath.'/language-pack.json')) {
|
||||
$this->markTestSkipped('g7-core-ja 번들이 아직 빌드되지 않음 — build-language-pack-ja.cjs 실행 후 재시도');
|
||||
}
|
||||
|
||||
// 같은 슬롯(core / ja)을 다른 팩이 이미 점유한 상태
|
||||
$this->makePack('other', 'ja', LanguagePackStatus::Active->value);
|
||||
|
||||
try {
|
||||
$pack = $this->service->installFromBundled('g7-core-ja', autoActivate: true);
|
||||
|
||||
$this->assertSame(
|
||||
LanguagePackStatus::Installed->value,
|
||||
$pack->status,
|
||||
'슬롯이 점유되어 있으면 설치는 성공하되 활성화는 건너뛰어야 한다'
|
||||
);
|
||||
} finally {
|
||||
File::deleteDirectory(base_path('lang-packs/g7-core-ja'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 자동 활성화는 트랜잭션의 직접 기록이 아니라 activate() 를 경유하며,
|
||||
* 그 경로에는 의존성 검사가 실제로 걸린다.
|
||||
*
|
||||
* 두 가지를 각각 단언한다.
|
||||
* (1) 경로 — `installed` 훅이 발화하는 시점(트랜잭션 직후)의 DB 상태가 `installed` 여야
|
||||
* 한다. 예전처럼 트랜잭션이 status 를 active 로 직접 썼다면 이 시점에 이미 active 다.
|
||||
* 그 뒤 `activated` 훅이 발화하고 최종 상태가 active 가 되는 순서까지 확인하면
|
||||
* 활성 승격이 activate() 에서 일어났다는 것이 확정된다.
|
||||
* (2) 검사 — activate() 는 저장된 manifest 로 의존성을 검사한다. 코어 로케일이
|
||||
* 활성이 아닌 확장 스코프 팩은 activate() 단계에서 거부되어야 한다.
|
||||
*
|
||||
* @scenario vector=finalize_install_activation, actor_permission=cli_system
|
||||
*
|
||||
* @effects auto_activate_goes_through_activate_and_enforces_dependencies
|
||||
*/
|
||||
public function test_finalize_install_with_auto_activate_goes_through_activate_and_runs_dependency_checks(): void
|
||||
{
|
||||
$identifier = 'actpath-core-ja';
|
||||
$bundledDir = $this->createBundledFixture($identifier, $this->coreJaManifest($identifier, 'actpath', '1.0.0'));
|
||||
|
||||
/** @var list<string> $order 훅 발화 순서 */
|
||||
$order = [];
|
||||
$statusAtInstalledHook = null;
|
||||
|
||||
HookManager::addAction('core.language_packs.installed', function () use (&$order, &$statusAtInstalledHook, $identifier) {
|
||||
$order[] = 'installed';
|
||||
$statusAtInstalledHook = DB::table('language_packs')
|
||||
->where('identifier', $identifier)
|
||||
->value('status');
|
||||
});
|
||||
HookManager::addAction('core.language_packs.activated', function () use (&$order) {
|
||||
$order[] = 'activated';
|
||||
});
|
||||
|
||||
try {
|
||||
$pack = $this->service->installFromBundled($identifier, autoActivate: true);
|
||||
|
||||
// (1) 경로 — 트랜잭션은 installed 로만 기록하고, 활성 승격은 그 뒤 activate() 에서 일어난다.
|
||||
$this->assertSame(
|
||||
LanguagePackStatus::Installed->value,
|
||||
$statusAtInstalledHook,
|
||||
'설치 트랜잭션이 status 를 active 로 직접 기록했다 — activate() 를 경유하지 않는다'
|
||||
);
|
||||
$this->assertSame(['installed', 'activated'], $order, '활성화가 설치 트랜잭션보다 먼저/동시에 일어났다');
|
||||
$this->assertSame(LanguagePackStatus::Active->value, $pack->status);
|
||||
} finally {
|
||||
HookManager::clearAction('core.language_packs.installed');
|
||||
HookManager::clearAction('core.language_packs.activated');
|
||||
File::deleteDirectory($bundledDir);
|
||||
File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
}
|
||||
|
||||
// (2) 검사 — activate() 는 저장된 manifest 의 의존성을 실제로 검사한다.
|
||||
// 코어 로케일이 활성이 아닌 상태에서 모듈 스코프 팩을 활성화하면 거부되어야 한다.
|
||||
// (위에서 설치한 팩이 코어 ja 를 점유하므로 의존성이 미충족인 다른 로케일을 쓴다)
|
||||
$dependent = LanguagePack::query()->create([
|
||||
'identifier' => 'actpath-module-de',
|
||||
'vendor' => 'actpath',
|
||||
'scope' => LanguagePackScope::Module->value,
|
||||
'target_identifier' => 'acme-demo',
|
||||
'locale' => 'de',
|
||||
'locale_name' => 'DE',
|
||||
'locale_native_name' => 'Deutsch',
|
||||
'text_direction' => 'ltr',
|
||||
'version' => '1.0.0',
|
||||
'status' => LanguagePackStatus::Installed->value,
|
||||
'is_protected' => false,
|
||||
'manifest' => [
|
||||
'identifier' => 'actpath-module-de',
|
||||
'scope' => LanguagePackScope::Module->value,
|
||||
'target_identifier' => 'acme-demo',
|
||||
'locale' => 'de',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertFalse(
|
||||
$this->registry->hasActiveCoreLocale('de'),
|
||||
'전제 조건 붕괴 — 코어 de 가 활성이면 의존성 검사가 통과해버려 이 단언이 무의미해진다'
|
||||
);
|
||||
|
||||
$this->expectException(LanguagePackOperationException::class);
|
||||
$this->service->activate($dependent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 팩의 업데이트는 활성 상태를 유지한다 — activate() 경유 전환의 회귀 가드.
|
||||
*
|
||||
* `performUpdate` 는 `$autoActivate = $pack->isActive()` 로 활성 여부를 승계해
|
||||
* 재설치 경로로 넘긴다. 활성화가 트랜잭션 직접 기록에서 activate() 경유로 바뀌면서
|
||||
* 이 경로에 의존성 검사·슬롯 충돌 검사가 새로 끼어들었으므로, 활성 팩의 업데이트가
|
||||
* 조용히 installed 로 떨어지거나 예외로 막히지 않는지 고정한다.
|
||||
*
|
||||
* @scenario vector=finalize_install_activation, actor_permission=cli_system
|
||||
*
|
||||
* @effects update_of_an_active_pack_keeps_it_active
|
||||
*/
|
||||
public function test_perform_update_of_active_pack_keeps_it_active(): void
|
||||
{
|
||||
$identifier = 'updact-core-ja';
|
||||
$bundledDir = $this->createBundledFixture($identifier, $this->coreJaManifest($identifier, 'updact', '1.0.0'));
|
||||
|
||||
try {
|
||||
$pack = $this->service->installFromBundled($identifier, autoActivate: true);
|
||||
$this->assertSame(LanguagePackStatus::Active->value, $pack->status, '전제 조건 — 업데이트 대상은 활성 팩이어야 한다');
|
||||
|
||||
// 번들에 신버전 배치 후 업데이트 (bundled 소스 강제)
|
||||
$this->createBundledFixture($identifier, $this->coreJaManifest($identifier, 'updact', '1.0.1'));
|
||||
|
||||
$updated = $this->service->performUpdate($pack, force: true);
|
||||
|
||||
$this->assertSame('1.0.1', $updated->version);
|
||||
$this->assertSame(
|
||||
LanguagePackStatus::Active->value,
|
||||
$updated->status,
|
||||
'활성 팩을 업데이트했더니 활성 상태를 잃었다 — activate() 경유 전환의 회귀'
|
||||
);
|
||||
} finally {
|
||||
File::deleteDirectory($bundledDir);
|
||||
File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 비활성 팩의 업데이트는 활성으로 승격되지 않는다 (기존 동작 유지).
|
||||
*
|
||||
* @scenario vector=finalize_install_activation, actor_permission=cli_system
|
||||
*
|
||||
* @effects update_of_an_inactive_pack_does_not_promote_it
|
||||
*/
|
||||
public function test_perform_update_of_inactive_pack_does_not_promote_it(): void
|
||||
{
|
||||
$identifier = 'updinact-core-ja';
|
||||
$bundledDir = $this->createBundledFixture($identifier, $this->coreJaManifest($identifier, 'updinact', '1.0.0'));
|
||||
|
||||
try {
|
||||
$pack = $this->service->installFromBundled($identifier, autoActivate: false);
|
||||
$this->assertSame(LanguagePackStatus::Installed->value, $pack->status);
|
||||
|
||||
$this->createBundledFixture($identifier, $this->coreJaManifest($identifier, 'updinact', '1.0.1'));
|
||||
|
||||
$updated = $this->service->performUpdate($pack, force: true);
|
||||
|
||||
$this->assertSame('1.0.1', $updated->version);
|
||||
$this->assertSame(
|
||||
LanguagePackStatus::Installed->value,
|
||||
$updated->status,
|
||||
'비활성 팩이 업데이트만으로 활성 승격되면 안 된다'
|
||||
);
|
||||
} finally {
|
||||
File::deleteDirectory($bundledDir);
|
||||
File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 ja 번들 픽스처용 manifest 를 만듭니다.
|
||||
*
|
||||
* @param string $identifier 번들 식별자
|
||||
* @param string $vendor 벤더
|
||||
* @param string $version 버전
|
||||
* @return array<string, mixed> manifest 데이터
|
||||
*/
|
||||
private function coreJaManifest(string $identifier, string $vendor, string $version): array
|
||||
{
|
||||
return [
|
||||
'identifier' => $identifier,
|
||||
'namespace' => $vendor,
|
||||
'vendor' => $vendor,
|
||||
'name' => ['ko' => $identifier, 'en' => $identifier, 'ja' => $identifier],
|
||||
'description' => ['ko' => '테스트', 'en' => 'Test'],
|
||||
'version' => $version,
|
||||
'scope' => LanguagePackScope::Core->value,
|
||||
'target_identifier' => null,
|
||||
'locale' => 'ja',
|
||||
'locale_name' => 'JA',
|
||||
'locale_native_name' => '日本語',
|
||||
'text_direction' => 'ltr',
|
||||
'g7_version' => '>=7.0.0-beta.4',
|
||||
];
|
||||
}
|
||||
|
||||
public function test_install_blocks_downgrade_without_force(): void
|
||||
@@ -485,11 +739,11 @@ class LanguagePackServiceTest extends TestCase
|
||||
]);
|
||||
|
||||
// force=false → 다운그레이드 차단 예외
|
||||
$this->expectException(\App\Exceptions\LanguagePackOperationException::class);
|
||||
$this->expectException(LanguagePackOperationException::class);
|
||||
$this->service->installFromBundled($identifier);
|
||||
} finally {
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($bundledDir);
|
||||
\Illuminate\Support\Facades\File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
File::deleteDirectory($bundledDir);
|
||||
File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,8 +787,8 @@ class LanguagePackServiceTest extends TestCase
|
||||
$pack = $this->service->installFromBundled($identifier, force: true);
|
||||
$this->assertSame('1.0.0-beta.1', $pack->version);
|
||||
} finally {
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($bundledDir);
|
||||
\Illuminate\Support\Facades\File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
File::deleteDirectory($bundledDir);
|
||||
File::deleteDirectory(base_path('lang-packs/'.$identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,8 +802,8 @@ class LanguagePackServiceTest extends TestCase
|
||||
private function createBundledFixture(string $identifier, array $manifest): string
|
||||
{
|
||||
$path = base_path('lang-packs/_bundled/'.$identifier);
|
||||
\Illuminate\Support\Facades\File::ensureDirectoryExists($path);
|
||||
\Illuminate\Support\Facades\File::put(
|
||||
File::ensureDirectoryExists($path);
|
||||
File::put(
|
||||
$path.DIRECTORY_SEPARATOR.'language-pack.json',
|
||||
json_encode($manifest, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
|
||||
);
|
||||
@@ -584,7 +838,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->assertFalse($match->exists, '가상 레코드는 exists=false 여야 함');
|
||||
$this->assertNull($match->id, '가상 레코드는 id 가 null 이어야 함');
|
||||
} finally {
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($path);
|
||||
File::deleteDirectory($path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,7 +878,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$match = $packs->firstWhere('identifier', $identifier);
|
||||
$this->assertNull($match, '동일 슬롯에 DB 레코드가 있으면 가상 레코드가 반환되지 않아야 함');
|
||||
} finally {
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($path);
|
||||
File::deleteDirectory($path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +914,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->assertNotNull($virtual);
|
||||
$this->assertSame(LanguagePackStatus::Uninstalled->value, $virtual->status);
|
||||
} finally {
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($path);
|
||||
File::deleteDirectory($path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +943,7 @@ class LanguagePackServiceTest extends TestCase
|
||||
$this->assertNotNull($items->firstWhere('identifier', $identifier));
|
||||
$this->assertNull($items->firstWhere('status', LanguagePackStatus::Active->value));
|
||||
} finally {
|
||||
\Illuminate\Support\Facades\File::deleteDirectory($path);
|
||||
File::deleteDirectory($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user