[1.0.x] mosparo Integration

Created on 3 February 2024, 5 months ago
Updated 17 June 2024, 8 days ago

About mosparo

mosparo is an accessible and free-to-use open-source spam protection software for web forms. Instead of trying to decide between humans and robots, mosparo scans the data the user entered into the form. Based on the rules, mosparo can decide if the form data contains spam. mosparo is a standalone software that a user must install on its web hosting. More info can be found on mosparo.io.

About the mosparo Integration

Like other spam protection methods (for example, reCAPTCHA), the method must be integrated into the form it should protect. The mosparo checkbox must be added to the frontend to protect a form. When the user submits the form, the submission must be verified with the mosparo API.

This module will handle both of these steps. It offers a custom field type for the Contact or the Webform module. The module is also compatible with the CAPTCHA module by simply offering an alternative to the available CAPTCHA types in the CAPTCHA module.

As soon as a form is submitted, the mosparo Integration module will verify the data with the API of mosparo. If everything is okay, the form submission can be processed by the normal submit process (sending the email, storing the data, executing the registration or the login process, and so on).

The module is split into three submodules so that the user can enable only the required submodules (for example, the CAPTCHA submodule if the user wants to use mosparo with the CAPTCHA module).

Project link

https://www.drupal.org/project/mosparo_integration →

📌 Task
Status

Fixed

Component

module

Created by

