From 7ed759ba0ee6035362c474aae15aecd04a867377 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 2 Jan 2021 21:45:59 +0200 Subject: [PATCH 1/2] First commit --- .env | 3 +++ Dockerfile | 2 ++ app/config/variables.php | 18 ++++++++++++++++++ app/controllers/api/health.php | 3 ++- app/controllers/api/storage.php | 3 ++- app/tasks/doctor.php | 3 ++- docker-compose.yml | 3 +++ 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.env b/.env index f881ca35d3..1277c28eff 100644 --- a/.env +++ b/.env @@ -15,6 +15,9 @@ _APP_DB_PORT=3306 _APP_DB_SCHEMA=appwrite _APP_DB_USER=user _APP_DB_PASS=password +_APP_STORAGE_ANTIVIRUS=enabled +_APP_STORAGE_ANTIVIRUS_HOST=clamav +_APP_STORAGE_ANTIVIRUS_PORT=3310 _APP_INFLUXDB_HOST=influxdb _APP_INFLUXDB_PORT=8086 _APP_STATSD_HOST=telegraf diff --git a/Dockerfile b/Dockerfile index fc7a03f936..9c48f9a4fc 100755 --- a/Dockerfile +++ b/Dockerfile @@ -77,6 +77,8 @@ ENV _APP_SERVER=swoole \ _APP_OPENSSL_KEY_V1=your-secret-key \ _APP_STORAGE_LIMIT=10000000 \ _APP_STORAGE_ANTIVIRUS=enabled \ + _APP_STORAGE_ANTIVIRUS_HOST=clamav \ + _APP_STORAGE_ANTIVIRUS_PORT=3310 \ _APP_REDIS_HOST=redis \ _APP_REDIS_PORT=6379 \ _APP_DB_HOST=mariadb \ diff --git a/app/config/variables.php b/app/config/variables.php index f752e90201..fb32000762 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -139,6 +139,24 @@ return [ 'required' => false, 'question' => '', ], + [ + 'name' => '_APP_STORAGE_ANTIVIRUS', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_ANTIVIRUS_HOST', + 'default' => 'clamav', + 'required' => false, + 'question' => '', + ], + [ + 'name' => '_APP_STORAGE_ANTIVIRUS_PORT', + 'default' => '3310', + 'required' => false, + 'question' => '', + ], [ 'name' => '_APP_FUNCTIONS_TIMEOUT', 'default' => '900', diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index c1c9de4755..370b2d0a17 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -256,7 +256,8 @@ App::get('/v1/health/anti-virus') throw new Exception('Anitvirus is disabled'); } - $antiVirus = new Network('clamav', 3310); + $antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)); $response->json([ 'status' => (@$antiVirus->ping()) ? 'online' : 'offline', diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index b7628e320b..b70fe9f950 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -96,7 +96,8 @@ App::post('/v1/storage/files') $mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled - $antiVirus = new Network('clamav', 3310); + $antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)); if (!$antiVirus->fileScan($path)) { $device->delete($path); diff --git a/app/tasks/doctor.php b/app/tasks/doctor.php index 70a7546b2a..e3985c8e75 100644 --- a/app/tasks/doctor.php +++ b/app/tasks/doctor.php @@ -113,7 +113,8 @@ $cli if(App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled') { // Check if scans are enabled try { - $antiVirus = new Network('clamav', 3310); + $antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'), + (int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310)); if((@$antiVirus->ping())) { Console::success('AntiVirus...........connected 👍'); diff --git a/docker-compose.yml b/docker-compose.yml index 701d1e240c..b4fb435275 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -91,6 +91,9 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_STORAGE_ANTIVIRUS + - _APP_STORAGE_ANTIVIRUS_HOST + - _APP_STORAGE_ANTIVIRUS_PORT - _APP_SMTP_HOST - _APP_SMTP_PORT - _APP_SMTP_SECURE From 0812a6b82d9e6ec20fac2678cde9a4dafebfd3a6 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 2 Jan 2021 21:47:23 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 6185144417..bb1fbf9c09 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -51,6 +51,7 @@ - Upgraded Influxdb Docker image to version 1.8 (alpine) - Added option to disable mail sending by setting empty SMTP host - Upgraded installation script ([#490](https://github.com/appwrite/appwrite/issues/490)) +- Added new environment variables for ClamAV hostname and port ([#780](https://github.com/appwrite/appwrite/pull/780)) ## Breaking Changes (Read before upgrading!) - **Deprecated** `first` and `last` query params for documents list route in the database API