1
0
Fork 0
mirror of synced 2024-05-23 14:09:49 +12:00

Added a new file extension validator

This commit is contained in:
Eldad Fux 2021-01-27 15:15:44 +02:00
parent 8fddd33f4b
commit 5e8c7eb3d3
3 changed files with 87 additions and 88 deletions

View file

@ -6,8 +6,8 @@ use Appwrite\Database\Validator\Authorization;
use Appwrite\Database\Validator\UID;
use Utopia\Storage\Storage;
use Utopia\Storage\Validator\File;
use Utopia\Storage\Validator\FileExt;
use Utopia\Storage\Validator\FileSize;
use Utopia\Storage\Validator\FileType;
use Utopia\Storage\Validator\Upload;
use Appwrite\Utopia\Response;
use Appwrite\Task\Validator\Cron;
@ -426,7 +426,7 @@ App::post('/v1/functions/:functionId/tags')
$file = $request->getFiles('code');
$device = Storage::getDevice('functions');
$fileType = new FileType([FileType::FILE_TYPE_GZIP]);
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
$fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0));
$upload = new Upload();
@ -439,8 +439,7 @@ App::post('/v1/functions/:functionId/tags')
$file['tmp_name'] = (\is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name'];
$file['size'] = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
// Check if file type is allowed (feature for project settings?)
if (!$fileType->isValid($file['tmp_name'])) {
if (!$$fileExt->isValid($file['tmp_name'])) { // Check if file type is allowed
throw new Exception('File type not allowed', 400);
}

View file

@ -45,7 +45,7 @@
"utopia-php/preloader": "0.2.*",
"utopia-php/domains": "0.2.*",
"utopia-php/swoole": "0.2.*",
"utopia-php/storage": "0.1.*",
"utopia-php/storage": "0.2.*",
"resque/php-resque": "1.3.6",
"matomo/device-detector": "3.13.0",

166
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3c94b5ea6b60232905b6831bec020b69",
"content-hash": "f83cd9bbcc8c8361622aba6313f81e28",
"packages": [
{
"name": "adhocore/jwt",
@ -1697,16 +1697,16 @@
},
{
"name": "utopia-php/storage",
"version": "0.1.0",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/storage.git",
"reference": "00e9045cee6bd1ec1d1f27329c329494ef420c19"
"reference": "27bfd663c9b2a17ac0911522a87f42bee834df95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/00e9045cee6bd1ec1d1f27329c329494ef420c19",
"reference": "00e9045cee6bd1ec1d1f27329c329494ef420c19",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/27bfd663c9b2a17ac0911522a87f42bee834df95",
"reference": "27bfd663c9b2a17ac0911522a87f42bee834df95",
"shasum": ""
},
"require": {
@ -1743,9 +1743,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/storage/issues",
"source": "https://github.com/utopia-php/storage/tree/0.1.0"
"source": "https://github.com/utopia-php/storage/tree/0.2.0"
},
"time": "2021-01-22T07:27:20+00:00"
"time": "2021-01-27T12:21:27+00:00"
},
{
"name": "utopia-php/swoole",
@ -3211,12 +3211,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "d66b11be20460c55f9655b50d06c0070d6de0ab8"
"reference": "42c07f0e3553df5bf56a079957a52e9353625058"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/d66b11be20460c55f9655b50d06c0070d6de0ab8",
"reference": "d66b11be20460c55f9655b50d06c0070d6de0ab8",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/42c07f0e3553df5bf56a079957a52e9353625058",
"reference": "42c07f0e3553df5bf56a079957a52e9353625058",
"shasum": ""
},
"require": {
@ -3264,7 +3264,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:26+00:00"
"time": "2021-01-27T12:51:34+00:00"
},
{
"name": "phpunit/php-invoker",
@ -3272,12 +3272,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-invoker.git",
"reference": "24d9117c920e229e4dd4e65ed966951dc8d6c0ee"
"reference": "3a913dc74b32a7646a5fb3cfb72f6ace01fabd01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/24d9117c920e229e4dd4e65ed966951dc8d6c0ee",
"reference": "24d9117c920e229e4dd4e65ed966951dc8d6c0ee",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/3a913dc74b32a7646a5fb3cfb72f6ace01fabd01",
"reference": "3a913dc74b32a7646a5fb3cfb72f6ace01fabd01",
"shasum": ""
},
"require": {
@ -3328,7 +3328,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:34+00:00"
"time": "2021-01-27T12:51:43+00:00"
},
{
"name": "phpunit/php-text-template",
@ -3336,12 +3336,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "3ace7e098d9ae64fdf2ee12e69ec1ed3eb16d6ec"
"reference": "f2e1a43551a53861fd0d000518f8db3818b82655"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3ace7e098d9ae64fdf2ee12e69ec1ed3eb16d6ec",
"reference": "3ace7e098d9ae64fdf2ee12e69ec1ed3eb16d6ec",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/f2e1a43551a53861fd0d000518f8db3818b82655",
"reference": "f2e1a43551a53861fd0d000518f8db3818b82655",
"shasum": ""
},
"require": {
@ -3388,7 +3388,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:15:08+00:00"
"time": "2021-01-27T12:52:18+00:00"
},
{
"name": "phpunit/php-timer",
@ -3396,12 +3396,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "7fe4501c193086a375125ff31e7b8bb6122f00bd"
"reference": "ca89d7aa771d3c7a095ec2bac5b70489a6d15638"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/7fe4501c193086a375125ff31e7b8bb6122f00bd",
"reference": "7fe4501c193086a375125ff31e7b8bb6122f00bd",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/ca89d7aa771d3c7a095ec2bac5b70489a6d15638",
"reference": "ca89d7aa771d3c7a095ec2bac5b70489a6d15638",
"shasum": ""
},
"require": {
@ -3448,7 +3448,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:43+00:00"
"time": "2021-01-27T12:51:51+00:00"
},
{
"name": "phpunit/phpunit",
@ -3613,12 +3613,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/cli-parser.git",
"reference": "72cbe9a5d3ac979d81dbe177c8bd6d103699c502"
"reference": "66398c0b5074897805514249878d592f9ada37c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/72cbe9a5d3ac979d81dbe177c8bd6d103699c502",
"reference": "72cbe9a5d3ac979d81dbe177c8bd6d103699c502",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/66398c0b5074897805514249878d592f9ada37c5",
"reference": "66398c0b5074897805514249878d592f9ada37c5",
"shasum": ""
},
"require": {
@ -3662,7 +3662,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:15:35+00:00"
"time": "2021-01-27T12:52:48+00:00"
},
{
"name": "sebastian/code-unit",
@ -3726,12 +3726,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "e49b92c16b780c4d526c118d49d904c4626b8c63"
"reference": "8be6fadd1eb9f4bcee0e823a0f392d641e00e3d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/e49b92c16b780c4d526c118d49d904c4626b8c63",
"reference": "e49b92c16b780c4d526c118d49d904c4626b8c63",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/8be6fadd1eb9f4bcee0e823a0f392d641e00e3d9",
"reference": "8be6fadd1eb9f4bcee0e823a0f392d641e00e3d9",
"shasum": ""
},
"require": {
@ -3774,7 +3774,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:13:19+00:00"
"time": "2021-01-27T12:50:24+00:00"
},
{
"name": "sebastian/comparator",
@ -3782,12 +3782,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "33c94310f57ca21d5ea6018c4e799be699e85650"
"reference": "66776aea976481264dbaeef1b80c72845711473c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/33c94310f57ca21d5ea6018c4e799be699e85650",
"reference": "33c94310f57ca21d5ea6018c4e799be699e85650",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/66776aea976481264dbaeef1b80c72845711473c",
"reference": "66776aea976481264dbaeef1b80c72845711473c",
"shasum": ""
},
"require": {
@ -3849,7 +3849,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:13:27+00:00"
"time": "2021-01-27T12:55:14+00:00"
},
{
"name": "sebastian/complexity",
@ -3857,12 +3857,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/complexity.git",
"reference": "b251b4b76965b9a24a847ac5641ed7419723e7e3"
"reference": "653277be0c4044b0a32ee3e799b3b0c6945aa7f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/b251b4b76965b9a24a847ac5641ed7419723e7e3",
"reference": "b251b4b76965b9a24a847ac5641ed7419723e7e3",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/653277be0c4044b0a32ee3e799b3b0c6945aa7f8",
"reference": "653277be0c4044b0a32ee3e799b3b0c6945aa7f8",
"shasum": ""
},
"require": {
@ -3907,7 +3907,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:15:17+00:00"
"time": "2021-01-27T12:52:27+00:00"
},
{
"name": "sebastian/diff",
@ -3915,12 +3915,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "1c3726f5fc6ecdf41a7d7a992c18db936d79345e"
"reference": "9d7fb8ba123928945b9727a3e02501645955f61f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1c3726f5fc6ecdf41a7d7a992c18db936d79345e",
"reference": "1c3726f5fc6ecdf41a7d7a992c18db936d79345e",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/9d7fb8ba123928945b9727a3e02501645955f61f",
"reference": "9d7fb8ba123928945b9727a3e02501645955f61f",
"shasum": ""
},
"require": {
@ -3974,7 +3974,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:13:35+00:00"
"time": "2021-01-27T12:50:42+00:00"
},
{
"name": "sebastian/environment",
@ -3982,12 +3982,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "71408304f2a06879d9306d6126ff19c26b77ab8f"
"reference": "27e27e02ab122412b7ff9c847445e21ecfcc5c68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/71408304f2a06879d9306d6126ff19c26b77ab8f",
"reference": "71408304f2a06879d9306d6126ff19c26b77ab8f",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/27e27e02ab122412b7ff9c847445e21ecfcc5c68",
"reference": "27e27e02ab122412b7ff9c847445e21ecfcc5c68",
"shasum": ""
},
"require": {
@ -4038,7 +4038,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:13:44+00:00"
"time": "2021-01-27T12:50:50+00:00"
},
{
"name": "sebastian/exporter",
@ -4046,12 +4046,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "9fdb8e271acb70c94fc378d0cd32de380e1a6f9d"
"reference": "4b97f87ebe0e759d27a96e5cfcb15193fdcc1000"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/9fdb8e271acb70c94fc378d0cd32de380e1a6f9d",
"reference": "9fdb8e271acb70c94fc378d0cd32de380e1a6f9d",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/4b97f87ebe0e759d27a96e5cfcb15193fdcc1000",
"reference": "4b97f87ebe0e759d27a96e5cfcb15193fdcc1000",
"shasum": ""
},
"require": {
@ -4116,7 +4116,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:13:52+00:00"
"time": "2021-01-27T12:50:59+00:00"
},
{
"name": "sebastian/global-state",
@ -4124,12 +4124,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "483fae6c9f89aee344c35547df17b130827a0981"
"reference": "ae53ac14d8df978ebc06a0382997257a2268dc2c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/483fae6c9f89aee344c35547df17b130827a0981",
"reference": "483fae6c9f89aee344c35547df17b130827a0981",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/ae53ac14d8df978ebc06a0382997257a2268dc2c",
"reference": "ae53ac14d8df978ebc06a0382997257a2268dc2c",
"shasum": ""
},
"require": {
@ -4181,7 +4181,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:00+00:00"
"time": "2021-01-27T12:51:08+00:00"
},
{
"name": "sebastian/lines-of-code",
@ -4189,12 +4189,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/lines-of-code.git",
"reference": "815e6e5f9021de94a4f896835e9a7b0fd9557e2d"
"reference": "3b537e8cf7d5d40c5937cb238dd86e9849058978"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/815e6e5f9021de94a4f896835e9a7b0fd9557e2d",
"reference": "815e6e5f9021de94a4f896835e9a7b0fd9557e2d",
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/3b537e8cf7d5d40c5937cb238dd86e9849058978",
"reference": "3b537e8cf7d5d40c5937cb238dd86e9849058978",
"shasum": ""
},
"require": {
@ -4239,7 +4239,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:15:26+00:00"
"time": "2021-01-27T12:52:38+00:00"
},
{
"name": "sebastian/object-enumerator",
@ -4247,12 +4247,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "5f8c843a728ed5433bbd6f4426923f9d750be40b"
"reference": "f8f7c1ff5e66b5c9145df7329b3bc54844138e21"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5f8c843a728ed5433bbd6f4426923f9d750be40b",
"reference": "5f8c843a728ed5433bbd6f4426923f9d750be40b",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f8f7c1ff5e66b5c9145df7329b3bc54844138e21",
"reference": "f8f7c1ff5e66b5c9145df7329b3bc54844138e21",
"shasum": ""
},
"require": {
@ -4297,7 +4297,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:09+00:00"
"time": "2021-01-27T12:51:16+00:00"
},
{
"name": "sebastian/object-reflector",
@ -4305,12 +4305,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-reflector.git",
"reference": "d41ef59df68d6f470c8084fae471b56fd2812bb2"
"reference": "dbea5f76fb03ccf212b0fc88fb8f2ad256f4f000"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/d41ef59df68d6f470c8084fae471b56fd2812bb2",
"reference": "d41ef59df68d6f470c8084fae471b56fd2812bb2",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/dbea5f76fb03ccf212b0fc88fb8f2ad256f4f000",
"reference": "dbea5f76fb03ccf212b0fc88fb8f2ad256f4f000",
"shasum": ""
},
"require": {
@ -4353,7 +4353,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:18+00:00"
"time": "2021-01-27T12:51:25+00:00"
},
{
"name": "sebastian/recursion-context",
@ -4361,12 +4361,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "f78f35f8c348f59a47e7973ec0533ae7be54254d"
"reference": "4181599c8f7b66401bf827a3e7e6da85a2303524"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f78f35f8c348f59a47e7973ec0533ae7be54254d",
"reference": "f78f35f8c348f59a47e7973ec0533ae7be54254d",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/4181599c8f7b66401bf827a3e7e6da85a2303524",
"reference": "4181599c8f7b66401bf827a3e7e6da85a2303524",
"shasum": ""
},
"require": {
@ -4417,7 +4417,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:51+00:00"
"time": "2021-01-27T12:52:00+00:00"
},
{
"name": "sebastian/resource-operations",
@ -4481,12 +4481,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "55fa25ad7fc6fb7caf2f7cfada5e5e20adf731aa"
"reference": "1c469702730295ddaf484d6fddb3b42a1354cd5c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/55fa25ad7fc6fb7caf2f7cfada5e5e20adf731aa",
"reference": "55fa25ad7fc6fb7caf2f7cfada5e5e20adf731aa",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/1c469702730295ddaf484d6fddb3b42a1354cd5c",
"reference": "1c469702730295ddaf484d6fddb3b42a1354cd5c",
"shasum": ""
},
"require": {
@ -4530,7 +4530,7 @@
"type": "github"
}
],
"time": "2021-01-23T09:14:59+00:00"
"time": "2021-01-27T12:52:09+00:00"
},
{
"name": "sebastian/version",
@ -4630,12 +4630,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "5d9e349571fa1fed2ed89fe1f5ffd58331468e87"
"reference": "a056a527ed72d089185d505882b66f3676e22439"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/5d9e349571fa1fed2ed89fe1f5ffd58331468e87",
"reference": "5d9e349571fa1fed2ed89fe1f5ffd58331468e87",
"url": "https://api.github.com/repos/symfony/console/zipball/a056a527ed72d089185d505882b66f3676e22439",
"reference": "a056a527ed72d089185d505882b66f3676e22439",
"shasum": ""
},
"require": {
@ -4720,7 +4720,7 @@
"type": "tidelift"
}
],
"time": "2021-01-23T09:52:46+00:00"
"time": "2021-01-27T09:05:46+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -5301,12 +5301,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "2f833cf54d5fe9646638c50778016a06b6fe1603"
"reference": "13c9099cdb470223b5863f7d11d17554b2dc6404"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/2f833cf54d5fe9646638c50778016a06b6fe1603",
"reference": "2f833cf54d5fe9646638c50778016a06b6fe1603",
"url": "https://api.github.com/repos/symfony/string/zipball/13c9099cdb470223b5863f7d11d17554b2dc6404",
"reference": "13c9099cdb470223b5863f7d11d17554b2dc6404",
"shasum": ""
},
"require": {
@ -5377,7 +5377,7 @@
"type": "tidelift"
}
],
"time": "2021-01-12T14:28:55+00:00"
"time": "2021-01-26T09:33:05+00:00"
},
{
"name": "theseer/tokenizer",