Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jan 2021 at 02:38 UTC
Updated:
27 Feb 2021 at 09:09 UTC
Jump to comment: Most recent
Comments
Comment #2
ntturner commentedLooking good! After reviewing this module's code and the code for the 'User Created by' module that you linked to, I agree that this is a different enough approach to warrant a separate module.
Code review:
Testing:
I ran into some issues while testing this on a fresh Drupal install (installed via Composer). The module installs well and works just fine, but on uninstall, I got some errors back. Here was the first one:
Error: Class 'FieldStorageConfig' not found in user_created_by_field_uninstall() (line 15 of /test_project/web/modules/contrib/user_created_by_field/user_created_by_field.install)I was able to make this go away by adding the following 'use' statements at the beginning of the user_created_by_field.install file:
However, I ran the uninstall again after that error and got back this message:
Error: Call to a member function delete() on null in user_created_by_field_uninstall() (line 21 of /test_project/web/modules/contrib/user_created_by_field/user_created_by_field.install)The field appears to have uninstalled successfully as it no longer appears in the UI or the database, but this error should still be resolved. Note: The error above says line 21, but that is after adding the lines I mentioned before. It corresponds to line 18 in the current codebase.
Good work overall! Once you resolve that error, I sign off on this as reviewed.
Comment #3
avpadernoComment #4
avpadernoInstead of unsetting a form element, the code should set the #access property for that form element or (even better) implement the field access hook not to give the edit access to that field to users who don't have the permission.
There is no need of that code. It's enough to implement what I described.
The test isn't testing the module. Drupal core already tests the front page is accessible.
Comment #5
avpadernoComment #6
ntturner commentedThe uninstall problems have some additional side effects I had not previously mentioned. While the field will be removed from the user entity and the corresponding views, the module itself does not uninstall, meaning that the codebase cannot be removed or it will cause errors on other admin pages, such as when trying to access
/admin/config.Comment #7
eahonet commentedThank you @ntturner and @kiamlaluno for your feedback and time. I believe I have addressed all concerns raised and have updated the module here: https://www.drupal.org/project/user_created_by_field
git clone --branch 1.1.x https://git.drupalcode.org/project/user_created_by_field.gitntturner: I have addressed the uninstall. I tested that works when there are no fields populated and when it's in use in views, output, and has the field populated with content. I also removed the auto-stubbed-out /templates as it wasn't doing anything.
kiamlaluno: I agree. The field access hook is a better implementation. I have removed my view/form alters and condensed those pieces to a single hook_entity_field_access(). I added the field to a Form Display and gave a role permission to edit as part of the testing. I also removed the auto-generated /tests directory.
Comment #8
ntturner commentedI jumped on to review the changes. The code changes for the uninstall script look really good, but I am currently unable to access a lot of admin pages again. I am getting this error, which I believe is related to the changes in the .module file:
TypeError: Argument 2 passed to user_created_by_field_help() must be an instance of RouteMatchInterface, instance of Drupal\Core\Routing\CurrentRouteMatch given in user_created_by_field_help() line 16 of /test_project/web/modules/contrib/user_created_by_field/user_created_by_field.module #0 [internal function]: user_created_by_field_help('system.admin_re...', Object(Drupal\Core\Routing\CurrentRouteMatch))I tried this on the existing site I had of the module and on a fresh install with the same results. I also tried downloading the module via Git and via Composer. This error is preventing uninstalling the module via the UI as I cannot access the Uninstall admin page.
Comment #9
ntturner commentedI had posted the whole stack trace here but it was a bit lengthy and I'm not sure that you will need it. If you would like the entire stack trace, however, I have saved it so that I can provide it.
Comment #10
eahonet commented@ntturner. So, so sorry. I didn't encounter that on the sites I tested on, but when I put the module on a site and used
/admin/modules/uninstallto test instead of 'drush en' and 'drush pmu'.... I saw the error. I had removeduse Drupal\Core\Routing\RouteMatchInterface;thinking it was for my functions that I removed and replaced with the Permission hook. But it was needed for the hook_help function.I have released a 1.1.1 version of the module and the -dev version is also updated to correct this. I am no longer experiencing the error when uninstalling from /admin.
Comment #11
avpaderno(I take the previous comment means the code has been fixed basing on what reported here.)
Comment #12
ntturner commented@eahonet, No need to apologize. :)
Good job fixing those issues! I approve this module and believe it is ready for security coverage.
Comment #13
avpadernoThank you for your contribution! I am going to update the project to opt it into security coverage.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, 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.
I thank all the dedicated reviewers as well.
Comment #14
eahonet commented@kiamlaluno
Thank you for your time. It's nice to see the project turn green.
But I didn't create this task just to turn show the project as security reviewed. My goal was to get the vetted role by following these instructions: https://www.drupal.org/node/1011698
I was expecting to mark the project as security reviewed myself based on those instructions. I've now created two modules that other people have marked as passing security review, but I am still unable to do so myself. And I just took over as maintainer for an abandoned project that I would like to mark as secure after myself and my coworkers review it.
I'm unsure what my path forward is to receive the vetted role.
Comment #15
avpadernoYou need to apply with a project that contains more code. A module with few code lines doesn't allow to verify what you understand about writing secure code that follows the coding standards and correctly uses the Drupal API.