Problem/Motivation

In Drupal\Core\Composer\Composer::vendorTestCodeCleanup() we attempt to remove test directories from the vendor directory as security mitigation.

The test directory for twig/twig is listed as test, which is accurate up through 1.42.2: https://github.com/twigphp/Twig/tree/v1.42.2

But then in 1.42.3 it's changed to tests: https://github.com/twigphp/Twig/tree/v1.42.3

This leaves behind the tests for twig/twig after an update.

This same issue is present in 8.8.x's vendor hardening plugin: https://git.drupalcode.org/project/drupal/blob/8.8.x/composer/Plugin/Ven...

Proposed resolution

Add tests to the list of directories to remove, so that we attempt to remove both test and tests.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Issue summary: View changes
voleger’s picture

Status: Active » Needs review
FileSize
517 bytes
623 bytes

Here the patches for both branches

Mile23’s picture

Version: 8.7.x-dev » 8.8.x-dev
Status: Needs review » Needs work
Issue tags: +needs backport to 8.7.x

Thanks, @voleger. :-)

Let's just do 8.8.x now and then get a backport, because they're different.

+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -90,7 +90,7 @@ class Composer {
+    'twig/twig' => ['doc', 'ext', 'test', 'tests'],

We need this same change in composer/Plugin/VendorHardening/Config.php.

voleger’s picture

Status: Needs work » Needs review
FileSize
1.21 KB

Sure

Mile23’s picture

Status: Needs review » Reviewed & tested by the community

LGTM. :-)

Mile23’s picture

Title: Test directories left behind for twig/twig » Vendor cleanup fail for twig/twig

Updated title to be clearer.

larowlan’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed 69fc0df and pushed to 8.8.x. Thanks!

  • larowlan committed 69fc0df on 8.8.x
    Issue #3082145 by voleger, Mile23: Vendor cleanup fail for twig/twig
    
voleger’s picture

Status: Patch (to be ported) » Needs review
Issue tags: -needs backport to 8.7.x
FileSize
517 bytes

Patch for 8.7.x

Mile23’s picture

Status: Needs review » Reviewed & tested by the community

LGTM.

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3f3c757 and pushed to 8.7.x. Thanks!

  • larowlan committed 3f3c757 on 8.7.x
    Issue #3082145 by voleger, Mile23: Vendor cleanup fail for twig/twig
    
Mixologic’s picture

Issue tags: +Composer initiative

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.