1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
From: Jordi Boggiano <j.boggiano@seld.be>
Date: Fri, 26 Jan 2024 17:39:30 +0100
Subject: Fix automatic disabling of plugins when running non-interactive as
root
Merge pull request from GHSA-7c6p-848j-wh5h
Origin: upstream, https://github.com/composer/composer/commit/7048ff3808dd6576628099b53b5b664ec16cba63
Bug: https://github.com/composer/composer/security/advisories/GHSA-7c6p-848j-wh5h
Bug-Debian: https://bugs.debian.org/1063603
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-24821
---
src/Composer/Command/BaseCommand.php | 9 +++++++++
src/Composer/Console/Application.php | 10 ++++++++++
2 files changed, 19 insertions(+)
diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php
index a33f3a5..20d046e 100644
--- a/src/Composer/Command/BaseCommand.php
+++ b/src/Composer/Command/BaseCommand.php
@@ -223,6 +223,15 @@ abstract class BaseCommand extends Command
// initialize a plugin-enabled Composer instance, either local or global
$disablePlugins = $input->hasParameterOption('--no-plugins');
$disableScripts = $input->hasParameterOption('--no-scripts');
+
+ $application = parent::getApplication();
+ if ($application instanceof Application && $application->getDisablePluginsByDefault()) {
+ $disablePlugins = true;
+ }
+ if ($application instanceof Application && $application->getDisableScriptsByDefault()) {
+ $disableScripts = true;
+ }
+
if ($this instanceof SelfUpdateCommand) {
$disablePlugins = true;
$disableScripts = true;
diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php
index 9e585e6..a36722c 100644
--- a/src/Composer/Console/Application.php
+++ b/src/Composer/Console/Application.php
@@ -651,6 +651,16 @@ class Application extends BaseApplication
return $this->initialWorkingDirectory;
}
+ public function getDisablePluginsByDefault(): bool
+ {
+ return $this->disablePluginsByDefault;
+ }
+
+ public function getDisableScriptsByDefault(): bool
+ {
+ return $this->disableScriptsByDefault;
+ }
+
/**
* @return 'prompt'|bool
*/
|