🇨🇭Switzerland zepich

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @zepich
  • 🇮🇳India rushiraval

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review → gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,>DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status will not be changed by this application; no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the branch to review and the project name.

    To the reviewers

    Please read How to review security advisory coverage applications → , Application workflow → , What to cover in an application review → , and Tools to use for reviews → .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications, even to leave a comment similar to the following one. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • It is also preferable to wait before using a CLI tool → to report what needs to be changed, especially because the comment left from Code Review Administrators suggests to use PHP_CodeSniffer. Before that, manual reviews should be done.
    • Reviewers should not copy-paste the output of a CLI tool. They should use a CLI tool only once per application. When they do that, they should later verify the code has been correctly changed; this means, for example, that adding a documentation comment that is not correct just to avoid to get a warning/error is not a correct change that should be reported in a further comment.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues → .

  • Status changed to Needs work 5 months ago
  • 🇮🇳India rushiraval

    Fix phpcs issues.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml mosparo_integration/

    FILE: mosparo_integration/mosparo_integration.info.yml
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
    1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/modules/mosparo_webform/mosparo_webform.info.yml
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -------------------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/modules/mosparo_contact/mosparo_contact.info.yml
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -------------------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/modules/mosparo_contact/src/Plugin/Field/FieldType/MosparoItem.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemBase.
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/modules/mosparo_contact/src/Plugin/Field/FieldWidget/MosparoWidget.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------
    33 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    34 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -------------------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/modules/mosparo_captcha/mosparo_captcha.info.yml
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -------------------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/src/Form/MosparoConnectionForm.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityForm.
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------

    FILE: mosparo_integration/src/Service/MosparoService.php
    ------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------
    116 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------------------

    FILE: .mosparo_integration/tests/src/Unit/Controller/MosparoConnectionListBuilderTest.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
    | | Drupal\Core\Entity\EntityStorageInterface.
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------

    FILE: .mosparo_integration/tests/src/Unit/Service/MosparoServiceTest.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    23 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Tests\UnitTestCase.
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------

  • 🇨🇭Switzerland zepich

    Hi @rushikesh-raval

    Thank you very much for your feedback.

    Which version have you tested? All the things you found are fixed in the latest commit (https://git.drupalcode.org/project/mosparo_integration/-/tree/483264de07...) (but not in the Beta version from last year).

    You can also see the phpcs result in the GitLab CI build from last Sunday: https://git.drupalcode.org/project/mosparo_integration/-/jobs/744569

    Kind reagrds,

    zepich

  • Status changed to Needs review 5 months ago
  • 🇨🇭Switzerland zepich
  • 🇮🇳India rushiraval

    Sorry, Its my mistake I have check on beta version instead of dev. I found there is not phpcs error in dev Version.

  • 🇮🇳India rushiraval

    I am changing the issue priority as per issue priorities → .

  • Status changed to Needs work about 1 month ago
  • When you call $ids = $this->entityStorage->getQuery()->execute();, you should add a call to checkAccess

    Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. See https://www.drupal.org/node/3201242 →

    ESLint:

    js/mosparo_integration.frontend.js
      11:87  error  Insert `,`  prettier/prettier
      34:48  error  Insert `,`  prettier/prettier
      40:8   error  Insert `,`  prettier/prettier
    
  • 🇮🇳India vishal.kadam Mumbai

    1. FILE: mosparo_integration.libraries.yml

    version: VERSION

    FILE: modules/mosparo_captcha/mosparo_captcha.libraries.yml

    version: VERSION

    VERSION is only used by Drupal core modules. Contributed modules should use a literal string that does not change with the Drupal core version a site is using.

    2. FILE: src/Event/MosparoIntegrationFilterFieldTypesEvent.php

      /**
       * Constructs the object.
       *
       * @param array $ignoredFieldTypes
       *   The list of ignored field types.
       * @param array $verifiableFieldTypes
       *   The list of verifiable field types.
       */
      public function __construct(array $ignoredFieldTypes, array $verifiableFieldTypes) {

    FILE: src/Event/MosparoIntegrationFilterFormDataEvent.php

      /**
       * Constructs the object.
       *
       * @param array $formData
       *   The form data as array.
       * @param array $requiredFields
       *   List of keys of the required fields.
       * @param array $verifiableFields
       *   List of keys of the verifiable fields.
       */
      public function __construct(array $formData, array $requiredFields, array $verifiableFields) {

    FILE: src/Form/MosparoConnectionForm.php

      /**
       * Constructs the form.
       *
       * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
       *   The entity type manager.
       */
      public function __construct(EntityTypeManagerInterface $entityTypeManager) {

    FILE: src/Form/MosparoConnectionForm.php

      /**
       * Constructs the form.
       *
       * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
       *   The entity type manager.
       */
      public function __construct(EntityTypeManagerInterface $entityTypeManager) {

    FILE: modules/mosparo_webform/src/Plugin/WebformElement/MosparoElement.php

      /**
       * {@inheritdoc}
       */
      public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

    3. FILE: modules/mosparo_contact/mosparo_contact.module

    /**
     * Validates the form.
     *
     */
    function mosparo_contact_form_validate(array $form, FormStateInterface &$form_state, MosparoConnectionInterface $connection, MosparoWidget $widget) {
    /**
     * Drupal hook: hook_help()
     */
    function mosparo_contact_help($route_name, RouteMatchInterface $route_match) {

    FILE: modules/mosparo_webform/mosparo_webform.module

    /**
     * Drupal hook: hook_help()
     */
    function mosparo_webform_help($route_name, RouteMatchInterface $route_match) {

    When implementing a hook, use a short summary of the form "Implements hook_menu().". Omit the parameter and return value documentation in this case.

  • 🇨🇭Switzerland zepich

    Hi @solideogloria

    Thank you very much for your feedback!

    accessCheck

    Thank you very much. I've missed some occurrences before and have now adjusted all the queries.

    eslint result

    Thank you very much. Unfortunately, this is an issue of the Eslint ruleset since Eslint thinks these three lines are arrays/objects, and we have to add a comma at the end. But in reality, these three issues are multi-line function calls. Adding a comma at the end will break the function.

    I've eliminated one of the lines by creating a constant, but I don't see any option to solve the others. If you have an idea, please let me know.

    MosparoService interface

    As suggested, I've added an interface and replaced all the type hints with the interface.

    Kind regards,

    zepich

  • Status changed to Needs review 27 days ago
  • 🇨🇭Switzerland zepich

    Hi @vishal.kadam

    Thank you very much for your review.

    1. VERSION

    I've replaced the VERSION constant with our version number.

    2. Constructor documentation comments

    I removed the constructor documentation comments since they're not mandatory.

    3. Hook documentation comments

    I've adjusted the comments for the hooks.

    One of the hooks you listed was not a hook but a normal function. I've moved this functionality into the object where we used it since there is no reason to have it in a separate function. With that, we were additionally able to eliminate one \Drupal call.

    Kind regards,

    zepich

  • Status changed to RTBC 27 days ago
  • 🇮🇳India vishal.kadam Mumbai

    Rest looks fine to me.

    Let’s wait for a Code Review Administrator to take a look and if everything goes fine, you will get the role.

  • Status changed to Fixed 24 days ago
  • 🇦🇹Austria klausi 🇦🇹 Vienna
    1. mosparo_integration_uninstall(): this should not be necessary, uninstalling a module already clears all caches.
    2. modules/mosparo_contact/config/mosparo_contact.schema.yml: this should be in the schema subfolder, right?

    Otherwise looks good to me.

    Thanks for your contribution, Matthias!

    I updated your account so you can opt into security advisory coverage now.

    Here are some recommended readings to help with excellent maintainership:

    You can find lots more contributors chatting on Slack → or IRC → in #drupal-contribute. So, come hang out and stay involved → !

    Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review → . I encourage you to learn more about that process and join the group of reviewers.

    Thanks to the dedicated reviewer(s) as well.

  • 🇨🇭Switzerland zepich

    Thank you all for your review, feedback, and help to improve the module!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024