Skip to content

Commit 4129da0

Browse files
apreimlrap2hpoutre
authored andcommitted
fix pathToLogFile to only get files in log dir (#90)
Proper check the file parameter to disallow arbitrary file downloads
1 parent 8da15ca commit 4129da0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,14 @@ public static function setFile($file)
7878
*/
7979
public static function pathToLogFile($file)
8080
{
81-
$logsPath = storage_path('logs');
81+
if (!starts_with('/', $file)) {
82+
$logsPath = storage_path('logs');
8283

83-
if (app('files')->exists($file)) { // try the absolute path
84-
return $file;
84+
$file = $logsPath . '/' . $file;
8585
}
8686

87-
$file = $logsPath . '/' . $file;
88-
8987
// check if requested file is really in the logs directory
90-
if (dirname($file) !== $logsPath) {
88+
if (dirname(realpath($file)) !== $logsPath) {
9189
throw new \Exception('No such log file');
9290
}
9391

0 commit comments

Comments
 (0)