diff --git a/ajax/ajax.php b/ajax/ajax.php index 4a30e16..1903831 100644 --- a/ajax/ajax.php +++ b/ajax/ajax.php @@ -90,7 +90,7 @@ $ws->getConnexion($_POST['host'], $_POST['url'], $_POST['login'], - Toolbox::sodiumDecrypt($_POST['pwd'])); + (new GLPIKey())->decrypt($_POST['pwd'])); $result = $ws->getStateMantis(); if (! $result) { diff --git a/composer.json b/composer.json index 3638ad6..80f27e8 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": "^7.2" + "php": ">=7.4" }, "require-dev": { "glpi-project/tools": "^0.4" @@ -8,7 +8,7 @@ "config": { "optimize-autoloader": true, "platform": { - "php": "7.2.0" + "php": "7.4.0" }, "sort-packages": true } diff --git a/composer.lock b/composer.lock index e7a6c4e..9dbff32 100644 --- a/composer.lock +++ b/composer.lock @@ -4,25 +4,26 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8354308e8805d3f53d35251aac6a4525", + "content-hash": "fc83e1062054dc8c9ba6b4c2ba423677", "packages": [], "packages-dev": [ { "name": "glpi-project/tools", - "version": "0.4.2", + "version": "0.4.5", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "34369dd85cc99c18c3b8cf441bba11ec32173f2d" + "reference": "55ffa6566813d3c40d621892713ef63614820c79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/34369dd85cc99c18c3b8cf441bba11ec32173f2d", - "reference": "34369dd85cc99c18c3b8cf441bba11ec32173f2d", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/55ffa6566813d3c40d621892713ef63614820c79", + "reference": "55ffa6566813d3c40d621892713ef63614820c79", "shasum": "" }, "require": { - "symfony/console": "^4.4 || ^5.0" + "symfony/console": "^4.4 || ^5.0", + "twig/twig": "^3.3" }, "bin": [ "bin/extract-locales", @@ -57,24 +58,24 @@ "issues": "https://github.com/glpi-project/tools/issues", "source": "https://github.com/glpi-project/tools" }, - "time": "2022-01-28T13:44:12+00:00" + "time": "2022-04-20T06:57:59+00:00" }, { "name": "psr/container", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", "shasum": "" }, "require": { - "php": ">=7.2.0" + "php": ">=7.4.0" }, "type": "library", "autoload": { @@ -103,49 +104,52 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" + "source": "https://github.com/php-fig/container/tree/1.1.2" }, - "time": "2021-03-05T17:36:06+00:00" + "time": "2021-11-05T16:50:12+00:00" }, { "name": "symfony/console", - "version": "v4.4.37", + "version": "v5.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0259f01dbf9d77badddbbf4c2abb681f24c9cac6" + "reference": "900275254f0a1a2afff1ab0e11abd5587a10e1d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0259f01dbf9d77badddbbf4c2abb681f24c9cac6", - "reference": "0259f01dbf9d77badddbbf4c2abb681f24c9cac6", + "url": "https://api.github.com/repos/symfony/console/zipball/900275254f0a1a2afff1ab0e11abd5587a10e1d6", + "reference": "900275254f0a1a2afff1ab0e11abd5587a10e1d6", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php73": "^1.9", "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2" + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" }, "conflict": { "psr/log": ">=3", - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3|>=5", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", "symfony/lock": "<4.4", - "symfony/process": "<3.3" + "symfony/process": "<4.4" }, "provide": { "psr/log-implementation": "1.0|2.0" }, "require-dev": { "psr/log": "^1|^2", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.3|^5.0" + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" }, "suggest": { "psr/log": "For using the console logger", @@ -178,8 +182,244 @@ ], "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.4.7" + }, + "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-03-31T17:09:19+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" + }, + "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-01-02T09:53:40+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + }, + "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": "2021-10-20T20:35:02+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/81b86b50cf841a64252b439e738e97f4a34e2783", + "reference": "81b86b50cf841a64252b439e738e97f4a34e2783", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], "support": { - "source": "https://github.com/symfony/console/tree/v4.4.37" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" }, "funding": [ { @@ -195,11 +435,95 @@ "type": "tidelift" } ], - "time": "2022-01-26T16:15:26+00:00" + "time": "2021-11-23T21:10:46+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", + "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" + }, + "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": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -231,12 +555,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -262,7 +586,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" }, "funding": [ { @@ -282,7 +606,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -308,12 +632,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -341,7 +665,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0" }, "funding": [ { @@ -361,16 +685,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", "shasum": "" }, "require": { @@ -387,12 +711,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -424,7 +748,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" }, "funding": [ { @@ -440,25 +764,29 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:33+00:00" + "time": "2022-03-04T08:16:47+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.11", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "633df678bec3452e04a7b0337c9bcfe7354124b3" + "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/633df678bec3452e04a7b0337c9bcfe7354124b3", - "reference": "633df678bec3452e04a7b0337c9bcfe7354124b3", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/24d9dc654b83e91aa59f9d167b131bc3b5bea24c", + "reference": "24d9dc654b83e91aa59f9d167b131bc3b5bea24c", "shasum": "" }, "require": { - "php": ">=7.1.3", - "psr/container": "^1.0" + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" }, "suggest": { "symfony/service-implementation": "" @@ -466,7 +794,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.1-dev" + "dev-main": "2.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -503,7 +831,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v1.1.11" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.1" }, "funding": [ { @@ -519,7 +847,169 @@ "type": "tidelift" } ], - "time": "2021-11-04T13:32:43+00:00" + "time": "2022-03-13T20:07:29+00:00" + }, + { + "name": "symfony/string", + "version": "v5.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "92043b7d8383e48104e411bc9434b260dbeb5a10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/92043b7d8383e48104e411bc9434b260dbeb5a10", + "reference": "92043b7d8383e48104e411bc9434b260dbeb5a10", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "conflict": { + "symfony/translation-contracts": ">=3.0" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.4.3" + }, + "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-01-02T09:53:40+00:00" + }, + { + "name": "twig/twig", + "version": "v3.3.10", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "8442df056c51b706793adf80a9fd363406dd3674" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/8442df056c51b706793adf80a9fd363406dd3674", + "reference": "8442df056c51b706793adf80a9fd363406dd3674", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "^1.8", + "symfony/polyfill-mbstring": "^1.3" + }, + "require-dev": { + "psr/container": "^1.0", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Twig Team", + "role": "Contributors" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "support": { + "issues": "https://github.com/twigphp/Twig/issues", + "source": "https://github.com/twigphp/Twig/tree/v3.3.10" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2022-04-06T06:47:41+00:00" } ], "aliases": [], @@ -528,11 +1018,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2" + "php": ">=7.4" }, "platform-dev": [], "platform-overrides": { - "php": "7.2.0" + "php": "7.4.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/front/config.form.php b/front/config.form.php index 7f5053e..06993e0 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -42,6 +42,11 @@ $PluginMantisConfig = new PluginMantisConfig(); if (isset($_POST["update"])) { + if (array_key_exists('pwd', $_POST)) { + // Password must not be altered, it will be encrypted and never displayed, so sanitize is not necessary. + $_POST['pwd'] = $_UPOST['pwd']; + } + $PluginMantisConfig->check($_POST["id"], UPDATE); $PluginMantisConfig->update($_POST); Html::back(); diff --git a/inc/config.class.php b/inc/config.class.php index 01568c1..acb9677 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -55,8 +55,8 @@ static function getTypeName($nb = 0) { **/ function prepareInputForUpdate($input) { - if (isset($input["pwd"]) AND !empty($input["pwd"])) { - $input["pwd"] = Toolbox::sodiumEncrypt(stripslashes($input["pwd"])); + if (isset($input["pwd"]) && !empty($input["pwd"])) { + $input["pwd"] = (new GLPIKey())->encrypt($input["pwd"]); } return $input; } @@ -122,7 +122,7 @@ function showForm($ID, $options = []) { echo ""; echo "" . __("MantisBT user password", "mantis") . ""; echo ""; + value='" . Html::entities_deep((new GLPIKey())->decrypt($this->fields["pwd"])) . "' />"; echo ""; echo ""; @@ -241,31 +241,35 @@ function showForm($ID, $options = []) { static function install(Migration $migration) { global $DB; + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); + $table = getTableForItemType(__CLASS__); if (!$DB->tableExists($table)) { $query = "CREATE TABLE `".$table."` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `host` varchar(255) NOT NULL default '', `url` varchar(255) NOT NULL default '', `login` varchar(255) NOT NULL default '', `pwd` varchar(255) NOT NULL default '', `champsUrlGlpi` varchar(100) NOT NULL default '', `champsGlpi` varchar(100) NOT NULL default '', - `enable_assign` int(3) NOT NULL default 0, - `neutralize_escalation` int(3) NOT NULL default 0, - `status_after_escalation` int(3) NOT NULL default 0, - `show_option_delete` int(3) NOT NULL default 0, - `doc_categorie` int(3) NOT NULL default 0, + `enable_assign` int NOT NULL default 0, + `neutralize_escalation` int NOT NULL default 0, + `status_after_escalation` int NOT NULL default 0, + `show_option_delete` int NOT NULL default 0, + `doc_categorie` int NOT NULL default 0, `itemType` varchar(255) NOT NULL default '', `etatMantis` varchar(100) NOT NULL default '', - `solutiontypes_id` int(11) NOT NULL DEFAULT 0, - `users_id` int(11) NOT NULL DEFAULT 0, - `check_ssl` int(1) NOT NULL DEFAULT 0, - `use_proxy` int(1) NOT NULL DEFAULT 0, - `is_password_sodium_encrypted` int(1) NOT NULL DEFAULT 1, + `solutiontypes_id` int {$default_key_sign} NOT NULL DEFAULT 0, + `users_id` int {$default_key_sign} NOT NULL DEFAULT 0, + `check_ssl` int NOT NULL DEFAULT 0, + `use_proxy` int NOT NULL DEFAULT 0, + `is_password_sodium_encrypted` int NOT NULL DEFAULT 1, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `$table` (id) VALUES (1)"; @@ -277,30 +281,31 @@ static function install(Migration $migration) { } if (!$DB->fieldExists($table, 'solutiontypes_id')) { - $migration->addField($table, "solutiontypes_id", "INT( 11 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "solutiontypes_id", "INT {$default_key_sign} NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'users_id')) { - $migration->addField($table, "users_id", "INT( 11 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "users_id", "INT {$default_key_sign} NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'check_ssl')) { - $migration->addField($table, "check_ssl", "INT( 1 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "check_ssl", "INT NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'use_proxy')) { - $migration->addField($table, "use_proxy", "INT( 1 ) NOT NULL DEFAULT 0"); + $migration->addField($table, "use_proxy", "INT NOT NULL DEFAULT 0"); } if (!$DB->fieldExists($table, 'is_password_sodium_encrypted')) { $config = new self(); $config->getFromDB(1); if (!empty($config->fields['pwd'])) { + $key = new GLPIKey(); $migration->addPostQuery( $DB->buildUpdate( 'glpi_plugin_mantis_configs', [ - 'pwd' => Toolbox::sodiumEncrypt(Toolbox::decrypt($config->fields['pwd'])) + 'pwd' => $key->encrypt($key->decryptUsingLegacyKey($config->fields['pwd'])) ], [ 'id' => 1, @@ -308,7 +313,7 @@ static function install(Migration $migration) { ) ); } - $migration->addField($table, "is_password_sodium_encrypted", "INT(1) NOT NULL DEFAULT 1"); + $migration->addField($table, "is_password_sodium_encrypted", "INT NOT NULL DEFAULT 1"); } } diff --git a/inc/mantis.class.php b/inc/mantis.class.php index 99da413..86e6124 100644 --- a/inc/mantis.class.php +++ b/inc/mantis.class.php @@ -73,7 +73,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem if (Session::haveRightsOr('plugin_mantis_use', [READ, UPDATE])) { $PluginMantisMantis = new self(); - $PluginMantisMantis->showForm($item); + $PluginMantisMantis->showFormForItilItem($item); } else { echo "


\"warning\"

"; @@ -104,19 +104,22 @@ public static function countForItem(CommonDBTM $item) { static function install(Migration $migration) { global $DB; + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); + $table = getTableForItemType(__CLASS__); if (!$DB->tableExists($table)) { - $query = "CREATE TABLE `".$table."` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `items_id` int(11) NOT NULL, - `idMantis` int(11) NOT NULL, + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `items_id` int {$default_key_sign} NOT NULL, + `idMantis` int NOT NULL, `dateEscalade` date NOT NULL, `itemtype` varchar(255) NOT NULL, - `user` int(11) NOT NULL, + `user` int NOT NULL, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->query($query) or die($DB->error()); } else { @@ -132,7 +135,7 @@ static function install(Migration $migration) { } if ($DB->fieldExists($table, 'idTicket') && !$DB->fieldExists($table, 'items_id')) { - $migration->changeField($table, 'idTicket', 'items_id', 'integer', []); + $migration->changeField($table, 'idTicket', 'items_id', "`items_id` int {$default_key_sign} NOT NULL", []); $migration->executeMigration(); } } @@ -484,7 +487,7 @@ private static function getInfoSolved($list_ticket_mantis) { * * @param $item */ - public function showForm($item) { + public function showFormForItilItem($item) { global $CFG_GLPI; $ws = new PluginMantisMantisws(); @@ -497,7 +500,7 @@ public function showForm($item) { if ($ws->testConnectionWS($conf->getField('host'), $conf->getField('url'), $conf->getField('login'), - Toolbox::sodiumDecrypt($conf->getField('pwd')))) { + (new GLPIKey())->decrypt($conf->getField('pwd')))) { if ($item->fields['status'] == $conf->fields['neutralize_escalation'] || $item->fields['status'] > $conf->fields['neutralize_escalation']) { @@ -570,12 +573,12 @@ public function displayBtnToLinkissueGlpi($item) { echo ""; echo ""; - echo ""; echo ""; - echo ""; @@ -985,7 +988,7 @@ private function getFormForDisplayInfo($item, $itemType) { if ($can_write && !$neutralize_escalation) { echo ""; echo ""; } else { echo "-"; diff --git a/inc/mantisws.class.php b/inc/mantisws.class.php index b43fa52..5f33ab5 100644 --- a/inc/mantisws.class.php +++ b/inc/mantisws.class.php @@ -68,7 +68,7 @@ function initializeConnection() { $this->_host = $conf->fields["host"]; $this->_url = $conf->fields["url"]; $this->_login = $conf->fields["login"]; - $this->_password = Toolbox::sodiumDecrypt($conf->fields["pwd"]); + $this->_password = (new GLPIKey())->decrypt($conf->fields["pwd"]); $this->_client = new SoapClient($this->_host . "/" . $this->_url, self::getOptionsStreamContext()); return true; diff --git a/inc/profile.class.php b/inc/profile.class.php index 9153bf5..efca84c 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -106,35 +106,25 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem } - /** - * Show profile form - * - * @param $items_id integer id of the profile - * @param $target value url of target - * - * @return nothing - **/ - function showForm($profiles_id = 0, $openform = true, $closeform = true) { + function showForm($ID, array $options = []) { echo "
"; - if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) - && $openform) { + if ($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) { $profile = new Profile(); echo "
"; } $profile = new Profile(); - $profile->getFromDB($profiles_id); + $profile->getFromDB($ID); $profile->displayRightsChoiceMatrix($this->getAllRights(), ['canedit' => $canedit, 'default_class' => 'tab_bg_2', 'title' => __('General')]); - if ($canedit - && $closeform) { + if ($canedit) { echo "
"; - echo Html::hidden('id', ['value' => $profiles_id]); + echo Html::hidden('id', ['value' => $ID]); echo Html::submit(_sx('button', 'Save'), ['name' => 'update']); echo "
\n"; Html::closeForm(); diff --git a/inc/userpref.class.php b/inc/userpref.class.php index 4375822..868a4d5 100644 --- a/inc/userpref.class.php +++ b/inc/userpref.class.php @@ -42,18 +42,24 @@ class PluginMantisUserpref extends CommonDBTM { static function install($migration) { global $DB; + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); + if (!$DB->tableExists("glpi_plugin_mantis_userprefs")) { $query = "CREATE TABLE `glpi_plugin_mantis_userprefs` ( - `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, - `users_id` int(11) NOT NULL , - `followTask` int(11) NOT NULL default '0', - `followFollow` int(11) NOT NULL default '0', - `followAttachment` int(11) NOT NULL default '0', - `followTitle` int(11) NOT NULL default '0', - `followDescription` int(11) NOT NULL default '0', - `followCategorie` int(11) NOT NULL default '0', - `followLinkedItem` int(11) NOT NULL default '0', - UNIQUE KEY (`users_id`))"; + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `users_id` int {$default_key_sign} NOT NULL , + `followTask` int NOT NULL default '0', + `followFollow` int NOT NULL default '0', + `followAttachment` int NOT NULL default '0', + `followTitle` int NOT NULL default '0', + `followDescription` int NOT NULL default '0', + `followCategorie` int NOT NULL default '0', + `followLinkedItem` int NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY (`users_id`) + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->query($query) or die($DB->error()); } } diff --git a/setup.php b/setup.php index 0484044..93a6df5 100644 --- a/setup.php +++ b/setup.php @@ -31,9 +31,9 @@ define("PLUGIN_MANTIS_VERSION", "4.4.1"); // Minimal GLPI version, inclusive -define("PLUGIN_MANTIS_MIN_GLPI", "9.5"); +define("PLUGIN_MANTIS_MIN_GLPI", "10.0.0"); // Maximum GLPI version, exclusive -define("PLUGIN_MANTIS_MAX_GLPI", "9.6"); +define("PLUGIN_MANTIS_MAX_GLPI", "10.0.99"); /** * function to initialize the plugin