Skip to content

Commit 4fe8745

Browse files
nobuhikoclaude
andcommitted
Fix: CodeRabbitレビュー指摘事項を修正(3回目)
- docblockの「トークン解析」を「正規表現でパース」に修正 - setUp()にDATA_REALDIRの定数チェックを追加 - tearDown()にtmpDir null guardを追加(markTestSkipped時の安全性) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aa081ea commit 4fe8745

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

data/class/batch/SC_Batch_Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function makeDistInfo($bkupDistInfoArray)
263263
/**
264264
* distinfo.php を安全にパースして $distinfo 配列を返す.
265265
*
266-
* include を使わず、ファイル内容をトークン解析することで
266+
* include を使わず、ファイル内容を正規表現でパースすることで
267267
* 任意コード実行を防止する.
268268
*
269269
* @param string $path distinfo.php のパス

tests/class/batch/SC_Batch_Update_parseDistInfoTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class SC_Batch_Update_parseDistInfoTest extends PHPUnit_Framework_TestCase
1313

1414
protected function setUp(): void
1515
{
16-
if (!defined('MODULE_REALDIR') || !defined('HTML_REALDIR')) {
16+
if (!defined('MODULE_REALDIR') || !defined('HTML_REALDIR') || !defined('DATA_REALDIR')) {
1717
$this->markTestSkipped('EC-CUBE constants are not defined.');
1818
}
1919
$this->batch = new SC_Batch_Update();
@@ -27,9 +27,11 @@ protected function setUp(): void
2727

2828
protected function tearDown(): void
2929
{
30-
// テンポラリファイルを削除
31-
array_map('unlink', glob($this->tmpDir.'/*'));
32-
rmdir($this->tmpDir);
30+
// テンポラリファイルを削除 (setUp がスキップした場合は tmpDir が null のため guard が必要)
31+
if ($this->tmpDir !== null && is_dir($this->tmpDir)) {
32+
array_map('unlink', glob($this->tmpDir.'/*') ?: []);
33+
rmdir($this->tmpDir);
34+
}
3335
if (file_exists('/tmp/pwned.txt')) {
3436
unlink('/tmp/pwned.txt');
3537
}

0 commit comments

Comments
 (0)