m3 Security Fixes

This commit is contained in:
Mark Gregory
2026-09-17 10:24:14 +01:00
parent 74f2387dfe
commit c9856d58c1
20 changed files with 234 additions and 201 deletions
+5 -3
View File
@@ -10,9 +10,11 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
class SpreadsheetExport
{
private const EXPORT_DIRECTORY = 'app/m3-exports/';
public function download(Collection $rows, string $filename): BinaryFileResponse
{
$path = storage_path('app/m3-exports/' . uniqid('', true) . '-' . basename($filename));
$path = storage_path(self::EXPORT_DIRECTORY . uniqid('', true) . '-' . basename($filename));
$this->write($rows, $path);
return response()->download($path, basename($filename))->deleteFileAfterSend(true);
@@ -20,7 +22,7 @@ class SpreadsheetExport
public function store(Collection $rows, string $filename, ?string $disk = null): string
{
$tmp = storage_path('app/m3-exports/' . uniqid('', true) . '-' . basename($filename));
$tmp = storage_path(self::EXPORT_DIRECTORY . uniqid('', true) . '-' . basename($filename));
$this->write($rows, $tmp);
if ($disk && config("filesystems.disks.$disk")) {
@@ -45,7 +47,7 @@ class SpreadsheetExport
$sheet->fromArray($array->map(fn ($row) => array_values($row))->all(), null, 'A1');
}
}
$tmp = storage_path('app/m3-exports/' . uniqid('', true) . '-' . basename($filename));
$tmp = storage_path(self::EXPORT_DIRECTORY . uniqid('', true) . '-' . basename($filename));
if (! is_dir(dirname($tmp))) {
mkdir(dirname($tmp), 0775, true);
}