This module creates a CKEditor5 plugin and field formatter that allows content editors to embed Soundcite clips into their content.

Project link

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

Comments

layalk created an issue. See original summary.

vishal.kadam’s picture

Issue summary: View changes
avpaderno’s picture

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 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

Status: Needs review » Needs work

1. 2.x-dev is a wrong name for a branch and should be removed. Release branch names always end with the literal .x as described in Release branches.

2. FILE: soundcite.module

A new module that aims to be compatible with latest Drupal releases is expected to implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.

/**
 * @file
 * Soundcite module.
 */

The usual description for a .module file is “Hook implementations for the [module name] module”, where [module name] is the module name given in the .info.yml file.

3. FILE: src/Form/Settings.php

With Drupal 10 and Drupal 11, there is no longer need to use #default_value for each form element, when the parent class is ConfigFormBase: It is sufficient to use #config_target, as in the following code.

    $form['image_toolkit'] = [
      '#type' => 'radios',
      '#title' => $this->t('Select an image processing toolkit'),
      '#config_target' => 'system.image:toolkit',
      '#options' => [],
    ];

Using that code, it is no longer needed to save the configuration values in the form submission handler: The parent class will take care of that.

4. FILE: src/Plugin/Field/FieldFormatter/SoundciteAudioFormatter.php

 * @FieldFormatter(
 *   id = "soundcite_audio",
 *   label = @Translation("Soundcite Audio Player"),
 *   field_types = {
 *     "file"
 *   }
 * )

Projects that are compatible with Drupal 10 or higher versions should use attributes instead of annotations.

layalk’s picture

Status: Needs work » Needs review

Hello,
Thanks @vishal.kadam for the very fast reply and help.
I've worked on the issues and it's ready to recheck.
However I have a question regarding the -dev branch. Is there a new way to have a development release? The main branch is `2.0.x` and the `2.x-dev` is for the dev release.

vishal.kadam’s picture

A development release corresponds to a branch.

For example: 1.x → generates 1.x-dev

vishal.kadam’s picture

Status: Needs review » Needs work

FILE: soundcite.module

Since the module is declared compatible with Drupal 10.5, removing the function implementing the hook is not possible. The function still needs to be defined, but it calls the method defined by the service class, as described in Support for object oriented hook implementations using autowired services (Backwards-compatible Hook implementation for Drupal versions from 10.1 to 11.0).

layalk’s picture

Noted for the development release..I'll update the branches.
Also for the soundcite.module, I'll make the changes.
Thank you again for the prompt feedback and very helpful support.

layalk’s picture

Status: Needs work » Needs review
vishal.kadam’s picture

Rest looks good to me.

Please wait for a Project Moderator to take a look and if everything goes fine, you will get the role.

bbu23’s picture

Assigned: Unassigned » bbu23
bbu23’s picture

Assigned: bbu23 » Unassigned
Status: Needs review » Needs work

First of all, it's very nice to see a schema with validation! A bit of a rare one ☺️
Overall the code looks great, I see great care for Drupal coding standards and best practices.

I do have some small findings tho:
- Missing composer.json file. See Add a composer.json file for more info.
- SoundciteHooks.php: While you're using an OOP class for hooks, the hooks themselves are not using the Hook Attribute which is available for Drupal 11.1+
- SoundciteHooks.php:
-- I would recommend using the modern alternative for strpos($variables['element'][0]['#text'], 'soundcite') !== FALSE) which is str_contains
-- I see usage of a config object in the preprocess function, but this object is not added as cacheable dependency which means if the settings change, the render arrays won't. $config = $this->configFactory->get('soundcite.settings');

layalk’s picture

Status: Needs work » Needs review

I will say this every I post on this thread: I'm humbled and amazed by the feedback and support. That's why I love Drupal.
I made the required changes.
Thanks

bbu23’s picture

🤜🤛

+1 RTBC

vishal.kadam’s picture

Priority: Normal » Major

I am changing priority as per Issue priorities.

vishal.kadam’s picture

Priority: Major » Critical

I am changing priority as per Issue priorities.

avpaderno’s picture

To make it clear (since there is a Please wait for a Project Moderator to take a look and if everything goes fine, you will get the role. comment): The project used by this application should be reviewed by other reviewers. The applicant still needs to check the application for any review, since the approval of this application is not guaranteed to be the next step.

