From 10d601b95cebb0f0bbad70775edd0e169f88bd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Wed, 21 Sep 2022 14:23:38 +0200 Subject: [PATCH] Fix #42 add PHPMD to the GitlabCI Update the dependencies --- .gitlab-ci.yml | 1 + Makefile | 1 + flexiapi/app/Account.php | 19 +- .../Commands/ClearOldAccountsTombstones.php | 7 +- .../app/Console/Commands/ImportDatabase.php | 8 +- .../Commands/ImportExternalAccounts.php | 21 +- .../Commands/RemoveUnconfirmedAccounts.php | 7 +- .../Controllers/Account/EmailController.php | 20 +- .../Account/PasswordController.php | 14 +- .../Api/AccountCreationTokenController.php | 5 +- .../Controllers/Api/PasswordController.php | 10 +- flexiapi/app/Http/Middleware/Authenticate.php | 1 - .../Middleware/AuthenticateDigestOrKey.php | 8 +- flexiapi/composer.json | 3 +- flexiapi/composer.lock | 601 ++++++++++++++++-- ..._last_used_at_column_to_api_keys_table.php | 5 +- flexiapi/phpmd.xml | 22 + flexiapi/tests/TestCase.php | 8 +- flexisip-account-manager.spec | 2 +- 19 files changed, 654 insertions(+), 109 deletions(-) create mode 100644 flexiapi/phpmd.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c73853..b4e454f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,6 +41,7 @@ centos7-rpm-test: - yum -y localinstall rpmbuild/x86_64/*.rpm - cd /opt/belledonne-communications/share/flexisip-account-manager/flexiapi - scl enable rh-php73 "vendor/bin/phpcs" + - scl enable rh-php73 "vendor/bin/phpmd . ansi phpmd.xml" - scl enable rh-php73 "php artisan key:generate" - scl enable rh-php73 "vendor/bin/phpunit --log-junit $CI_PROJECT_DIR/flexiapi_phpunit.log" artifacts: diff --git a/Makefile b/Makefile index 571bd9a..e275138 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ package-common: cp flexiapi/artisan $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/ cp flexiapi/phpunit.xml $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/ cp flexiapi/phpcs.xml $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/ + cp flexiapi/phpmd.xml $(OUTPUT_DIR)/flexisip-account-manager/flexiapi/ # General cp README.md $(OUTPUT_DIR)/flexisip-account-manager/ diff --git a/flexiapi/app/Account.php b/flexiapi/app/Account.php index 1e6004a..3481959 100644 --- a/flexiapi/app/Account.php +++ b/flexiapi/app/Account.php @@ -58,9 +58,11 @@ class Account extends Authenticatable if (!$user->admin || !config('app.admins_manage_multi_domains')) { $builder->where('domain', config('app.sip_domain')); } - } else { - $builder->where('domain', config('app.sip_domain')); + + return; } + + $builder->where('domain', config('app.sip_domain')); }); /** @@ -274,7 +276,7 @@ class Account extends Authenticatable '<', Carbon::now()->subMinutes(AuthToken::$expirationMinutes) )->orWhere('account_id', $this->id) - ->delete(); + ->delete(); $authToken = new AuthToken; $authToken->account_id = $this->id; @@ -314,13 +316,10 @@ VERSION:4.0 KIND:individual IMPP:sip:' . $this->getIdentifierAttribute(); - if (!empty($this->attributes['display_name'])) { - $vcard .= ' -FN:' . $this->attributes['display_name']; - } else { - $vcard .= ' -FN:' . $this->getIdentifierAttribute(); - } + $vcard .= ' +FN:' . !empty($this->attributes['display_name']) + ? $this->attributes['display_name'] + : $this->getIdentifierAttribute(); if ($this->dtmf_protocol) { $vcard .= ' diff --git a/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php b/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php index 7a695e8..c3e9f96 100644 --- a/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php +++ b/flexiapi/app/Console/Commands/ClearOldAccountsTombstones.php @@ -44,8 +44,11 @@ class ClearOldAccountsTombstones extends Command if ($this->option('apply')) { $this->info($tombstones->count() . ' tombstones deleted'); $tombstones->delete(); - } else { - $this->info($tombstones->count() . ' tombstones to delete'); + + return 0; } + + $this->info($tombstones->count() . ' tombstones to delete'); + return 0; } } diff --git a/flexiapi/app/Console/Commands/ImportDatabase.php b/flexiapi/app/Console/Commands/ImportDatabase.php index 4b8f325..2bc01af 100644 --- a/flexiapi/app/Console/Commands/ImportDatabase.php +++ b/flexiapi/app/Console/Commands/ImportDatabase.php @@ -69,9 +69,7 @@ class ImportDatabase extends Command 'prefix' => '', ], 'default'); - if (!$this->argument('sqlite-file-path')) { - $this->confirm('No SQLite database file was specified : Do you wish to continue?'); - } else { + if ($this->argument('sqlite-file-path')) { $capsule->addConnection([ 'driver' => 'sqlite', 'database' => $this->argument('sqlite-file-path'), @@ -80,6 +78,10 @@ class ImportDatabase extends Command $capsule->setAsGlobal(); + if (!$this->argument('sqlite-file-path')) { + $this->confirm('No SQLite database file was specified : Do you wish to continue?'); + } + // Ensure that the target database is empty if (Account::count() > 0) { $this->error('An empty database is required to run the migration'); diff --git a/flexiapi/app/Console/Commands/ImportExternalAccounts.php b/flexiapi/app/Console/Commands/ImportExternalAccounts.php index 51ee7e0..598cab1 100644 --- a/flexiapi/app/Console/Commands/ImportExternalAccounts.php +++ b/flexiapi/app/Console/Commands/ImportExternalAccounts.php @@ -41,17 +41,18 @@ class ImportExternalAccounts extends Command foreach ($json as $account) { if ($existingUsernames->contains($account->username)) { $existingCounter++; - } else { - $externalAccount = new ExternalAccount; - $externalAccount->username = $account->username; - $externalAccount->domain = $account->domain; - $externalAccount->group = $account->group; - $externalAccount->password = $account->password; - $externalAccount->algorithm = $account->algorithm; - - $externalAccounts->push($externalAccount->toArray()); - $importedCounter++; + continue; } + + $externalAccount = new ExternalAccount; + $externalAccount->username = $account->username; + $externalAccount->domain = $account->domain; + $externalAccount->group = $account->group; + $externalAccount->password = $account->password; + $externalAccount->algorithm = $account->algorithm; + + $externalAccounts->push($externalAccount->toArray()); + $importedCounter++; } ExternalAccount::insert($externalAccounts->toArray()); diff --git a/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php b/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php index 3f44cdc..15fdea0 100644 --- a/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php +++ b/flexiapi/app/Console/Commands/RemoveUnconfirmedAccounts.php @@ -52,8 +52,11 @@ class RemoveUnconfirmedAccounts extends Command $this->info($count . ' accounts in deletion…'); $accounts->delete(); $this->info($count . ' accounts deleted'); - } else { - $this->info($count . ' accounts to delete'); + + return 0; } + + $this->info($count . ' accounts to delete'); + return 0; } } diff --git a/flexiapi/app/Http/Controllers/Account/EmailController.php b/flexiapi/app/Http/Controllers/Account/EmailController.php index a73b7fb..f555f15 100644 --- a/flexiapi/app/Http/Controllers/Account/EmailController.php +++ b/flexiapi/app/Http/Controllers/Account/EmailController.php @@ -38,16 +38,16 @@ class EmailController extends Controller public function requestUpdate(Request $request) { - if ($request->user()->email) { - $request->validate([ - 'email_current' => ['required', Rule::in([$request->user()->email])], - 'email' => 'required|different:email_current|confirmed|email', - ]); - } else { - $request->validate([ - 'email' => 'required|confirmed|email', - ]); - } + $request->validate( + $request->user()->email + ? [ + 'email_current' => ['required', Rule::in([$request->user()->email])], + 'email' => 'required|different:email_current|confirmed|email', + ] + : [ + 'email' => 'required|confirmed|email', + ] + ); $request->user()->requestEmailUpdate($request->get('email')); diff --git a/flexiapi/app/Http/Controllers/Account/PasswordController.php b/flexiapi/app/Http/Controllers/Account/PasswordController.php index ef7cc3a..bb9b4bc 100644 --- a/flexiapi/app/Http/Controllers/Account/PasswordController.php +++ b/flexiapi/app/Http/Controllers/Account/PasswordController.php @@ -52,13 +52,15 @@ class PasswordController extends Controller if ($account->passwords()->count() > 0) { Log::channel('events')->info('Web: Password changed', ['id' => $account->identifier]); $request->session()->flash('success', 'Password successfully changed'); - } else { - Log::channel('events')->info('Web: Password set for the first time', ['id' => $account->identifier]); - $request->session()->flash('success', 'Password successfully set. Your SIP account creation process is now finished.'); - if (!empty($account->email)) { - Mail::to($account)->send(new ConfirmedRegistration($account)); - } + return redirect()->route('account.panel'); + } + + Log::channel('events')->info('Web: Password set for the first time', ['id' => $account->identifier]); + $request->session()->flash('success', 'Password successfully set. Your SIP account creation process is now finished.'); + + if (!empty($account->email)) { + Mail::to($account)->send(new ConfirmedRegistration($account)); } return redirect()->route('account.panel'); diff --git a/flexiapi/app/Http/Controllers/Api/AccountCreationTokenController.php b/flexiapi/app/Http/Controllers/Api/AccountCreationTokenController.php index 69f004a..1e83a37 100644 --- a/flexiapi/app/Http/Controllers/Api/AccountCreationTokenController.php +++ b/flexiapi/app/Http/Controllers/Api/AccountCreationTokenController.php @@ -65,8 +65,9 @@ class AccountCreationTokenController extends Controller Log::channel('events')->info('API: Token sent', ['token' => $token->token]); $token->save(); - } else { - abort(503, "Token not sent"); + return; } + + abort(503, "Token not sent"); } } diff --git a/flexiapi/app/Http/Controllers/Api/PasswordController.php b/flexiapi/app/Http/Controllers/Api/PasswordController.php index c6c9848..58dabe6 100644 --- a/flexiapi/app/Http/Controllers/Api/PasswordController.php +++ b/flexiapi/app/Http/Controllers/Api/PasswordController.php @@ -58,12 +58,12 @@ class PasswordController extends Controller } return response()->json(['errors' => ['old_password' => 'Incorrect old password']], 422); - } else { - $account->updatePassword($request->get('password'), $algorithm); + } - if (!empty($account->email)) { - Mail::to($account)->send(new ConfirmedRegistration($account)); - } + $account->updatePassword($request->get('password'), $algorithm); + + if (!empty($account->email)) { + Mail::to($account)->send(new ConfirmedRegistration($account)); } } } diff --git a/flexiapi/app/Http/Middleware/Authenticate.php b/flexiapi/app/Http/Middleware/Authenticate.php index 1fd242e..18ed0ec 100644 --- a/flexiapi/app/Http/Middleware/Authenticate.php +++ b/flexiapi/app/Http/Middleware/Authenticate.php @@ -1,7 +1,6 @@ algorithm == 'CLRTXT' + $a1 = $password->algorithm == 'CLRTXT' ? hash($hash, $account->username.':'.$resolvedRealm.':'.$password->password) : $password->password; // username:realm/domain:password - $A2 = hash($hash, $request->method().':'.$auth['uri']); + $a2 = hash($hash, $request->method().':'.$auth['uri']); $validResponse = hash($hash, - $A1. + $a1. ':'.$auth['nonce']. ':'.$auth['nc']. ':'.$auth['cnonce']. ':'.$auth['qop']. - ':'.$A2 + ':'.$a2 ); // Auth response don't match diff --git a/flexiapi/composer.json b/flexiapi/composer.json index 66cef93..013c03f 100644 --- a/flexiapi/composer.json +++ b/flexiapi/composer.json @@ -28,7 +28,8 @@ "mockery/mockery": "^1.4", "nunomaduro/collision": "^5.0", "phpunit/phpunit": "^9.0", - "squizlabs/php_codesniffer": "^3.7" + "squizlabs/php_codesniffer": "^3.7", + "phpmd/phpmd": "^2.13" }, "config": { "platform": { diff --git a/flexiapi/composer.lock b/flexiapi/composer.lock index 044d30f..37d5b79 100644 --- a/flexiapi/composer.lock +++ b/flexiapi/composer.lock @@ -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": "5491f03249bb73afd568b82584b43311", + "content-hash": "6be6fea08638d583a0607ed9582e56d5", "packages": [ { "name": "anhskohbo/no-captcha", @@ -738,16 +738,16 @@ }, { "name": "dragonmantank/cron-expression", - "version": "v3.3.1", + "version": "v3.3.2", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "be85b3f05b46c39bbc0d95f6c071ddff669510fa" + "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/be85b3f05b46c39bbc0d95f6c071ddff669510fa", - "reference": "be85b3f05b46c39bbc0d95f6c071ddff669510fa", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/782ca5968ab8b954773518e9e49a6f892a34b2a8", + "reference": "782ca5968ab8b954773518e9e49a6f892a34b2a8", "shasum": "" }, "require": { @@ -787,7 +787,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.1" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.2" }, "funding": [ { @@ -795,7 +795,7 @@ "type": "github" } ], - "time": "2022-01-18T15:43:28+00:00" + "time": "2022-09-10T18:51:20+00:00" }, { "name": "egulias/email-validator", @@ -1638,16 +1638,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.2.1", + "version": "v1.2.2", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "d78fd36ba031a1a695ea5a406f29996948d7011b" + "reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/d78fd36ba031a1a695ea5a406f29996948d7011b", - "reference": "d78fd36ba031a1a695ea5a406f29996948d7011b", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/47afb7fae28ed29057fdca37e16a84f90cc62fae", + "reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae", "shasum": "" }, "require": { @@ -1694,7 +1694,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2022-08-26T15:25:27+00:00" + "time": "2022-09-08T13:45:54+00:00" }, { "name": "laravel/tinker", @@ -3256,16 +3256,16 @@ }, { "name": "react/dns", - "version": "v1.9.0", + "version": "v1.10.0", "source": { "type": "git", "url": "https://github.com/reactphp/dns.git", - "reference": "6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb" + "reference": "a5427e7dfa47713e438016905605819d101f238c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb", - "reference": "6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb", + "url": "https://api.github.com/repos/reactphp/dns/zipball/a5427e7dfa47713e438016905605819d101f238c", + "reference": "a5427e7dfa47713e438016905605819d101f238c", "shasum": "" }, "require": { @@ -3273,11 +3273,11 @@ "react/cache": "^1.0 || ^0.6 || ^0.5", "react/event-loop": "^1.2", "react/promise": "^3.0 || ^2.7 || ^1.2.1", - "react/promise-timer": "^1.8" + "react/promise-timer": "^1.9" }, "require-dev": { - "clue/block-react": "^1.2", - "phpunit/phpunit": "^9.3 || ^4.8.35" + "phpunit/phpunit": "^9.3 || ^4.8.35", + "react/async": "^4 || ^3 || ^2" }, "type": "library", "autoload": { @@ -3320,7 +3320,7 @@ ], "support": { "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.9.0" + "source": "https://github.com/reactphp/dns/tree/v1.10.0" }, "funding": [ { @@ -3332,7 +3332,7 @@ "type": "github" } ], - "time": "2021-12-20T08:46:54+00:00" + "time": "2022-09-08T12:22:46+00:00" }, { "name": "react/event-loop", @@ -6142,16 +6142,16 @@ }, { "name": "tijsverkoyen/css-to-inline-styles", - "version": "2.2.4", + "version": "2.2.5", "source": { "type": "git", "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", - "reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c" + "reference": "4348a3a06651827a27d989ad1d13efec6bb49b19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/da444caae6aca7a19c0c140f68c6182e337d5b1c", - "reference": "da444caae6aca7a19c0c140f68c6182e337d5b1c", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/4348a3a06651827a27d989ad1d13efec6bb49b19", + "reference": "4348a3a06651827a27d989ad1d13efec6bb49b19", "shasum": "" }, "require": { @@ -6189,9 +6189,9 @@ "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", "support": { "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues", - "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.4" + "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/2.2.5" }, - "time": "2021-12-08T09:12:39+00:00" + "time": "2022-09-12T13:28:28+00:00" }, { "name": "vlucas/phpdotenv", @@ -6491,6 +6491,143 @@ ], "time": "2022-07-11T09:26:42+00:00" }, + { + "name": "composer/pcre", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/c8e9d27cfc5ed22643c19c160455b473ffd8aabe", + "reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/2.0.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-02-25T20:05:29+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "ced299686f41dce890debac69273b47ffe98a40c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-02-25T21:32:43+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.1", @@ -7218,6 +7355,63 @@ ], "time": "2022-01-10T16:22:52+00:00" }, + { + "name": "pdepend/pdepend", + "version": "2.12.1", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "7a892d56ceafd804b4a2ecc85184640937ce9e84" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/7a892d56ceafd804b4a2ecc85184640937ce9e84", + "reference": "7a892d56ceafd804b4a2ecc85184640937ce9e84", + "shasum": "" + }, + "require": { + "php": ">=5.3.7", + "symfony/config": "^2.3.0|^3|^4|^5|^6.0", + "symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0", + "symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0|^1.2.3", + "gregwar/rst": "^1.0", + "phpunit/phpunit": "^4.8.36|^5.7.27", + "squizlabs/php_codesniffer": "^2.0.0" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "PDepend\\": "src/main/php/PDepend" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "support": { + "issues": "https://github.com/pdepend/pdepend/issues", + "source": "https://github.com/pdepend/pdepend/tree/2.12.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/pdepend/pdepend", + "type": "tidelift" + } + ], + "time": "2022-09-08T19:30:37+00:00" + }, { "name": "phar-io/manifest", "version": "2.0.3", @@ -7329,6 +7523,89 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpmd/phpmd", + "version": "2.13.0", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "dad0228156856b3ad959992f9748514fa943f3e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/dad0228156856b3ad959992f9748514fa943f3e3", + "reference": "dad0228156856b3ad959992f9748514fa943f3e3", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0", + "ext-xml": "*", + "pdepend/pdepend": "^2.12.1", + "php": ">=5.3.9" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0 || ^1.3.2", + "ext-json": "*", + "ext-simplexml": "*", + "gregwar/rst": "^1.0", + "mikey179/vfsstream": "^1.6.8", + "phpunit/phpunit": "^4.8.36 || ^5.7.27", + "squizlabs/php_codesniffer": "^2.0" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "library", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Manuel Pichler", + "email": "github@manuel-pichler.de", + "homepage": "https://github.com/manuelpichler", + "role": "Project Founder" + }, + { + "name": "Marc Würth", + "email": "ravage@bluewin.ch", + "homepage": "https://github.com/ravage84", + "role": "Project Maintainer" + }, + { + "name": "Other contributors", + "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", + "role": "Contributors" + } + ], + "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", + "homepage": "https://phpmd.org/", + "keywords": [ + "mess detection", + "mess detector", + "pdepend", + "phpmd", + "pmd" + ], + "support": { + "irc": "irc://irc.freenode.org/phpmd", + "issues": "https://github.com/phpmd/phpmd/issues", + "source": "https://github.com/phpmd/phpmd/tree/2.13.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/phpmd/phpmd", + "type": "tidelift" + } + ], + "time": "2022-09-10T08:44:15+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.17", @@ -7914,16 +8191,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -7976,7 +8253,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -7984,7 +8261,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -8174,16 +8451,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { @@ -8239,7 +8516,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { @@ -8247,7 +8524,7 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", @@ -8602,16 +8879,16 @@ }, { "name": "sebastian/type", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb44e1cc6e557418387ad815780360057e40753e" + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e", - "reference": "fb44e1cc6e557418387ad815780360057e40753e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "shasum": "" }, "require": { @@ -8623,7 +8900,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -8646,7 +8923,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.1.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" }, "funding": [ { @@ -8654,7 +8931,7 @@ "type": "github" } ], - "time": "2022-08-29T06:55:37+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { "name": "sebastian/version", @@ -8765,6 +9042,238 @@ }, "time": "2022-06-18T07:21:10+00:00" }, + { + "name": "symfony/config", + "version": "v5.4.11", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "ec79e03125c1d2477e43dde8528535d90cc78379" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/ec79e03125c1d2477e43dde8528535d90cc78379", + "reference": "ec79e03125c1d2477e43dde8528535d90cc78379", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22" + }, + "conflict": { + "symfony/finder": "<4.4" + }, + "require-dev": { + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/yaml": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/config/tree/v5.4.11" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-07-20T13:00:38+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v5.4.11", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "a8b9251016e9476db73e25fa836904bc0bf74c62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/a8b9251016e9476db73e25fa836904bc0bf74c62", + "reference": "a8b9251016e9476db73e25fa836904bc0bf74c62", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1.1", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16", + "symfony/polyfill-php81": "^1.22", + "symfony/service-contracts": "^1.1.6|^2" + }, + "conflict": { + "ext-psr": "<1.1|>=2", + "symfony/config": "<5.3", + "symfony/finder": "<4.4", + "symfony/proxy-manager-bridge": "<4.4", + "symfony/yaml": "<4.4.26" + }, + "provide": { + "psr/container-implementation": "1.0", + "symfony/service-implementation": "1.0|2.0" + }, + "require-dev": { + "symfony/config": "^5.3|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4.26|^5.0|^6.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows you to standardize and centralize the way objects are constructed in your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.11" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-07-20T13:00:38+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.4.12", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "2d67c1f9a1937406a9be3171b4b22250c0a11447" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/2d67c1f9a1937406a9be3171b4b22250c0a11447", + "reference": "2d67c1f9a1937406a9be3171b4b22250c0a11447", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.12" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-08-02T13:48:16+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", diff --git a/flexiapi/database/migrations/2022_02_07_111109_add_last_used_at_column_to_api_keys_table.php b/flexiapi/database/migrations/2022_02_07_111109_add_last_used_at_column_to_api_keys_table.php index 0d62aa6..aca1985 100644 --- a/flexiapi/database/migrations/2022_02_07_111109_add_last_used_at_column_to_api_keys_table.php +++ b/flexiapi/database/migrations/2022_02_07_111109_add_last_used_at_column_to_api_keys_table.php @@ -16,9 +16,10 @@ class AddLastUsedAtColumnToApiKeysTable extends Migration Schema::table('api_keys', function (Blueprint $table) { if (DB::getDriverName() == 'sqlite') { $table->dateTime('last_used_at')->default(''); - } else { - $table->dateTime('last_used_at'); + return; } + + $table->dateTime('last_used_at'); }); } diff --git a/flexiapi/phpmd.xml b/flexiapi/phpmd.xml new file mode 100644 index 0000000..953c29e --- /dev/null +++ b/flexiapi/phpmd.xml @@ -0,0 +1,22 @@ + + + + + +The Clean Code ruleset contains rules that enforce a clean code base. This includes rules from SOLID and object calisthenics. + + + + + + + + + + */vendor/* + + diff --git a/flexiapi/tests/TestCase.php b/flexiapi/tests/TestCase.php index e62c47c..f7d4e56 100644 --- a/flexiapi/tests/TestCase.php +++ b/flexiapi/tests/TestCase.php @@ -59,18 +59,18 @@ abstract class TestCase extends BaseTestCase $cnonce = generateNonce(); - $A1 = $password->password; - $A2 = hash($hash, $this->method . ':' . $this->route); + $a1 = $password->password; + $a2 = hash($hash, $this->method . ':' . $this->route); $response = hash( $hash, sprintf( '%s:%s:%s:%s:%s:%s', - $A1, + $a1, $extractedChallenge['nonce'], $nc, $cnonce, $extractedChallenge['qop'], - $A2 + $a2 ) ); diff --git a/flexisip-account-manager.spec b/flexisip-account-manager.spec index f143f35..86caa80 100644 --- a/flexisip-account-manager.spec +++ b/flexisip-account-manager.spec @@ -8,7 +8,7 @@ #%define _datadir %{_datarootdir} #%define _docdir %{_datadir}/doc -%define build_number 151 +%define build_number 152 %define var_dir /var/opt/belledonne-communications %define opt_dir /opt/belledonne-communications/share/flexisip-account-manager