NOW MANAGED ON CODEBERG
Moved sketchy file samples to base64 equivilents
Dan Brownf25e58500817
diff --git a/tests/Uploads/ImageTest.php b/tests/Uploads/ImageTest.phpindex 1c736d672..9b0e004b1 100644--- a/tests/Uploads/ImageTest.php+++ b/tests/Uploads/ImageTest.php@@ -136,7 +136,7 @@ class ImageTest extends TestCase$relPath = $this->getTestImagePath('gallery', $fileName);$this->deleteImage($relPath);- $file = $this->getTestImage($fileName);+ $file = $this->newTestImageFromBase64('bad-php.base64', $fileName);$upload = $this->withHeader('Content-Type', 'image/jpeg')->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $file], []);$upload->assertStatus(302);@@ -158,7 +158,7 @@ class ImageTest extends TestCase$relPath = $this->getTestImagePath('gallery', $fileName);$this->deleteImage($relPath);- $file = $this->getTestImage($fileName);+ $file = $this->newTestImageFromBase64('bad-phtml.base64', $fileName);$upload = $this->withHeader('Content-Type', 'image/jpeg')->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $file], []);$upload->assertStatus(302);@@ -175,7 +175,7 @@ class ImageTest extends TestCase$relPath = $this->getTestImagePath('gallery', $fileName);$this->deleteImage($relPath);- $file = $this->getTestImage($fileName);+ $file = $this->newTestImageFromBase64('bad-phtml-png.base64', $fileName);$upload = $this->withHeader('Content-Type', 'image/png')->call('POST', '/images/gallery', ['uploaded_to' => $page->id], [], ['file' => $file], []);$upload->assertStatus(302);diff --git a/tests/Uploads/UsesImages.php b/tests/Uploads/UsesImages.phpindex 64f26dea8..a2026d968 100644--- a/tests/Uploads/UsesImages.php+++ b/tests/Uploads/UsesImages.php@@ -6,10 +6,9 @@ use Illuminate\Http\UploadedFile;trait UsesImages{/**- * Get the path to our basic test image.- * @return string+ * Get the path to a file in the test-data-directory.*/- protected function getTestImageFilePath(?string $fileName = null)+ protected function getTestImageFilePath(?string $fileName = null): string{if (is_null($fileName)) {$fileName = 'test-image.png';@@ -18,14 +17,27 @@ trait UsesImagesreturn base_path('tests/test-data/' . $fileName);}+ /**+ * Creates a new temporary image file using the given name,+ * with the content decoded from the given bas64 file name.+ * Is generally used for testing sketchy files that could trip AV.+ */+ protected function newTestImageFromBase64(string $base64FileName, $imageFileName): UploadedFile+ {+ $imagePath = implode(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), $imageFileName]);+ $base64FilePath = $this->getTestImageFilePath($base64FileName);+ $data = file_get_contents($base64FilePath);+ $decoded = base64_decode($data);+ file_put_contents($imagePath, $decoded);+ return new UploadedFile($imagePath, $imageFileName, 'image/png', null, true);+ }+/*** Get a test image that can be uploaded- * @param $fileName- * @return UploadedFile*/- protected function getTestImage($fileName, ?string $testDataFileName = null)+ protected function getTestImage(string $fileName, ?string $testDataFileName = null): UploadedFile{- return new UploadedFile($this->getTestImageFilePath($testDataFileName), $fileName, 'image/png', 5238, null, true);+ return new UploadedFile($this->getTestImageFilePath($testDataFileName), $fileName, 'image/png', null, true);}/**diff --git a/tests/test-data/bad-php.base64 b/tests/test-data/bad-php.base64new file mode 100644index 000000000..550ce17e8--- /dev/null+++ b/tests/test-data/bad-php.base64@@ -0,0 +1,10 @@+/9j/4AAQSkZJRgABAQEBLAEsAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAEBAQEBAQEBAQEB+AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBD+AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB+AQEBAQEBAQH/wgARCAABAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACv/EABQBAQAA+AAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAT/n/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgB+AQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPwF//8QAFBEBAAAAAAAAAAAAAAAA+AAAAAP/aAAgBAgEBPwF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAA+AAAAAAAAAAAAAAAAAP/aAAgBAQABPyF//9oADAMBAAIAAwAAABAf/8QAFBEBAAAAAAAAAAAAAAAA+AAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAFBABAAAA+AAAAAAAAAAAAAAAAAP/aAAgBAQABPxB//9k8P3BocCBlY2hvICdiYWRwaHAnOwo=diff --git a/tests/test-data/bad-phtml-png.base64 b/tests/test-data/bad-phtml-png.base64new file mode 100644index 000000000..7fd9d8f64--- /dev/null+++ b/tests/test-data/bad-phtml-png.base64@@ -0,0 +1,3 @@+iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA+B3RJTUUH4gEcDCo5iYNs+gAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUH+AAAAFElEQVQI12O0jN/KgASYGFABqXwAZtoBV6Sl3hIAAAAASUVORK5CYII=diff --git a/tests/test-data/bad-phtml.base64 b/tests/test-data/bad-phtml.base64new file mode 100644index 000000000..550ce17e8--- /dev/null+++ b/tests/test-data/bad-phtml.base64@@ -0,0 +1,10 @@+/9j/4AAQSkZJRgABAQEBLAEsAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAEBAQEBAQEBAQEB+AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBD+AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB+AQEBAQEBAQH/wgARCAABAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACv/EABQBAQAA+AAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAT/n/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgB+AQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPwF//8QAFBEBAAAAAAAAAAAAAAAA+AAAAAP/aAAgBAgEBPwF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAA+AAAAAAAAAAAAAAAAAP/aAAgBAQABPyF//9oADAMBAAIAAwAAABAf/8QAFBEBAAAAAAAAAAAAAAAA+AAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAFBABAAAA+AAAAAAAAAAAAAAAAAP/aAAgBAQABPxB//9k8P3BocCBlY2hvICdiYWRwaHAnOwo=diff --git a/tests/test-data/bad.php b/tests/test-data/bad.phpdeleted file mode 100644index 3b7c0f36c..000000000Binary files a/tests/test-data/bad.php and /dev/null differdiff --git a/tests/test-data/bad.phtml b/tests/test-data/bad.phtmldeleted file mode 100644index 3b7c0f36c..000000000Binary files a/tests/test-data/bad.phtml and /dev/null differdiff --git a/tests/test-data/bad.phtml.png b/tests/test-data/bad.phtml.pngdeleted file mode 100644index dd15f6e83..000000000Binary files a/tests/test-data/bad.phtml.png and /dev/null differ