Neon CRM Events integrates Drupal with the Neon CRM API v2 so editors can pick a Neon CRM event from their account and sync its data into a Drupal node with a single click. Every event field — name, summary, description, dates and times, timezone, location, fee, registration URL, thumbnail, and publish/inactive status — is stored as a real Drupal field, so site builders can list and filter events using Views, build calendar feeds, or theme them however they like. Fields remain fully editable after syncing.

Project link

https://www.drupal.org/project/neon_crm_events

Comments

dsdeiz created an issue. See original summary.

mookum’s picture

Hi, thanks for submitting this module

I went through the code, plus ran phpcs/phpstan/phpunit and wanted to share what I found so you can get this over the line.
Nothing here is scary, and most of it is quick to fix.
Two things below I'd consider must-fix, the rest is smaller polish.

1. A permission that isn't actually enforced (please fix)
You've defined a `sync neon crm events` permission, but it's never checked in the code not in the submit handler, not on the route.
Right now anyone who can edit one of these nodes can trigger a sync, whether or not they have that permission.
I'm guessing this was meant to gate the "Sync from Neon" button could you add a check for it in `syncSubmit()` (or drop the permission if it's not needed)?

2. The API key is stored/shown as plain text (please fix)
In the settings form, the API key field uses a regular textfield, so it prints back out in plain text every time someone opens the settings page, and it sits unmasked in any config export or backup.
Could you switch that field to `#type: password`? Long term, pointing people at the `key` module for storing this kind of credential would be even nicer, but the password field alone solves the immediate exposure.

3. Small coding standards cleanup
phpcs flagged 10 spots in `NeonCrmEventsHooks.php` where `t()` is called directly instead of `$this->t()` all inside the `help()` and `formNodeFormAlter()` methods. Adding `use StringTranslationTrait` to the class and swapping those calls over will clear it up. (The `t()` calls in the static submit/ajax methods are fine as they are you can't use `$this->t()` there anyway, and phpcs correctly leaves those alone.)

4. A few phpstan notes in `NeonCrmApi.php`
- Line 179: the `is_array($data)` check is redundant at that point you've already confirmed it's an array a few lines up.
- Line 282: `isset($m[3])` will always be true there, since the regex's AM/PM group is required and PCRE fills in the earlier optional group once a later one matches. `(int) $m[3]` on its own is enough.
- Line 366: `filter_default_format()` is deprecated as of 11.4 and goes away in 13.0 worth switching to the `FilterFormatRepositoryInterface` service now rather than later.

5. README is a little out of date
The "File structure" section still mentions a `.install` file, a `Service/` folder, and a `templates/` folder that aren't there anymore (the module's moved to `src/Hook/` and config-based install). Just needs a quick pass to match what's actually in the repo.

6. No tests yet
Not a blocker for the application, but a couple of unit tests around `combineDateTime()` and `extractEventId()` would be a nice addition given they're doing regex parsing.

Let me know if anything above is unclear or you'd like a hand with any of it!

mookum’s picture

Status: Needs review » Needs work
avpaderno’s picture

Thank you for applying!

Before giving links helpful to understand how the review process works, what to expect from a review, and what to do to avoid a review takes more time than needed, I would like to thank all the reviewers for the work they do.
These applications are volunters-driven, which also means it is not possible to predict when an application will be marked fixed and the applicant will get the permission to opt projects into security advisory policy. While we aim to make an application as quick as possible, it is also important for us that more people review the project used for an application. In this way, we make sure applications do not miss some important points that should be instead reported.
Applications are not meant to be complete debugging sessions that eliminate every existing bug, though. I apologize if sometimes applications seem to go into too-detailed reviews.

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 enable GitLab CI for the project and fix the PHP_CodeSniffer errors/warnings it reports.
  • 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; once this application is closed, you will be able to change the project status from Not covered to Opt into security advisory coverage. This is possible only 14 days after the project is created.

    Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
  • Only the person who created the application will get the permission to opt projects into security advisory coverage. No other person will get the same permission from the same application; that applies also to co-maintainers/maintainers of the project used for the application.
  • 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 project name and the branch to review.

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 project moderator before posting the first comment on newly created applications. Project moderators will do some preliminary checks that are necessary before any change on the project files is suggested.
  • Reviewers should show the output of a CLI tool only once per application.
  • 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.

vishal.kadam’s picture

FILE: src/NeonCrmApi.php

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The HTTP client.
   *
   * @var \GuzzleHttp\ClientInterface
   */
  protected $httpClient;

  /**
   * The logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  /**
   * Constructs a new NeonCrmApi.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param \GuzzleHttp\ClientInterface $http_client
   *   The HTTP client.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
   *   The logger channel factory.
   */
  public function __construct(
    ConfigFactoryInterface $config_factory,
    ClientInterface $http_client,
    LoggerChannelFactoryInterface $logger_factory,
  ) {
    $this->configFactory = $config_factory;
    $this->httpClient = $http_client;
    $this->logger = $logger_factory->get('neon_crm_events');
  }

Modules which are compatible with Drupal 10 and higher versions are expected to use constructor property promotion.

avpaderno’s picture

I am not sure that using a password form element for a key value is the correct way to go, for two reasons:

  • When a password form element is used for an account password, it is used for a value that is supposedly changed by a single person (the person who created the account). The settings for a module could be changed by more than one person, if the site is not personal.
  • To change an account password, it is necessary to first enter the current password. Without asking first the old value, somebody who gained access to an account which can change those settings could change the key value without knowing the value of the key.

To avoid somebody who gains access to an account with elevated permissions changes the key, the solution could be doing like Drupal core does some values: retrieve those values using the Drupal\Core\Site\Settings class.

dsdeiz’s picture

Status: Needs work » Needs review

Hello

I've made updates on the module for https://www.drupal.org/project/projectapplications/issues/3618312#commen.... For the implementation of the key, I had it use the "#type" => "password". But it's purpose was to keep the key hidden. It's only change when you put a new value on the element. Otherwise, it uses the same key. The key is still stored as plain text in the configuration though.

avpaderno’s picture

A password form element is thought for a value (the password) that is changed by a single person. Even in that case, to change a password, the previous value must be entered.
That does work well for a value that can be changed by two or more people. In that case, how can a person visiting the form know the value has been already changed by another person? Should that person try changing the key?

dsdeiz’s picture

Yeah, there is a description on the API key element that says a key has already been saved. I updated it to add to put more emphasis - https://monosnap.ai/direct/aBF5rsYafNsIx8gIAcKTsDvRiCakv7.

avpaderno’s picture

Still, how can a person who has access to that form know the API key has been already updated from somebody else, in a different moment?

dsdeiz’s picture

I have updated the module and adjusted the description to include when and who changed the keys:

A key is already saved. It was last changed 5 seconds ago by admin. Leave this field blank to keep it, or enter a new key to replace it. Keys are generated in Neon CRM under Settings > User Management.

There's also an option to always keep it overridden from the settings file through $config['neon_crm_events.settings']['api_key'] = 'your-neon-api-key';. Similar to using Settings::get().