drupal/composer/Plugin/VendorHardening
catch 7939d08092 Issue #3376431 by quietone, bbrala: Spellcheck core after removal of "Please" 2023-07-24 08:55:25 +01:00
..
Config.php Issue #3324801 by Spokje, mondrake: Fix PHPStan L2 error "Property Foo::$bar has unknown class Baz as its type." 2022-12-07 11:22:31 +00:00
FileSecurity.php Issue #3255350 by alexpott, longwave: Remove PHP 7 code from Drupal 10 2021-12-21 13:04:58 +00:00
LICENSE.txt Issue #3057094 by Mile23, hussainweb, greg.1.anderson, Mixologic, alexpott, catch, bojanz, andypost, leolando.tan: Add Composer vendor/ hardening plugin to core 2019-08-26 09:42:56 +10:00
README.txt Issue #3376431 by quietone, bbrala: Spellcheck core after removal of "Please" 2023-07-24 08:55:25 +01:00
TESTING.txt Issue #3057094 by Mile23, hussainweb, greg.1.anderson, Mixologic, alexpott, catch, bojanz, andypost, leolando.tan: Add Composer vendor/ hardening plugin to core 2019-08-26 09:42:56 +10:00
VendorHardeningPlugin.php Issue #3088730 by Spokje, anmolgoyal74, ankithashetty, Mile23, longwave, naresh_bavaskar, greg.1.anderson, Mixologic, klausi: Include 'composer' directory in phpcs scans 2022-02-24 17:39:07 +00:00
composer.json Issue #3284420 by longwave, Gábor Hojtsy, Spokje: Remove Composer 1 specific code paths from Drupal 10 2022-07-01 09:32:39 +01:00

README.txt

The Drupal Vendor Hardening Composer Plugin
===========================================

Thanks for using this Drupal component.

You can participate in its development on Drupal.org, through our issue system:
https://www.drupal.org/project/issues/drupal

You can get the full Drupal repo here:
https://www.drupal.org/project/drupal/git-instructions

You can browse the full Drupal repo here:
https://git.drupalcode.org/project/drupal

What does it do?
----------------

This Composer plugin does two things:

1) It removes extraneous directories from the project's vendor directory.
They're typically directories which might contain executable files, such as test
directories.

This sort of processing is required for projects that have a vendor directory
inside the HTTP server docroot. This is a common layout for Drupal.

By default, the plugin knows how to clean up packages for Drupal core, so you
can require drupal/core-vendor-hardening in your project and the rest will
happen automatically.

The plugin can also be configured to clean up additional packages using the
project's composer.json extra field.

This plugin can also clean up packages that were installed outside of the
vendor directory, using composer/installers. This allows users to configure the
plugin to clean up, for instance, Drupal extensions and Drupal core.

2) The plugin also adds .htaccess and web.config files to the root of the
project's vendor directory. These files will perform due diligence to keep the
web server from serving files from within the vendor directory.

How do I set it up?
-------------------

Require this Composer plugin into your project:

    composer require drupal/core-vendor-hardening

When you install or update, this plugin will look through each package and
remove directories it knows about.

You can see the list of default package cleanups for this plugin in Config.php.
If you discover that this list needs updating, file an issue about it:
https://www.drupal.org/project/issues/drupal

In addition to the default list of packages, you can configure the plugin using
the root package's composer.json extra field, like this:

    "extra": {
      "drupal-core-vendor-hardening": {
        "vendor/package": ["test", "documentation"]
      }
    }

The above code will tell the plugin to remove the test/ and documentation/
directories from the 'vendor/package' package when it is installed or updated.

For packages installed outside of the vendor directory, such as those installed
by composer/installers, the paths to remove should be relative to the package
base. As an example, a Drupal module package named drupal/module_name might be
installed by composer/installers to web/modules/contrib/module_name/. Cleanup
paths specified for this package might look like this:

    "extra": {
      "drupal-core-vendor-hardening": {
        "drupal/module_name": ["tests", "src/Tests"]
      }
    }

This would then cause the plugin to try and remove
web/modules/contrib/module_name/tests and
web/modules/contrib/module_name/src/Tests.