|
| 1 | +<?php |
| 2 | + |
| 3 | +return [ |
| 4 | + /* |
| 5 | + |-------------------------------------------------------------------------- |
| 6 | + | File Upload Configuration |
| 7 | + |-------------------------------------------------------------------------- |
| 8 | + | |
| 9 | + | This file contains configuration options for file uploads including |
| 10 | + | allowed file extensions and MIME types for security validation. |
| 11 | + | |
| 12 | + */ |
| 13 | + |
| 14 | + /* |
| 15 | + |-------------------------------------------------------------------------- |
| 16 | + | Allowed File Extensions |
| 17 | + |-------------------------------------------------------------------------- |
| 18 | + | |
| 19 | + | List of file extensions that are allowed to be uploaded. |
| 20 | + | Only files with these extensions will be accepted. |
| 21 | + | Archive formats (.zip, .rar, .tar, .7z) are explicitly NOT allowed for security. |
| 22 | + | |
| 23 | + */ |
| 24 | + 'allowed_extensions' => [ |
| 25 | + // Documents |
| 26 | + 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', |
| 27 | + 'txt', 'csv', |
| 28 | + |
| 29 | + // Images |
| 30 | + 'jpg', 'jpeg', 'png', 'gif', 'svg', |
| 31 | + |
| 32 | + // Audio |
| 33 | + 'mp3', |
| 34 | + |
| 35 | + // Video |
| 36 | + 'mp4', |
| 37 | + ], |
| 38 | + /* |
| 39 | + |-------------------------------------------------------------------------- |
| 40 | + | Extension to MIME Type Mapping |
| 41 | + |-------------------------------------------------------------------------- |
| 42 | + | |
| 43 | + | An associative array that maps each allowed file extension to one or more |
| 44 | + | corresponding MIME types. This provides a strong validation to ensure that |
| 45 | + | a file's content type (MIME type) matches its declared extension, |
| 46 | + | preventing malicious files (like a script disguised as an image) from being uploaded. |
| 47 | + | |
| 48 | + */ |
| 49 | + 'extension_mime_map' => [ |
| 50 | + // Documents |
| 51 | + 'pdf' => ['application/pdf'], |
| 52 | + 'doc' => ['application/msword'], |
| 53 | + 'docx' => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'], |
| 54 | + 'xls' => ['application/vnd.ms-excel'], |
| 55 | + 'xlsx' => ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], |
| 56 | + 'ppt' => ['application/vnd.ms-powerpoint'], |
| 57 | + 'pptx' => ['application/vnd.openxmlformats-officedocument.presentationml.presentation'], |
| 58 | + 'txt' => ['text/plain'], |
| 59 | + 'csv' => ['text/csv', 'application/csv'], |
| 60 | + |
| 61 | + // Audio |
| 62 | + 'jpg' => ['image/jpeg'], |
| 63 | + 'jpeg' => ['image/jpeg'], |
| 64 | + 'png' => ['image/png'], |
| 65 | + 'gif' => ['image/gif'], |
| 66 | + 'svg' => ['image/svg+xml'], |
| 67 | + |
| 68 | + // Audio |
| 69 | + 'mp3' => ['audio/mpeg'], |
| 70 | + |
| 71 | + // Video |
| 72 | + 'mp4' => ['video/mp4'], |
| 73 | + ], |
| 74 | + |
| 75 | + /* |
| 76 | + |-------------------------------------------------------------------------- |
| 77 | + | Enable MIME Type Validation |
| 78 | + |-------------------------------------------------------------------------- |
| 79 | + | |
| 80 | + | Whether to enable MIME type validation against allowed_mime_types list |
| 81 | + | AND validate that MIME type corresponds to file extension using extension_mime_map. |
| 82 | + | This provides comprehensive validation to prevent malicious files. |
| 83 | + | Recommended to keep this enabled for security. |
| 84 | + | |
| 85 | + */ |
| 86 | + 'enable_mime_validation' => env('ENABLE_MIME_VALIDATION', true), |
| 87 | + |
| 88 | + /* |
| 89 | + |-------------------------------------------------------------------------- |
| 90 | + | Enable Extension Validation |
| 91 | + |-------------------------------------------------------------------------- |
| 92 | + | |
| 93 | + | Whether to enable basic file extension validation against allowed_extensions list. |
| 94 | + | This validates that the file extension is in the allowed list. |
| 95 | + | Recommended to keep this enabled for security. |
| 96 | + | |
| 97 | + */ |
| 98 | + 'enable_extension_validation' => env('ENABLE_EXTENSION_VALIDATION', true), |
| 99 | + |
| 100 | + /* |
| 101 | + |-------------------------------------------------------------------------- |
| 102 | + | Security Dangerous File Extensions |
| 103 | + |-------------------------------------------------------------------------- |
| 104 | + | |
| 105 | + | Archive formats (.zip, .rar, .tar, .7z, .gz, etc.) are explicitly |
| 106 | + | NOT allowed for security reasons. These file types can contain |
| 107 | + | malicious content and are blocked by default. |
| 108 | + | |
| 109 | + */ |
| 110 | + 'dangerous_extensions' => [ |
| 111 | + 'zip', 'rar', '7z', 'tar', 'gz', 'bz2', 'xz', 'lzma', |
| 112 | + 'cab', 'ar', 'iso', 'dmg', 'pkg', 'deb', 'rpm', |
| 113 | + ], |
| 114 | + |
| 115 | + /* |
| 116 | + |-------------------------------------------------------------------------- |
| 117 | + | Security Dangerous MIME Types |
| 118 | + |-------------------------------------------------------------------------- |
| 119 | + | |
| 120 | + | A list of MIME types associated with archives and executables. |
| 121 | + | This provides an additional layer of security to prevent the upload of |
| 122 | + | compressed files or other potentially dangerous content, even if their |
| 123 | + | file extension has been tampered with. |
| 124 | + | |
| 125 | + */ |
| 126 | + 'dangerous_mime_types' => [ |
| 127 | + 'application/zip', |
| 128 | + 'application/x-rar-compressed', |
| 129 | + 'application/x-7z-compressed', |
| 130 | + 'application/x-tar', |
| 131 | + 'application/gzip', |
| 132 | + 'application/x-bzip2', |
| 133 | + 'application/x-xz', |
| 134 | + 'application/x-lzma', |
| 135 | + 'application/vnd.ms-cab-compressed', |
| 136 | + 'application/x-iso9660-image', |
| 137 | + ], |
| 138 | +]; |
0 commit comments