fix(vikon): switch validateFileTypes from blacklist to whitelist
Based on actual file analysis of sveden/abitur/vsoko modules: - html, css, js, map (content + assets) - png, jpg, gif, svg, ico, bmp (images) - ttf, woff, woff2, eot (fonts) - pdf, doc, docx (documents) - vikon (module-specific) No PHP/ASP/executables in allowed list — any non-whitelisted file is blocked.
This commit is contained in:
@@ -66,17 +66,22 @@ class FilesystemTask
|
|||||||
|
|
||||||
public function validateFileTypes(string $directory): array
|
public function validateFileTypes(string $directory): array
|
||||||
{
|
{
|
||||||
$blocked = [
|
$allowed = [
|
||||||
'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phps',
|
'html', 'htm',
|
||||||
'asp', 'aspx', 'jsp', 'jspx', 'cfm',
|
'css', 'js', 'map',
|
||||||
'pl', 'py', 'rb', 'cgi', 'sh', 'bash', 'bat', 'cmd', 'exe',
|
'json', 'xml', 'txt',
|
||||||
'ps1', 'htaccess', 'htpasswd',
|
'png', 'jpg', 'jpeg', 'gif', 'svg', 'svgz', 'webp', 'ico', 'bmp',
|
||||||
|
'ttf', 'woff', 'woff2', 'eot', 'otf',
|
||||||
|
'pdf', 'doc', 'docx', 'xls', 'xlsx',
|
||||||
|
'zip',
|
||||||
|
'vikon',
|
||||||
];
|
];
|
||||||
|
|
||||||
$found = [];
|
$found = [];
|
||||||
|
|
||||||
foreach (File::allFiles($directory) as $file) {
|
foreach (File::allFiles($directory) as $file) {
|
||||||
$ext = strtolower($file->getExtension());
|
$ext = strtolower($file->getExtension());
|
||||||
if (in_array($ext, $blocked, true)) {
|
if (!in_array($ext, $allowed, true)) {
|
||||||
$found[] = str_replace(base_path() . '/', '', $file->getPathname());
|
$found[] = str_replace(base_path() . '/', '', $file->getPathname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user