Mosaic is a visual layout builder for Drupal 11/12 that enables content authors to compose pages from reusable components without writing code. It uses a canvas-based editor (Puck + React 19) with PHP 8 Attribute-based component plugins, a design token entity type with CSS custom property export, schema versioning with queue-based migration, and built-in WCAG 2.2 AA accessibility. Fully self-hosted with no cloud dependency.

It differs from Drupal core Layout Builder by providing a full drag-and-drop canvas with live data binding from entity fields, Views, REST, and context sources.

Security measures:
- All POST routes require _csrf_request_header_token: TRUE
- All content entity queries use accessCheck(TRUE)
- accessCheck(FALSE) only for config entity CSS on anonymous pages (documented)
- No dynamic SQL — all queries via Drupal entity query API
- Input sanitised via Twig auto-escaping throughout
- Route access via mosaic.administer permission
- SSRF protection on all outbound URL resolution

Code quality:
- PHPCS Drupal + DrupalPractice: 0 errors, 0 warnings
- PHPUnit: 935 tests passing (Unit + Kernel + Functional)
- PHP 8.1+ compatible, no deprecations
- Drupal ^11.1 || ^12 supported

I will complete the review bonus (3 reviews) and post links here before this issue is closed.

Project link

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

Comments

arunkarthick created an issue. See original summary.

arunkarthick’s picture

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

Issue summary: View changes
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

Status: Needs review » Needs work

1. FILE: mosaic.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: mosaic.module and modules/mosaic_canvas_bridge/mosaic_canvas_bridge.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.

arunkarthick’s picture

Status: Needs work » Needs review

Fixed in 1.0.0-rc3.

Thank you for the review @vishal.kadam. Both issues have been addressed:

**1. version: VERSION in mosaic.libraries.yml**

Removed from all four library definitions (renderer, device_preview,
media_library_bridge, builder). VERSION resolves to the Drupal core
version, not the module version. Drupal.org packaging rewrites .info.yml
files but not .libraries.yml files.

**2. Procedural hooks → OO #[Hook] attribute pattern**

All procedural hook functions have been migrated:

- src/Hook/MosaicHooks.php — hook_help, hook_page_attachments,
hook_mosaic_global_template_presave, hook_runtime_requirements
- modules/mosaic_canvas_bridge/src/Hook/MosaicCanvasBridgeHooks.php —
hook_field_formatter_info_alter, hook_entity_view_alter
(both with Order::Last)

hook_module_implements_alter was deleted rather than converted — it is
removed in Drupal 12 and cannot be a #[Hook] class method. The run-last
ordering it provided is replaced by Order::Last on the actual hook
methods. The module is now fully Drupal 12 compatible.

vishal.kadam’s picture

It is better not to create new releases during these applications, since a review could ask for a change that is not backward compatible with the existing releases. Just using a development version avoids those BC issues.

vishal.kadam’s picture

Rest seems fine to me.

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

avpaderno’s picture

Status: Needs review » Needs work
  • The following points are just a start and don't necessarily encompass all of the changes that may be necessary
  • A specific point may just be an example and may apply in other places
  • A review is about code that does not follow the coding standards, contains possible security issue, or does not correctly use the Drupal API
  • The single review points are not ordered, not even by importance

src/Hook/MosaicHooks.php

    $account = \Drupal::currentUser();
    if ($account->hasPermission('mosaic.administer')) {
      $attachments['#attached']['library'][] = 'mosaic/device_preview';
      $attachments['#attached']['drupalSettings']['mosaic']['devicePreview'] = TRUE;
    }

Any dependency must be injected using the dependency injection container, except in the case the dependency is used only from static methods.

Hook classes are essentially autowired service classes that do not need to be defined in the .services.yml file. As such, any dependency is defined as parameter of the class constructor.

It is also better to initialize the string translation instance calling setStringTranslation().

    foreach ($updates as $id => $info) {
      $label   = $info['label'] ?? $id;
      $version = $info['version'] ?? '?';
      $items[] = $this->t('@label (v@version)', ['@label' => $label, '@version' => $version]);
    }

Is the label a translatable string?

    return [
      'mosaic_template_updates' => [
        'title'       => $this->t('Mosaic: template updates pending review'),
        'description' => $this->t('The following global templates have been updated since their initial deployment. Layouts derived from these templates may need to be reviewed by content editors: @list', [
          '@list' => implode(', ', array_map('strval', $items)),
        ]),
        'severity'    => REQUIREMENT_WARNING,
        'value'       => $this->t('@count template(s) updated', ['@count' => count($updates)]),
      ],
    ];

As per Drupal coding standards, only a white space is required before and after the assignment operator and other operators.

LICENSE.txt

The content of the LICENSE.txt file is expected to be the same of the LICENSE.txt file used by Drupal core.

modules/mosaic_acsf/mosaic_acsf.module

Drupal core no longer requires a .module file to recognize a module. If those files do not contain code, they can be omissed.

src/Controller/AiGenerateController.php

