diff --git a/ReCaptchaAdminUi/Block/Adminhtml/System/Config/Form/Field/Notice.php b/ReCaptchaAdminUi/Block/Adminhtml/System/Config/Form/Field/Notice.php new file mode 100644 index 00000000..9a3b6032 --- /dev/null +++ b/ReCaptchaAdminUi/Block/Adminhtml/System/Config/Form/Field/Notice.php @@ -0,0 +1,34 @@ +

' . '' . __('Important:') + . ' ' . '' . ' ' . __('Please note, for reCAPTCHA to be enabled, + the valid "Google API Website Key" and "Google API Secret Key" fields are required.') . '' . '

'; + + return $this->_decorateRowHtml($element, $html); + } +} diff --git a/ReCaptchaAdminUi/composer.json b/ReCaptchaAdminUi/composer.json index 005a9b9a..607ae8a9 100644 --- a/ReCaptchaAdminUi/composer.json +++ b/ReCaptchaAdminUi/composer.json @@ -2,8 +2,9 @@ "name": "magento/module-re-captcha-admin-ui", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", + "magento/module-config": "*", "magento/module-re-captcha-ui": "*" }, "type": "magento2-module", diff --git a/ReCaptchaAdminUi/etc/adminhtml/system.xml b/ReCaptchaAdminUi/etc/adminhtml/system.xml index 5666470f..f3cfdea0 100644 --- a/ReCaptchaAdminUi/etc/adminhtml/system.xml +++ b/ReCaptchaAdminUi/etc/adminhtml/system.xml @@ -22,6 +22,10 @@ + + Magento\ReCaptchaAdminUi\Block\Adminhtml\System\Config\Form\Field\Notice + @@ -35,6 +39,10 @@ + + Magento\ReCaptchaAdminUi\Block\Adminhtml\System\Config\Form\Field\Notice + diff --git a/ReCaptchaAdminUi/view/adminhtml/web/css/source/_module.less b/ReCaptchaAdminUi/view/adminhtml/web/css/source/_module.less new file mode 100644 index 00000000..d4623ef1 --- /dev/null +++ b/ReCaptchaAdminUi/view/adminhtml/web/css/source/_module.less @@ -0,0 +1,10 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +.recaptcha_backend_type_for_recaptcha_backend_info_heading_notice, +.recaptcha_frontend_type_for_recaptcha_frontend_info_heading_notice { + strong { + color: @grid-severity-critical-color; + } +} diff --git a/ReCaptchaCheckout/composer.json b/ReCaptchaCheckout/composer.json index 33c10ffc..1b394307 100644 --- a/ReCaptchaCheckout/composer.json +++ b/ReCaptchaCheckout/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-checkout", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-checkout": "*", "magento/module-re-captcha-ui": "*" diff --git a/ReCaptchaContact/Test/Integration/ContactFormTest.php b/ReCaptchaContact/Test/Integration/ContactFormTest.php index ffa6b2fc..9e963fc8 100644 --- a/ReCaptchaContact/Test/Integration/ContactFormTest.php +++ b/ReCaptchaContact/Test/Integration/ContactFormTest.php @@ -178,8 +178,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? self::assertContains('field-recaptcha', $content) - : self::assertNotContains('field-recaptcha', $content); + ? self::assertStringContainsString('field-recaptcha', $content) + : self::assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } @@ -193,7 +193,7 @@ private function checkSuccessfulPostResponse(array $postValues = []): void $this->makePostRequest($postValues); $this->assertSessionMessages( - self::contains( + self::containsEqual( "Thanks for contacting us with your comments and questions. We'll respond to you very soon." ), MessageInterface::TYPE_SUCCESS diff --git a/ReCaptchaContact/composer.json b/ReCaptchaContact/composer.json index 1e25f817..0abcf099 100644 --- a/ReCaptchaContact/composer.json +++ b/ReCaptchaContact/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-contact", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-ui": "*" }, diff --git a/ReCaptchaCustomer/Test/Integration/AjaxLoginFormTest.php b/ReCaptchaCustomer/Test/Integration/AjaxLoginFormTest.php index 79e97200..7a65d351 100644 --- a/ReCaptchaCustomer/Test/Integration/AjaxLoginFormTest.php +++ b/ReCaptchaCustomer/Test/Integration/AjaxLoginFormTest.php @@ -18,7 +18,7 @@ use Magento\TestFramework\App\MutableScopeConfig; use Magento\TestFramework\TestCase\AbstractController; use PHPUnit\Framework\MockObject\MockObject; -use Zend\Http\Headers; +use Laminas\Http\Headers; /** * @magentoDataFixture Magento/Customer/_files/customer.php @@ -188,8 +188,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? $this->assertContains('recaptcha-popup-login', $content) - : $this->assertNotContains('recaptcha-popup-login', $content); + ? $this->assertStringContainsString('recaptcha-popup-login', $content) + : $this->assertStringNotContainsString('recaptcha-popup-login', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } diff --git a/ReCaptchaCustomer/Test/Integration/CreateCustomerFormTest.php b/ReCaptchaCustomer/Test/Integration/CreateCustomerFormTest.php index 3155ca6e..d453cd16 100644 --- a/ReCaptchaCustomer/Test/Integration/CreateCustomerFormTest.php +++ b/ReCaptchaCustomer/Test/Integration/CreateCustomerFormTest.php @@ -25,6 +25,7 @@ /** * @magentoAppArea frontend * @magentoAppIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CreateCustomerFormTest extends AbstractController { @@ -201,8 +202,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? $this->assertContains('field-recaptcha', $content) - : $this->assertNotContains('field-recaptcha', $content); + ? $this->assertStringContainsString('field-recaptcha', $content) + : $this->assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } diff --git a/ReCaptchaCustomer/Test/Integration/ForgotPasswordFormTest.php b/ReCaptchaCustomer/Test/Integration/ForgotPasswordFormTest.php index 55d40b15..59265f51 100644 --- a/ReCaptchaCustomer/Test/Integration/ForgotPasswordFormTest.php +++ b/ReCaptchaCustomer/Test/Integration/ForgotPasswordFormTest.php @@ -195,8 +195,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? $this->assertContains('field-recaptcha', $content) - : $this->assertNotContains('field-recaptcha', $content); + ? $this->assertStringContainsString('field-recaptcha', $content) + : $this->assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } diff --git a/ReCaptchaCustomer/Test/Integration/LoginFromTest.php b/ReCaptchaCustomer/Test/Integration/LoginFromTest.php index 5f31ed30..e5a61344 100644 --- a/ReCaptchaCustomer/Test/Integration/LoginFromTest.php +++ b/ReCaptchaCustomer/Test/Integration/LoginFromTest.php @@ -195,8 +195,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? $this->assertContains('field-recaptcha', $content) - : $this->assertNotContains('field-recaptcha', $content); + ? $this->assertStringContainsString('field-recaptcha', $content) + : $this->assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } diff --git a/ReCaptchaCustomer/composer.json b/ReCaptchaCustomer/composer.json index c7df22e4..c189e6e3 100644 --- a/ReCaptchaCustomer/composer.json +++ b/ReCaptchaCustomer/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-customer", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-customer": "*", "magento/module-re-captcha-ui": "*", diff --git a/ReCaptchaFrontendUi/composer.json b/ReCaptchaFrontendUi/composer.json index 102a88c2..32c73d88 100644 --- a/ReCaptchaFrontendUi/composer.json +++ b/ReCaptchaFrontendUi/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-frontend-ui", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-store": "*", "magento/module-re-captcha-ui": "*" diff --git a/ReCaptchaMigration/composer.json b/ReCaptchaMigration/composer.json index 40b3277a..9c122161 100644 --- a/ReCaptchaMigration/composer.json +++ b/ReCaptchaMigration/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-migration", "description": "Google reCAPTCHA config migration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-config": "*" }, diff --git a/ReCaptchaNewsletter/Test/Integration/NewsletterFormTest.php b/ReCaptchaNewsletter/Test/Integration/NewsletterFormTest.php index 3eef2a76..ad496c47 100644 --- a/ReCaptchaNewsletter/Test/Integration/NewsletterFormTest.php +++ b/ReCaptchaNewsletter/Test/Integration/NewsletterFormTest.php @@ -54,7 +54,7 @@ class NewsletterFormTest extends AbstractController /** * @inheritDoc */ - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->mutableScopeConfig = $this->_objectManager->get(MutableScopeConfig::class); @@ -192,8 +192,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? self::assertContains('field-recaptcha', $content) - : self::assertNotContains('field-recaptcha', $content); + ? self::assertStringContainsString('field-recaptcha', $content) + : self::assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } @@ -207,7 +207,7 @@ private function checkSuccessfulPostResponse(array $postValues = []): void $this->makePostRequest($postValues); $this->assertSessionMessages( - self::contains( + self::containsEqual( 'Thank you for your subscription.' ), MessageInterface::TYPE_SUCCESS diff --git a/ReCaptchaNewsletter/composer.json b/ReCaptchaNewsletter/composer.json index c70c2f0a..108ad049 100644 --- a/ReCaptchaNewsletter/composer.json +++ b/ReCaptchaNewsletter/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-newsletter", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-ui": "*" }, diff --git a/ReCaptchaPaypal/composer.json b/ReCaptchaPaypal/composer.json index 4429c6ed..640a2b93 100644 --- a/ReCaptchaPaypal/composer.json +++ b/ReCaptchaPaypal/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-paypal", "description": "Google reCaptcha integration for Magento2 PayPal PayflowPro payment form", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-ui": "*", "magento/module-re-captcha-validation-api": "*", diff --git a/ReCaptchaReview/Test/Integration/ReviewFormTest.php b/ReCaptchaReview/Test/Integration/ReviewFormTest.php index 0eb4c2a1..a7cbe8e3 100644 --- a/ReCaptchaReview/Test/Integration/ReviewFormTest.php +++ b/ReCaptchaReview/Test/Integration/ReviewFormTest.php @@ -188,8 +188,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? self::assertContains('field-recaptcha', $content) - : self::assertNotContains('field-recaptcha', $content); + ? self::assertStringContainsString('field-recaptcha', $content) + : self::assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } @@ -203,7 +203,7 @@ private function checkSuccessfulPostResponse(array $postValues = []): void $this->makePostRequest($postValues); $this->assertSessionMessages( - self::contains( + self::containsEqual( 'You submitted your review for moderation.' ), MessageInterface::TYPE_SUCCESS diff --git a/ReCaptchaReview/composer.json b/ReCaptchaReview/composer.json index 73d8795c..be9bc922 100644 --- a/ReCaptchaReview/composer.json +++ b/ReCaptchaReview/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-review", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-ui": "*" }, diff --git a/ReCaptchaSendFriend/Test/Integration/SendFriendFormTest.php b/ReCaptchaSendFriend/Test/Integration/SendFriendFormTest.php index adab3eab..e87f9faf 100644 --- a/ReCaptchaSendFriend/Test/Integration/SendFriendFormTest.php +++ b/ReCaptchaSendFriend/Test/Integration/SendFriendFormTest.php @@ -211,8 +211,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? self::assertContains('field-recaptcha', $content) - : self::assertNotContains('field-recaptcha', $content); + ? self::assertStringContainsString('field-recaptcha', $content) + : self::assertStringNotContainsString('field-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } @@ -226,7 +226,7 @@ private function checkSuccessfulPostResponse(array $postValues = []): void $this->makePostRequest($postValues); $this->assertSessionMessages( - self::contains( + self::containsEqual( 'The link to a friend was sent.' ), MessageInterface::TYPE_SUCCESS diff --git a/ReCaptchaSendFriend/composer.json b/ReCaptchaSendFriend/composer.json index 68f59315..fa7a0eb4 100644 --- a/ReCaptchaSendFriend/composer.json +++ b/ReCaptchaSendFriend/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-send-friend", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-ui": "*" }, diff --git a/ReCaptchaUi/composer.json b/ReCaptchaUi/composer.json index 3ad26a8c..2f0e4b81 100644 --- a/ReCaptchaUi/composer.json +++ b/ReCaptchaUi/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-ui", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-validation-api": "*" }, diff --git a/ReCaptchaUser/Test/Integration/ForgotPasswordFormTest.php b/ReCaptchaUser/Test/Integration/ForgotPasswordFormTest.php index d7af7752..3ae29679 100644 --- a/ReCaptchaUser/Test/Integration/ForgotPasswordFormTest.php +++ b/ReCaptchaUser/Test/Integration/ForgotPasswordFormTest.php @@ -172,8 +172,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? $this->assertContains('admin-recaptcha', $content) - : $this->assertNotContains('admin-recaptcha', $content); + ? $this->assertStringContainsString('admin-recaptcha', $content) + : $this->assertStringNotContainsString('admin-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } diff --git a/ReCaptchaUser/Test/Integration/LoginFormTest.php b/ReCaptchaUser/Test/Integration/LoginFormTest.php index bc136d96..8595c861 100644 --- a/ReCaptchaUser/Test/Integration/LoginFormTest.php +++ b/ReCaptchaUser/Test/Integration/LoginFormTest.php @@ -184,8 +184,8 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo self::assertNotEmpty($content); $shouldContainReCaptcha - ? $this->assertContains('admin-recaptcha', $content) - : $this->assertNotContains('admin-recaptcha', $content); + ? $this->assertStringContainsString('admin-recaptcha', $content) + : $this->assertStringNotContainsString('admin-recaptcha', $content); self::assertEmpty($this->getSessionMessages(MessageInterface::TYPE_ERROR)); } diff --git a/ReCaptchaUser/composer.json b/ReCaptchaUser/composer.json index 8dfff32b..4225a716 100644 --- a/ReCaptchaUser/composer.json +++ b/ReCaptchaUser/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-user", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-ui": "*", "magento/module-re-captcha-validation-api": "*" diff --git a/ReCaptchaUser/etc/adminhtml/system.xml b/ReCaptchaUser/etc/adminhtml/system.xml index e90f4d4a..8bb4d234 100644 --- a/ReCaptchaUser/etc/adminhtml/system.xml +++ b/ReCaptchaUser/etc/adminhtml/system.xml @@ -10,13 +10,13 @@
- Magento\ReCaptchaAdminUi\Model\OptionSource\Type - Magento\ReCaptchaAdminUi\Model\OptionSource\Type diff --git a/ReCaptchaValidation/composer.json b/ReCaptchaValidation/composer.json index 3a76b6c9..27557ec4 100644 --- a/ReCaptchaValidation/composer.json +++ b/ReCaptchaValidation/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-validation", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-re-captcha-validation-api": "*", "google/recaptcha": "^1.2" diff --git a/ReCaptchaValidationApi/composer.json b/ReCaptchaValidationApi/composer.json index c06f316c..137541b4 100644 --- a/ReCaptchaValidationApi/composer.json +++ b/ReCaptchaValidationApi/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-validation-api", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*" }, "type": "magento2-module", diff --git a/ReCaptchaVersion2Checkbox/composer.json b/ReCaptchaVersion2Checkbox/composer.json index 8acd468d..a565558c 100644 --- a/ReCaptchaVersion2Checkbox/composer.json +++ b/ReCaptchaVersion2Checkbox/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-version-2-checkbox", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-store": "*", "magento/module-re-captcha-ui": "*", diff --git a/ReCaptchaVersion2Invisible/composer.json b/ReCaptchaVersion2Invisible/composer.json index 5f95f3b5..b3089652 100644 --- a/ReCaptchaVersion2Invisible/composer.json +++ b/ReCaptchaVersion2Invisible/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-version-2-invisible", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-store": "*", "magento/module-re-captcha-ui": "*", diff --git a/ReCaptchaVersion3Invisible/composer.json b/ReCaptchaVersion3Invisible/composer.json index 3a39ea00..204d10fd 100644 --- a/ReCaptchaVersion3Invisible/composer.json +++ b/ReCaptchaVersion3Invisible/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-re-captcha-version-3-invisible", "description": "Google reCAPTCHA integration for Magento2", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-store": "*", "magento/module-re-captcha-ui": "*", diff --git a/Securitytxt/Model/Config/Backend/SecureUrl.php b/Securitytxt/Model/Config/Backend/SecureUrl.php new file mode 100644 index 00000000..50e6bd71 --- /dev/null +++ b/Securitytxt/Model/Config/Backend/SecureUrl.php @@ -0,0 +1,36 @@ +getValue(); + // phpcs:ignore Magento2.Functions.DiscouragedFunction + $isValid = parse_url($url, PHP_URL_SCHEME) === 'https'; + if (!$isValid && $url !== '') { + throw new ValidatorException( + __('URL should be in correct format and must start with HTTPS.') + ); + } + return $this; + } +} diff --git a/Securitytxt/Model/Config/Backend/Validate.php b/Securitytxt/Model/Config/Backend/Validate.php deleted file mode 100644 index 30e78bcf..00000000 --- a/Securitytxt/Model/Config/Backend/Validate.php +++ /dev/null @@ -1,126 +0,0 @@ -getPath()); - $sectionName = reset($sectionPathString); - - if ($sectionName !== Config::XML_SECURITYTXT_MODULE || $this->getData('group_id') !== 'contact_information') { - return parent::validateBeforeSave(); - } - - $dataGroup = $this->getData()['groups']; - $contactInformationFields = $dataGroup['contact_information']['fields']; - $otherInformationFields = $dataGroup['other_information']['fields']; - $isExtensionEnabled = (bool)$dataGroup['general']['fields']['enabled']['value']; - $contactEmail = $contactInformationFields['email']['value']; - $contactPhone = $contactInformationFields['phone']['value']; - $contactWebPage = $contactInformationFields['contact_page']['value']; - - if ($isExtensionEnabled) { - if ($contactEmail === '' && $contactPhone === '' && $contactWebPage === '') { - throw new ValidatorException(__('At least one contact information is required.')); - } - } else { - return parent::validateBeforeSave(); - } - - $this->validateContactEmail($contactEmail); - $this->validateContactWebpageUrl($contactWebPage); - $this->validateUrlField("Contact Page URL", $contactWebPage); - $this->validateUrlField("Encryption URL", $otherInformationFields['encryption']['value']); - $this->validateUrlField("Acknowledgements URL", $otherInformationFields['acknowledgements']['value']); - $this->validateUrlField("Hiring URL", $otherInformationFields['hiring']['value']); - $this->validateUrlField("Policy URL", $otherInformationFields['policy']['value']); - - return parent::validateBeforeSave(); - } - - /** - * Validate url value to be secure. - * - * @param string $url - * @return bool - */ - private function validateSecureUrl(string $url): bool - { - $url = filter_var($url, FILTER_SANITIZE_STRING); - // phpcs:ignore Magento2.Functions.DiscouragedFunction - if (parse_url($url, PHP_URL_SCHEME) === 'https' && filter_var($url, FILTER_VALIDATE_URL)) { - return true; - } - - return false; - } - - /** - * Validate contact email configuration field. - * - * @param string $contactEmail - * @return void - * @throws ValidatorException - */ - private function validateContactEmail(string $contactEmail): void - { - if ($contactEmail !== '' && !filter_var($contactEmail, FILTER_VALIDATE_EMAIL)) { - throw new ValidatorException( - __('Contact Information: Email validation failed. Please enter in correct format.') - ); - } - } - - /** - * Validate contact web page configuration field. - * - * @param string $contactWebpage - * @return void - * @throws ValidatorException - */ - private function validateContactWebpageUrl(string $contactWebpage): void - { - if ($contactWebpage !== '' && !$this->validateSecureUrl($contactWebpage)) { - throw new ValidatorException( - __('Contact Information: Contact Page URL should be in correct format and must start with HTTPS.') - ); - } - } - - /** - * Validate Security.txt configuration field containing url. - * - * @param string $fieldName - * @param string $fieldValue - * @throws ValidatorException - */ - private function validateUrlField(string $fieldName, string $fieldValue): void - { - if ($fieldValue !== '' && !$this->validateSecureUrl($fieldValue)) { - throw new ValidatorException( - __('Other Information: %1 should be in correct format and must start with HTTPS.', $fieldName) - ); - } - } -} diff --git a/Securitytxt/Model/Config/Signature.php b/Securitytxt/Model/Config/Signature.php index 4b604ae3..a9d62d31 100644 --- a/Securitytxt/Model/Config/Signature.php +++ b/Securitytxt/Model/Config/Signature.php @@ -3,18 +3,40 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\Securitytxt\Model\Config; use Magento\Config\Model\Config\CommentInterface; +use Magento\Framework\Escaper; /** * Signature field description */ class Signature implements CommentInterface { + /** + * @var string + */ + private $instructionLink; + + /** + * @var Escaper + */ + private $escaper; + + /** + * @param Escaper $escaper + * @param string $instructionLink + */ + public function __construct( + Escaper $escaper, + string $instructionLink = '' + ) { + $this->escaper = $escaper; + $this->instructionLink = $instructionLink; + } + /** * Get comment for signature field of security txt extension. * @@ -24,8 +46,13 @@ class Signature implements CommentInterface */ public function getCommentText($elementValue): string { - return " - Read instructions on how to generate signature - "; + if ($this->instructionLink === '') { + return ''; + } + return sprintf( + "%s", + $this->escaper->escapeUrl($this->instructionLink), + __('Read instructions on how to generate signature') + ); } } diff --git a/Securitytxt/composer.json b/Securitytxt/composer.json index 4a22e423..a0761449 100644 --- a/Securitytxt/composer.json +++ b/Securitytxt/composer.json @@ -3,7 +3,7 @@ "description": "Security.txt file for Magento 2 websites", "type": "magento2-module", "require": { - "php": "~7.1.3||~7.2.0||~7.3.0", + "php": "~7.3.0||~7.4.0", "magento/framework": "*", "magento/module-config": "*", "magento/module-store": "*" diff --git a/Securitytxt/etc/adminhtml/system.xml b/Securitytxt/etc/adminhtml/system.xml index c636be88..08474520 100644 --- a/Securitytxt/etc/adminhtml/system.xml +++ b/Securitytxt/etc/adminhtml/system.xml @@ -12,82 +12,91 @@
+ showInWebsite="1" showInStore="0"> separator-top security Magento_Securitytxt::config + showInStore="0"> + showInStore="0"> Magento\Config\Model\Config\Source\Yesno + showInStore="0"> + showInWebsite="1" showInStore="0"> validate-email - Magento\Securitytxt\Model\Config\Backend\Validate + showInWebsite="1" showInStore="0"> + showInWebsite="1" showInStore="0"> validate-url validate-no-html-tags + Magento\Securitytxt\Model\Config\Backend\SecureUrl Example: https://example.com/security-contact.html + + 1 + + showInStore="0"> + showInWebsite="1" showInStore="0" > validate-url validate-no-html-tags Example: https://example.com/pgp-key.txt + Magento\Securitytxt\Model\Config\Backend\SecureUrl + showInWebsite="1" showInStore="0"> validate-url validate-no-html-tags Example: https://example.com/hall-of-fame.html + Magento\Securitytxt\Model\Config\Backend\SecureUrl + showInWebsite="1" showInStore="0"> validate-text validate-no-html-tags Example: en, es, hi, de, fr + showInWebsite="1" showInStore="0"> validate-url validate-no-html-tags Example: https://example.com/jobs.html + Magento\Securitytxt\Model\Config\Backend\SecureUrl + showInWebsite="1" showInStore="0"> validate-url validate-no-html-tags - Example: https://example.com/security-policy.html + Magento\Securitytxt\Model\Config\Backend\SecureUrl + showInWebsite="1" showInStore="0"> validate-no-html-tags + + 1 +
- \ No newline at end of file + diff --git a/Securitytxt/etc/config.xml b/Securitytxt/etc/config.xml new file mode 100644 index 00000000..c2b3a47a --- /dev/null +++ b/Securitytxt/etc/config.xml @@ -0,0 +1,17 @@ + + + + + + + https://magento.com/security + + + + diff --git a/Securitytxt/etc/di.xml b/Securitytxt/etc/di.xml index 19d2a5d1..4c44f1e2 100644 --- a/Securitytxt/etc/di.xml +++ b/Securitytxt/etc/di.xml @@ -22,4 +22,11 @@ securitytxtResultPageFactory - \ No newline at end of file + + + + https://github.com/magento/security-package/blob/1.0-develop/Securitytxt/README.md + + + + diff --git a/Securitytxt/i18n/en_US.csv b/Securitytxt/i18n/en_US.csv index e3062d2c..662e7015 100644 --- a/Securitytxt/i18n/en_US.csv +++ b/Securitytxt/i18n/en_US.csv @@ -25,5 +25,5 @@ Preferred-Languages,Preferred-Languages Hiring,Hiring "Example: https://example.com/jobs.html","Example: https://example.com/jobs.html" Policy,Policy -"Example: https://example.com/security-policy.html","Example: https://example.com/security-policy.html" -Signature,Signature \ No newline at end of file +Signature,Signature +"Read instructions on how to generate signature","Read instructions on how to generate signature" diff --git a/TwoFactorAuth/Model/AdminAccessTokenService.php b/TwoFactorAuth/Model/AdminAccessTokenService.php index bac1f3a0..007878a0 100644 --- a/TwoFactorAuth/Model/AdminAccessTokenService.php +++ b/TwoFactorAuth/Model/AdminAccessTokenService.php @@ -90,16 +90,16 @@ public function createAdminAccessToken($username, $password): string } if (!$this->configRequestManager->isConfigurationRequiredFor($userId)) { - // @codingStandardsIgnoreStart throw new LocalizedException( - __( + // phpcs:ignore Magento2.Functions.DiscouragedFunction + call_user_func( + '__', 'Please use the 2fa provider-specific endpoints to obtain a token.', [ 'active_providers' => $activeProviderCodes ] ) ); - // @codingStandardsIgnoreEnd } elseif (empty($this->tfa->getUserProviders($userId))) { // It is expected that available 2fa providers are selected via db or admin ui throw new LocalizedException( @@ -116,7 +116,9 @@ public function createAdminAccessToken($username, $password): string } throw new LocalizedException( - __( + // phpcs:ignore Magento2.Functions.DiscouragedFunction + call_user_func( + '__', 'You are required to configure personal Two-Factor Authorization in order to login. ' . 'Please check your email.', [