Problem/Motivation

Since #3331168: Limit trusted Composer plugins to a known list, allow user to add more, the Package Manager module will refuse to apply changes if untrusted composer plugins are installed or staged.

change record

That added \Drupal\package_manager\Validator\ComposerPluginsValidator , which does:

  /**
   * Composer plugins known to modify other packages, but that are validated.
   *
   * (The validation guarantees they are safe to use.)
   *
   * Keys are composer plugin package names, values are associated validators or
   * excluders necessary to make those composer plugins work reliably with the
   * Package Manager module.
   *
   * @var string[][]
   */
  private const SUPPORTED_PLUGINS_THAT_DO_MODIFY = [
    // cSpell:disable
    'cweagans/composer-patches' => ComposerPatchesValidator::class,
    'drupal/core-vendor-hardening' => VendorHardeningExcluder::class,
    // cSpell:enable
  ];

  /**
   * The composer plugins are known not to modify other packages.
   *
   * @var string[]
   */
  private const SUPPORTED_PLUGINS_THAT_DO_NOT_MODIFY = [
    // cSpell:disable
    'composer/installers',
    'dealerdirect/phpcodesniffer-composer-installer',
    'drupal/core-composer-scaffold',
    'drupal/core-project-message',
    'phpstan/extension-installer',
    // cSpell:enable
  ];

Individual sites can expand which composer plugins are allowed by updating the additional_trusted_composer_plugins key-value pair in the package_manager.settings configuration.

While necessary for reliability (and arguably security), this opens some new challenges:

  • What about contrib modules requiring additional composer plugins? → naïve answer: they could modify that config — but this would not work because that contrib module would not be installable through Project Browser, it'd have to be manually composer required, and then its hook_install() could update that config ⇒ we need data on how many contrib projects actually depend (directly or indirectly) on composer plugins
  • How do we evolve those constants in Drupal core?
  • Can we safely allow contrib modules to opt in more composer plugins to this by requiring them to have an associated validator class? → what about dummy validators to just bypass this?

IOW: balancing reliability ("Package Manager should never fail to ensure Project Browser and Automatic Updates never fail") with flexibility ("I want to install Drupal module X, why can't I?!") is tricky.

Steps to reproduce

Proposed resolution

TBD

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

we need data on how many contrib projects actually depend (directly or indirectly) on composer plugins

I did an initial round of research in #3336867: Identify & vet commonly used composer plugins in the Drupal ecosystem, and it looks like the number is very small.

wim leers’s picture

Title: [Policy, no patch] Create a core policy issue to be clear that projects with other Composer plugins will have to set this setting » [Policy, no patch] Projects depending on composer plugins will have to update the additional_trusted_composer_plugins setting in package_manager.settings
Issue summary: View changes

😅

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Active » Postponed (maintainer needs more info)

What is the next step here?

Package manager is in core as an experimental module and I haven't found a change record about this. Maybe the information in the change record should be moved to a change record to be published when package manager is stable?