Skip to content

Commit ca091a1

Browse files
committed
Fixed path traversal.
Signed-off-by: Joshua Parker <joshua@joshuaparker.dev>
1 parent ca5fd66 commit ca091a1

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

Helpers/core.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
use Qubus\Expressive\OrmBuilder;
1515
use ReflectionException;
1616

17+
use function dirname;
18+
use function getcwd;
1719
use function is_int;
1820
use function Qubus\Security\Helpers\__observer;
1921
use function Qubus\Support\Helpers\is_false__;
2022
use function Qubus\Support\Helpers\is_null__;
2123
use function file_exists;
2224
use function in_array;
2325
use function is_string;
26+
use function realpath;
2427
use function rtrim;
2528
use function sprintf;
2629
use function substr_count;
@@ -68,20 +71,12 @@ function config(string $key, array|bool $set = false): mixed
6871
*/
6972
function get_fresh_bootstrap(): mixed
7073
{
71-
if (file_exists(filename: $file = __DIR__ . '/../../../../../bootstrap/app.php')) {
72-
return require($file);
73-
} elseif (file_exists(filename: $file = __DIR__ . '/../../../../bootstrap/app.php')) {
74-
return require($file);
75-
} elseif (file_exists(filename: $file = __DIR__ . '/../../bootstrap/app.php')) {
76-
return require($file);
77-
} elseif (
78-
file_exists(
79-
filename: $file = rtrim(string: (string) env(key: 'APP_BASE_PATH'), characters: '/') . '/bootstrap/app.php'
80-
)
81-
) {
82-
return require($file);
74+
if(file_exists(filename: $file = getcwd() . '/bootstrap/app.php')) {
75+
return require(realpath(path: $file));
76+
} elseif(file_exists(filename: $file = dirname(path: getcwd()) . '/bootstrap/app.php')) {
77+
return require(realpath(path: $file));
8378
} else {
84-
return require(__DIR__ . '/../bootstrap/app.php');
79+
return require(realpath(path: dirname(path: getcwd()) . '/bootstrap/app.php'));
8580
}
8681
}
8782

0 commit comments

Comments
 (0)