A controller class is not supposed to be extended by classes implemented by other modules, so it is fine to use private property. It would also be better to define the class final.

    if ($has('hero', 'landing', 'homepage', 'home page', 'welcome')) {
      return array_values(array_filter([
        $avail('mosaic_heading') ? $h('Welcome to Our Site', 'h1') : NULL,
        $avail('mosaic_text') ? $txt('Add a compelling description of your service or product here.') : NULL,
        $avail('mosaic_button') ? $btn('Get Started') : NULL,
      ]));
    }

    if ($has('feature', 'benefit')) {
      return array_values(array_filter([
        $avail('mosaic_heading') ? $h('Our Features', 'h2', 'center') : NULL,
        $avail('mosaic_text') ? $txt('Everything you need, built to work together.') : NULL,
        $avail('mosaic_columns') ? $cols(3, [
          [$card('Feature One', 'Describe your first feature here.')],
          [$card('Feature Two', 'Describe your second feature here.')],
          [$card('Feature Three', 'Describe your third feature here.')],
        ]) : NULL,
      ]));
    }

Strings shown in the user interface must be translatable.

src/Controller/ComponentPackagesController.php

Since that class does not use methods from the parent class, or it uses a single method from the parent class, it does not need to use ControllerBase as parent class.
Controllers do not need to have a parent class; as long as they implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface, they are fine.

      $build['package_' . $provider] = [
        '#type' => 'details',
        '#title' => $this->t('@name (@count components)', [
          '@name'  => $moduleInfo,
          '@count' => count($components),
        ]),
        '#open'  => TRUE,
        'table'  => [
          '#type'   => 'table',
          '#header' => [
            $this->t('Plugin ID'),
            $this->t('Label'),
            $this->t('Category'),
            $this->t('Level'),
          ],
          '#rows'   => $rows,
          '#empty'  => $this->t('No components.'),
          '#attributes' => ['class' => ['mosaic-component-packages__table']],
        ],
      ];

For translatable strings that change basing on a number (as in this case), there is ::formatPlural().

src/Controller/EntityFieldsController.php

A controller class needs to implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface.
Since its properties are private, the class can be as well final.

arunkarthick’s picture

Status: Needs work » Needs review

Thank you for the detailed review, @avpaderno. All 9 issues from Comment #9 have been addressed. Here is a summary of each fix:

1. MosaicHooks — Remove \Drupal:: static calls
All static calls replaced with constructor-injected services: AccountProxyInterface, MosaicTokenManager, MosaicTokenBridgeService, StateInterface, TimeInterface, and TranslationInterface (passed to setStringTranslation()).

2. MosaicHooks — Register as DI service
Registered in mosaic.services.yml with the FQCN as the service ID (Drupal\mosaic\Hook\MosaicHooks:). Note: using a custom service ID causes HookCollectorPass::registerHookServices() to create a second autowired definition with zero constructor arguments, resulting in ArgumentCountError at runtime. FQCN is required.

3. AiGenerateController — Add final keyword
Class is now declared final.

4. AiGenerateController — Add StringTranslationTrait + wrap error strings in t()
StringTranslationTrait added, TranslationInterface injected. All three error response strings (Rate limit exceeded. Try again later., Invalid JSON payload., No components available for generation.) are now wrapped in $this->t().

5. ComponentPackagesController — Drop extends ControllerBase
Replaced with implements ContainerInjectionInterface + use StringTranslationTrait. TranslationInterface injected directly.

6. ComponentPackagesController — Use formatPlural() for component count
@count components in t() replaced with:
$this->formatPlural(count($components), '1 component', '@count components')

7. EntityFieldsController — Add implements ContainerInjectionInterface
Interface was missing despite create() being present. Added.

8. EntityFieldsController — Add final keyword
Class is now declared final.

9. mosaic_acsf.module — Delete empty file
File contained only a @file docblock and declare(strict_types=1). Deleted. Drupal 11 does not require a .module file for module recognition, and the ACSF factory hooks are invoked directly by ACSF without it.


Commits:

  • c996ae2 — All 9 avpaderno fixes
  • ef04a7e — Follow-up: FQCN service ID for MosaicHooks (caught by Kernel tests during QA)

On the release strategy:

A 1.0.x-dev release has been created and is now live at https://www.drupal.org/project/mosaic/releases. This tracks the 1.0.x branch tip and will automatically reflect all further fixes as they are pushed — no separate release node is needed for each update.

The stable 1.0.0 tag will be cut once this security advisory application is approved. This avoids the overhead of repeated release candidate tags while the review is in progress, and ensures the published stable release is clean from the start.

Please let me know if any further changes are needed. Thank you again for the thorough review.

avpaderno’s picture

Assigned: Unassigned » avpaderno
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.

arunkarthick’s picture

Thank you so much, Avpaderno — and thank you for the thorough and detailed review.
The feedback through this process has genuinely made the module better, and I
appreciate both your time and your patience.

I have tried to opt into security advisory coverage on the project edit page, but
the "Opt into security advisory coverage" option is currently not enabled for
selection. Could you confirm once the account update has been applied? I will
check back and enable it as soon as it becomes available.

Thank you again for everything.

vishal.kadam’s picture

New projects must wait 10 days before opting in.

avpaderno’s picture

The description for the Security advisory coverage field says New projects must wait 10 days before opting into security advisory coverage. Please take this time to review writing secure code and best practices. The project has been created on May 10; that means waiting until May 20/21.

Status: Fixed » Closed (fixed)

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