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).
Comments
Comment #2
rushikesh raval commentedThank 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.
phpcs --standard=Drupal,>DrupalPracticeon the project, which alone fixes most of what reviewers would report.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.
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.
Comment #3
rushikesh raval commentedFix 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
-------------------------------------------------------------------------------------------------------------------------
Comment #4
zepich commentedHi @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
Comment #5
zepich commentedComment #6
rushikesh raval commentedSorry, Its my mistake I have check on beta version instead of dev. I found there is no phpcs error in dev Version.
Comment #7
rushikesh raval commentedI am changing the issue priority as per issue priorities.
Comment #8
solideogloria commentedWhen you call
$ids = $this->entityStorage->getQuery()->execute();, you should add a call tocheckAccessRelying 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:
Also, MosparoService should have a corresponding MosparoServiceInterface class and anything injecting the service should have a type hint for the interface instead of the service class, so that your service can be easily extended by other modules or custom code.
Comment #9
vishal.kadam1. FILE: mosparo_integration.libraries.yml
version: VERSIONFILE: modules/mosparo_captcha/mosparo_captcha.libraries.yml
version: VERSIONVERSION 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
FILE: src/Event/MosparoIntegrationFilterFormDataEvent.php
FILE: src/Form/MosparoConnectionForm.php
FILE: src/Form/MosparoConnectionForm.php
FILE: modules/mosparo_webform/src/Plugin/WebformElement/MosparoElement.php
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
FILE: modules/mosparo_webform/mosparo_webform.module
When implementing a hook, use a short summary of the form "Implements hook_menu().". Omit the parameter and return value documentation in this case.
Comment #10
zepich commentedHi @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
Comment #11
zepich commentedHi @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
\Drupalcall.Kind regards,
zepich
Comment #12
vishal.kadamRest 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.
Comment #13
klausiOtherwise 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.
Comment #14
zepich commentedThank you all for your review, feedback, and help to improve the module!