Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow-plugins config value #10314

Merged
merged 13 commits into from
Dec 7, 2021
Merged

Conversation

Seldaek
Copy link
Member

@Seldaek Seldaek commented Nov 25, 2021

Fixes #5659

Still a few TODOs / open questions

  • Currently this warns on every operation once you have a plugin which is not enabled, I am not sure if this gets annoying or not. Are there cases where you want to have plugins installed but not enable them? Or is this only a safety net?
    image
  • Probably would be nicer if it instead prompted the user if the plugin should be added or not when something doesn't match the allow-plugins rules. Default to no of course.. Then we could modify the config in band and proceed activating the plugin if desired. Otherwise store it in a disallow-plugins list to make explicit those you don't wanna hear about again?
  • Docs
  • add the new /allow-plugins shortlink on getcomposer.org

@Seldaek Seldaek force-pushed the disable_plugins branch 2 times, most recently from 81507db to 6b97c95 Compare December 6, 2021 14:23
@Seldaek Seldaek marked this pull request as ready for review December 6, 2021 14:25
@Seldaek Seldaek requested a review from naderman December 6, 2021 20:51
@Seldaek
Copy link
Member Author

Seldaek commented Dec 7, 2021

Latest version of the PR does prompt the user whether new unknown plugins should be enabled if interactive. When non-interactive and allow-plugins is not set at all, it allows all plugins for BC. When non-interactive and allow-plugins is set but does not include a given package, that package is not allowed.

Now I do wonder if we shouldn't build in some time-based feature switch in there that makes it forbid all plugins if allow-plugins is not set in 6months or 1year from now? That way 2.2.0 and above would keep working BC but would warn users, getting people to slowly add that config, and then at some point it'd remove the BC layer and default allow-plugins to false.

Any thoughts on this last point?

@naderman
Copy link
Member

naderman commented Dec 7, 2021

I agree with adding a mechanism to get people to start adding the setting in due time.

@@ -69,6 +80,9 @@ public function __construct(IOInterface $io, Composer $composer, Composer $globa
$this->globalComposer = $globalComposer;
$this->versionParser = new VersionParser();
$this->disablePlugins = $disablePlugins;

$this->allowPluginRules = $this->parseAllowedPlugins($composer->getConfig()->get('allow-plugins'));
$this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer ? $globalComposer->getConfig()->get('allow-plugins') : false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how global plugin allow should even work? Merging the setting with local and applying to all plugins executed in this process or should the global setting apply to global plugins and local setting to local plugins?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it does apply global setting to global plugins and local to local plugins. Note that this refers to the composer global installed plugins. The global config.json would just be merged in both local and global composer configs.

I think it's fine as is. If you add a plugin via composer global require ... it will prompt you and add it in that composer.json and it works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that's fine but this may require a bit more documentation? Can also add that when the first confused person shows up ;-)

Seldaek and others added 7 commits December 7, 2021 13:47
…o enable/disable some packages, so we can suppress warnings for things we never want enabled, and add a way to update the config for the user if run interactively
Co-authored-by: Nils Adermann <naderman@naderman.de>
@Seldaek Seldaek force-pushed the disable_plugins branch 2 times, most recently from bbd9cf3 to 55569a1 Compare December 7, 2021 13:14
Seldaek added a commit to composer/getcomposer.org that referenced this pull request Dec 7, 2021
@bmack
Copy link

bmack commented Dec 7, 2021

Hey @Seldaek ,

Now I do wonder if we shouldn't build in some time-based feature switch in there that makes it forbid all plugins if allow-plugins is not set in 6months or 1year from now? That way 2.2.0 and above would keep working BC but would warn users, getting people to slowly add that config, and then at some point it'd remove the BC layer and default allow-plugins to false.

I was just reviewing your PR and was wondering why you put the timing check in the code, instead of using versioning. Otherwise people could stick with old versions (of course they should not do that), instead of faking their system time to make plugins work without configuration anymore :)

@Seldaek
Copy link
Member Author

Seldaek commented Dec 7, 2021

@bmack why would anyone want to do this though? I mean if you really don't care for security you can do composer config --global allow-plugins true to just tell it to run anything on all projects on your machine. NOT RECOMMENDED but it's there.

@naderman naderman merged commit a3e91b5 into composer:main Dec 7, 2021
@bmack
Copy link

bmack commented Dec 7, 2021

@Seldaek well, personally, I'd never do such things (but you know, people come up with stupid ideas to solve their issues). Also: I'd never put this in a global setting at all (my CI wouldn't have the plugins enabled, but I have it in my global config - would lead to inconsistencies), but I see this 100% on a per-project config level, and love it.

Doing this switch not via versioning but by date seems odd. I just wondered why we shouldn't stick to sem-ver here, instead of going with a fixed date "deadline". In any case: Thanks a bunch, very much looking forward to this!

@naderman
Copy link
Member

naderman commented Dec 7, 2021

@bmack We want this in 2.2 LTS so that this will apply to the majority of all users within a few months. As 2.3 is going to drop support for lots of old PHP versions, dependencies etc., we would have to introduce the requirement for allow-plugins in a 2.2.x release. But that would mean people who don't want the requirement have to stay on an outdated version missing bugfixes on the 2.2 LTS line, which we want to discourage them from doing.

So instead it'll be timed and included in all 2.2 releases, and worst case as Jordi described it can be disabled.

@Seldaek Seldaek deleted the disable_plugins branch December 8, 2021 08:47
nicolas-grekas added a commit to symfony/skeleton that referenced this pull request Dec 11, 2021
This PR was merged into the 4.4 branch.

Discussion
----------

Add allow-plugins in the skeleton config

Refs composer/composer#10314

For now, the default value in Composer is still to allow all plugins implicitly for BC. But the behavior will change in July 2022 to default to an empty list of allowed plugins.

This PR has 2 effects:
- it makes new project use the new Composer behavior directly instead of relying on the BC layer
- it marks `symfony/flex` as an allowed plugin, as our skeleton is meant to be used with Flex

The first point means that projects installing other composer plugins will need to mark them as allowed for them to run (but `composer update` running in an interactive shell will ask for that anyway)

Commits
-------

f757a29 Add allow-plugins in the skeleton config
aschempp added a commit to contao/contao-manager that referenced this pull request Dec 14, 2021
@GPHemsley-RELX
Copy link

Is there a command that can be run that will do nothing but prompt about updating the allow-plugins config?

@Seldaek
Copy link
Member Author

Seldaek commented Jan 11, 2022

composer show for example would load the plugins and prompt, without other side effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global config option to disable plugins and scripts
5 participants