brian@graith’s picture

Reviewed the 2.0.x branch. The formatter side is handled well: the audio-formatter template sets data-url / data-start / data-end via Attribute setAttribute() (values escaped), configuration is passed through drupalSettings rather than injected into JS, the config cacheable dependency is declared, and the hooks use the #[Hook] + #[LegacyHook] pattern.

Main point:

  • The SoundCite runtime is loaded from an external CDN at an unpinned "latest" version, with no Subresource Integrity. soundcite.libraries.yml pulls https://cdn.knightlab.com/libs/soundcite/latest/js/soundcite.min.js (type: external) onto the front end of any page containing a clip. Because it is "latest", whatever that URL serves at any time — including a future or compromised build — runs as first-party script on the site with no integrity check, and it discloses visitor IPs to a third-party CDN. For a security-covered module this external, unpinned dependency is worth addressing: pin a specific SoundCite version (not latest), and ideally vendor the library locally, or at minimum document the external dependency and add an integrity hash.

Minor: soundcite-behavior.js copies settings.soundcite.background_color from config into window.SOUNDCITE_CONFIG without validation; it is admin-only and used as data, but validating it as a colour in the settings form would be tidier.

For reference, js/build/soundcite.js is the module's own compiled CKEditor 5 plugin (its source and webpack config are present), which is the expected pattern rather than a bundled third-party library.

I use Assisted AI but I review what it generates

avpaderno’s picture

Priority: Critical » Normal
Status: Needs review » Needs work
vishal.kadam’s picture

Priority: Normal » Minor

I am changing priority as per Issue priorities.

layalk’s picture

Thanks Brian for the review. Here's what's been addressed:

  • CDN pinning + SRI: soundcite.libraries.yml now references SoundCite
    0.5.1 (the latest tagged release) instead of latest for both the JS and CSS,
    and both now carry integrity (SHA-384) and crossorigin: anonymous attributes.
    If the CDN content ever changes unexpectedly, the browser will refuse to execute it rather than silently
    running it.
  • background_color validation: this was already in place in Settings.php —
    the form validates the value against a CSS color regex (hex/rgb/rgba/hsl/hsla/named colors) before it's
    saved to config, so the value reaching soundcite-behavior.js is already validated.
layalk’s picture

Status: Needs work » Needs review
avpaderno’s picture

Priority: Minor » Normal
avpaderno’s picture

Assigned: Unassigned » avpaderno

src/Form/Settings.php

  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);

    $background_color = $form_state->getValue('background_color');
    if (!empty($background_color)) {
      // Validate CSS color format (hex, rgb, rgba, hsl, hsla, or named colors).
      $valid_color = preg_match('/^(#[0-9A-Fa-f]{3,8}|rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)|rgba\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*[\d.]+\s*\)|hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)|hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*[\d.]+\s*\)|[a-zA-Z]+)$/', $background_color);
      if (!$valid_color) {
        $form_state->setErrorByName('background_color', $this->t('Please enter a valid CSS color value (e.g., #ff6600, rgb(255,102,0), or a color name like "orange").'));
      }
    }

    $soundcloud_client_id = $form_state->getValue('soundcloud_client_id');
    if (!empty($soundcloud_client_id)) {
      // SoundCloud client IDs are alphanumeric.
      if (!preg_match('/^[a-zA-Z0-9]+$/', $soundcloud_client_id)) {
        $form_state->setErrorByName('soundcloud_client_id', $this->t('Please enter a valid SoundCloud Client ID (alphanumeric characters only).'));
      }
    }
  }

Validating a submitted value with a pattern in a validation handler is not necessary, since the textfield form element accepts a #pattern value.

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'soundcite.settings',
    ];
  }

It is no longer necessary to implement that method, when the configuration form uses #config_target. It is sufficient to use RedundantEditableConfigNamesTrait.

avpaderno’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for your contribution and for your patience with the review process!

I am going to update your account so you can opt into security advisory coverage any project you create, including the projects you already created.

These are some recommended readings to help you with maintainership:

You can find more contributors chatting on Slack or IRC in #drupal-contribute. So, come hang out and stay involved!
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 also all the reviewers for helping with these applications.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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