diff --git a/app/controllers/projects.php b/app/controllers/projects.php index aafa295866..6b84214012 100644 --- a/app/controllers/projects.php +++ b/app/controllers/projects.php @@ -121,6 +121,9 @@ $utopia->get('/v1/projects/:projectId/usage') $client = $register->get('influxdb'); + $requests = []; + $network = []; + if($client) { $start = DateTime::createFromFormat('U', strtotime('first day of this month')); $start = $start->format(DateTime::RFC3339); @@ -129,10 +132,8 @@ $utopia->get('/v1/projects/:projectId/usage') $database = $client->selectDB('telegraf'); // Requests - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \'' . $start . '\' AND time < \'' . $end . '\' AND "metric_type"=\'counter\' AND "project"=\'' . $project->getUid() . '\' GROUP BY time(1d) FILL(null)'); $points = $result->getPoints(); - $requests = []; foreach ($points as $point) { $requests[] = [ @@ -142,10 +143,8 @@ $utopia->get('/v1/projects/:projectId/usage') } // Network - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \'' . $start . '\' AND time < \'' . $end . '\' AND "metric_type"=\'counter\' AND "project"=\'' . $project->getUid() . '\' GROUP BY time(1d) FILL(null)'); $points = $result->getPoints(); - $network = []; foreach ($points as $point) { $network[] = [ @@ -363,7 +362,8 @@ $utopia->patch('/v1/projects/:projectId/oauth') $key = $request->getServer('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); - $secret = json_encode([ + $tag = null; + $secret = json_encode([ 'data' => OpenSSL::encrypt($secret, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), 'method' => OpenSSL::CIPHER_AES_128_GCM, 'iv' => bin2hex($iv), @@ -498,6 +498,7 @@ $utopia->post('/v1/projects/:projectId/webhooks') $key = $request->getServer('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $tag = null; $httpPass = json_encode([ 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), 'method' => OpenSSL::CIPHER_AES_128_GCM, @@ -563,6 +564,7 @@ $utopia->put('/v1/projects/:projectId/webhooks/:webhookId') $key = $request->getServer('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $tag = null; $httpPass = json_encode([ 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), 'method' => OpenSSL::CIPHER_AES_128_GCM, @@ -882,6 +884,7 @@ $utopia->post('/v1/projects/:projectId/tasks') $key = $request->getServer('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $tag = null; $httpPass = json_encode([ 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), 'method' => OpenSSL::CIPHER_AES_128_GCM, @@ -971,6 +974,7 @@ $utopia->put('/v1/projects/:projectId/tasks/:taskId') $key = $request->getServer('_APP_OPENSSL_KEY_V1'); $iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM)); + $tag = null; $httpPass = json_encode([ 'data' => OpenSSL::encrypt($httpPass, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag), 'method' => OpenSSL::CIPHER_AES_128_GCM, diff --git a/composer.json b/composer.json index 1aff11e424..5b514ee577 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "dragonmantank/cron-expression": "2.2.0", "sentry/sentry": "1.9.*", "domnikl/statsd": "2.0.*", - "influxdb/influxdb-php": "1.14.*", + "influxdb/influxdb-php": "1.15.*", "bacon/bacon-qr-code": "2.0.0", "erusev/parsedown": "1.7.1" }, diff --git a/composer.lock b/composer.lock index ec18590515..2c34df62c0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "f68a775eff043cea514c2805cc3e4b05", + "content-hash": "83fe01a42c79683e1d521172aec04743", "packages": [ { "name": "appwrite/php-clamav", @@ -284,12 +284,12 @@ "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "ec2e24d4fa6a0d50d423794a56605ecec3401b85" + "reference": "f26a67e397be0e5c00d7c52ec7b5010098e15ce5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/ec2e24d4fa6a0d50d423794a56605ecec3401b85", - "reference": "ec2e24d4fa6a0d50d423794a56605ecec3401b85", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/f26a67e397be0e5c00d7c52ec7b5010098e15ce5", + "reference": "f26a67e397be0e5c00d7c52ec7b5010098e15ce5", "shasum": "" }, "require": { @@ -332,7 +332,7 @@ "ssl", "tls" ], - "time": "2019-08-01 07:52:17" + "time": "2019-08-02 09:05:43" }, { "name": "dasprid/enum", @@ -624,12 +624,12 @@ "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "ca2892a8c2778c1821899fd2c79932e3b895f2ad" + "reference": "de7437d73816cb67ed35d476784d69e010a688b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ca2892a8c2778c1821899fd2c79932e3b895f2ad", - "reference": "ca2892a8c2778c1821899fd2c79932e3b895f2ad", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/de7437d73816cb67ed35d476784d69e010a688b5", + "reference": "de7437d73816cb67ed35d476784d69e010a688b5", "shasum": "" }, "require": { @@ -682,7 +682,7 @@ "rest", "web service" ], - "time": "2019-05-12 12:35:22" + "time": "2019-08-05 16:15:18" }, { "name": "guzzlehttp/promises", @@ -808,16 +808,16 @@ }, { "name": "influxdb/influxdb-php", - "version": "1.14.8", + "version": "1.15.0", "source": { "type": "git", "url": "https://github.com/influxdata/influxdb-php.git", - "reference": "e2c94cc7402d892185b3833f9627d67b6379e3d8" + "reference": "bf3415f81962e1ab8c939bc1a08a85f500bead35" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/e2c94cc7402d892185b3833f9627d67b6379e3d8", - "reference": "e2c94cc7402d892185b3833f9627d67b6379e3d8", + "url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/bf3415f81962e1ab8c939bc1a08a85f500bead35", + "reference": "bf3415f81962e1ab8c939bc1a08a85f500bead35", "shasum": "" }, "require": { @@ -828,6 +828,7 @@ "phpunit/phpunit": "^5.7" }, "suggest": { + "ext-curl": "Curl extension, needed for Curl driver", "stefanotorresi/influxdb-php-async": "An asyncronous client for InfluxDB, implemented via ReactPHP." }, "type": "library", @@ -864,7 +865,7 @@ "influxdb library", "time series" ], - "time": "2019-05-30T00:05:10+00:00" + "time": "2019-05-30T00:15:14+00:00" }, { "name": "matthiasmullie/minify", @@ -1385,12 +1386,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" + "reference": "550ebaac289296ce228a706d0867afc34687e3f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4", "shasum": "" }, "require": { @@ -1402,7 +1403,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -1418,13 +1419,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -1435,7 +1436,7 @@ "polyfill", "portable" ], - "time": "2019-02-06 07:57:58" + "time": "2019-08-06 08:03:45" }, { "name": "symfony/polyfill-mbstring", @@ -1443,12 +1444,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "626bb16c799983996863d1243eadf5bcb2cbb5bd" + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/626bb16c799983996863d1243eadf5bcb2cbb5bd", - "reference": "626bb16c799983996863d1243eadf5bcb2cbb5bd", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", "shasum": "" }, "require": { @@ -1460,7 +1461,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -1494,7 +1495,7 @@ "portable", "shim" ], - "time": "2019-08-01 10:49:16" + "time": "2019-08-06 08:03:45" }, { "name": "twig/twig", @@ -1502,12 +1503,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "5bfe590de545c791e4c3c98a908f65cc6c79b404" + "reference": "03dbdb9683a74379491d237504c1021ff3864b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/5bfe590de545c791e4c3c98a908f65cc6c79b404", - "reference": "5bfe590de545c791e4c3c98a908f65cc6c79b404", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/03dbdb9683a74379491d237504c1021ff3864b5b", + "reference": "03dbdb9683a74379491d237504c1021ff3864b5b", "shasum": "" }, "require": { @@ -1541,19 +1542,19 @@ "authors": [ { "name": "Fabien Potencier", + "role": "Lead Developer", "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" + "homepage": "http://fabien.potencier.org" }, { "name": "Twig Team", - "homepage": "https://twig.symfony.com/contributors", - "role": "Contributors" + "role": "Contributors", + "homepage": "https://twig.symfony.com/contributors" + }, + { + "name": "Armin Ronacher", + "role": "Project Founder", + "email": "armin.ronacher@active-4.com" } ], "description": "Twig, the flexible, fast, and secure template language for PHP", @@ -1561,7 +1562,7 @@ "keywords": [ "templating" ], - "time": "2019-07-12 06:13:06" + "time": "2019-08-02 08:10:18" }, { "name": "utopia-php/abuse", @@ -1906,12 +1907,12 @@ "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" + "reference": "6c3e9f1c8315a93bcebdd5f21630c945439968e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/6c3e9f1c8315a93bcebdd5f21630c945439968e9", + "reference": "6c3e9f1c8315a93bcebdd5f21630c945439968e9", "shasum": "" }, "require": { @@ -1946,7 +1947,7 @@ "object", "object graph" ], - "time": "2019-04-07T13:18:21+00:00" + "time": "2019-08-05T15:28:34+00:00" }, { "name": "phar-io/manifest", @@ -2370,8 +2371,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", @@ -2412,8 +2413,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Simple template engine.", @@ -2461,8 +2462,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Utility class for timing", @@ -2527,12 +2528,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e11397fed729bfef7a9c76f7b193c27ad5710f6b" + "reference": "062dfa4b8836627848a471bb552ede3d5c4f2a8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e11397fed729bfef7a9c76f7b193c27ad5710f6b", - "reference": "e11397fed729bfef7a9c76f7b193c27ad5710f6b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/062dfa4b8836627848a471bb552ede3d5c4f2a8f", + "reference": "062dfa4b8836627848a471bb552ede3d5c4f2a8f", "shasum": "" }, "require": { @@ -2603,7 +2604,7 @@ "testing", "xunit" ], - "time": "2019-07-27T05:00:17+00:00" + "time": "2019-08-03T08:12:46+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -3163,8 +3164,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", @@ -3269,7 +3270,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2.0", + "php": ">=7.3.0", "ext-mysqlnd": "*", "ext-curl": "*", "ext-imagick": "*",