Problem/Motivation

There are 2 reasons that Automatic Updates in core will require core to have a production dependency on the composer/composer package:

  1. For people on hosting accounts that disable shell_exec and friends (#3218119: [policy, no patch] To enable or use Automatic Updates, require "proc_open" to not be disabled), the only way to invoke composer commands is through the PHP API.
  2. The automatic updates module needs to inspect things from composer.json and composer.lock (#3238647: Create an API for easily accessing relevant Composer information), and the composer/composer package provides the API to do that.

I'm opening this issue to get feedback on whether Drupal core having a production dependency on composer/composer is ok. If it's not, we'll need to figure out some alternative, though I'm not really sure what.

I'm filing this for Drupal 10, though if we get the module to beta in time for inclusion into 10.0, then if we also want to include it into 9.4, then the question applies for 9.4 as well. Meanwhile, if we don't get the module ready in time for 10.0, would we want to move composer/composer to a production dependency in 10.0 anyway, rather than having to make that change in a minor release (e.g., 10.1)?

For now, this is just a policy question. A patch to actually implement this change can happen in a followup.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

effulgentsia created an issue. See original summary.

effulgentsia’s picture

andypost’s picture

+1 also in needs policy to update as security releases for linux and windows are different for composer

mxr576’s picture

I understand the motivation behind this, but I would like to ask a purely technical question: if composer/composer becomes a drupal/core dependency, do we also get a new Drupal core security advisory for every Composer security advisory? (Do we get a new drupal-core-recommended release every time when a Composer security update is released?)

I am asking this because as of today we run symfonycorp/cli also known as fabpot/local-php-security-checker on our PRs/CRs/MRs and as scheduled check on every project; and whenever there is a Composer security update, we also get warnings about those from the CI. Why? Because some dev dependencies are rightfully requiring composer/composer as a dev dependency (like Composer plugins) and in non-dev envs we install projects with composer install and not with composer install --no-dev (to be able run tests, etc.). But, even if Composer is available in [project_root]/vendor/bin, I think nobody is using it (at least not before automated updates), everybody is using the project independent Composer binary installed somewhere on the system, so these are 99% false-positive warnings already. Adding Composer as a drupal/core dependency will bring this problem to production environments too. (Nightmare vision: even if we will provide a code drop to an on-prem customer with the result of composer install, their security team/scanner may through that back to us because it will contain a sec. vulnerable Composer version that they do/should not use either way.)

mxr576’s picture

(hm, maybe if the binary/cli app and the "framework" called Composer would be separate packages that improve the situation, but I am sceptical if Composer devs would be open for a refactoring like this.)

andypost’s picture

longwave’s picture

@mxr576 #3198340: Strict constraints in drupal/core-recommended make it harder for Composer-managed sites to apply their own security updates when a core update is not available discusses relaxing core-recommended, I think that becomes even more important if Composer is a production dependency.

effulgentsia’s picture

do we also get a new Drupal core security advisory for every Composer security advisory?

Not necessarily. Only if the Drupal security team determines that it's needed. We don't issue Drupal security advisories solely to satisfy scanners. However, the next regular bug-fix or minor release would likely get onto that version, so scanners would get satisfied eventually.

(Do we get a new drupal-core-recommended release every time when a Composer security update is released?)

Per above, yes, but not necessarily as a security release.

xjm’s picture

next regular bug-fix or minor release would likely get onto that version, so scanners would get satisfied eventually.

We do issue off-schedule normal patch releases to change the lockfile/metapackage versions at least (edit: on a best-effort basis when the release managers are available and the core release schedule allows it), although constraints will not be increased unless the exploit is in core. (E.g. last week, we were two minor releases behind on Twig, so we did not increase our Twig constraint since the vuln requires an admin permission to exploit in core, because otherwise it would have forced a minor update in a patch release.)

dave reid’s picture

We run into so many issues with composer/composer as a dependency, and having a duplicate version of composer installed in vendor/bin means that version gets used, but it cannot self-update itself when being used with composer-patches as well as core-composer-scaffold. Please do not add this dependency to drupal/core as a production dependency.

The error we often run into is the following:

error:In FilesystemRepository.php line 163: file_get_contents(/var/www/html/vendor/composer/composer/src/Composer/Repository/../InstalledVersions.php): failed to open stream: No such file or directory

Because composer gets installed in the vendor directory, and it has a relative path to trying to find the InstalledVersions.php file, it cannot find it and it fails.

As a workaround, we have to specifically run a composer update composer/composer first, before we do any other composer update commands.

#3163923: composer/composer dependency in drupal/core-composer-scaffold fails to update composer
https://github.com/composer/composer/issues/9937

phenaproxima’s picture

I have a potential solution for that in Package Manager, @Dave Reid: #3309220: Remove runtime dependency on composer/composer

phenaproxima’s picture

@Dave Reid, I'd like to understand more details about the problems you run into, because if I (and others) understood them better, it's possible we could implement workarounds, guardrails, and maybe straight-up fixes in Package Manager/Automatic Updates (or perhaps, for that matter, Composer itself).

Would you be able to describe for me the layout of a project that you'd run into problems with? (Or provide a sample bare-bones composer.json that I could use to set up an environment like that?) And then maybe a few tasks/commands you try to run which break it?

phenaproxima’s picture

It's worth mentioning that @tedbow and I are debating how and if to remove composer/composer as a runtime dependency from Automatic Updates. I opened a meta for it and outlined my proposed plan: #3316368: Remove our runtime dependency on composer/composer: remove ComposerUtility

catch’s picture

Status: Active » Postponed

Postponing on #3316368: Remove our runtime dependency on composer/composer: remove ComposerUtility, seems (much) better to avoid it if we can.

wim leers’s picture

phenaproxima’s picture

I think we should close this issue as outdated.

We're already nearly done removing our runtime dependency on composer/composer and ripping out the ComposerUtility class which relies on it. So if composer/composer is moved into core's runtime dependencies, it won't be the Automatic Updates Initiative's doing.

effulgentsia’s picture

Status: Postponed » Closed (won't fix)

Agreed.

There's still the question of #3218119: [policy, no patch] To enable or use Automatic Updates, require "proc_open" to not be disabled, but:

  1. We don't know in 2023 how big a percentage of sites actually have that limitation, and we shouldn't add support for it until we have evidence that it's a non-trivial amount.
  2. If we need to support Automatic Updates on sites that don't have proc_open enabled, there's other issues we'll need to solve too. It won't just be a matter of using Composer's PHP API and everything magically working.
  3. If we need to support Automatic Updates on sites that don't have proc_open enabled, we shouldn't necessarily have to make composer/composer a runtime requirement for everyone else. We'll need to come up with a solution that only brings it in for the few sites that need it.

Therefore, closing this for now, and it can be re-opened if/when another need for it arises, whether that's Automatic Updates related or something else entirely.