External Libraries: Test that MediaElement SWF files remain deleted.

The files were removed from Core in r42462 because they're no longer necessary, and have a history of security issues. They remain upstream, though, so this test makes it explicitly clear that they should not be added back in the future without careful consideration and discussion with the Security team.

`Tests_Admin_IncludesUpdateCore::test_new_files_are_not_in_old_files_array_compiled()` would already catch files with the exact same name, but this test will also catch files with new names, just to be extra cautious.

Props iandunn, ocean90, SergeyBiryukov
Fixes 43101


git-svn-id: https://develop.svn.wordpress.org/trunk@42762 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ian Dunn 2018-02-27 14:37:15 +00:00
parent 1cc516f2e8
commit fde455a89f
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php
/**
* @group dependencies
* @group scripts
*/
class Tests_Dependencies_MediaElementjs extends WP_UnitTestCase {
/**
* Test if the MediaElement.js Flash fallbacks have been re-added.
*
* MediaElement's Flash fallbacks were removed in WordPress 4.9.2 due to limited use cases and
* a history of security vulnerabilities. It's unlikely that there'll ever be a need to
* restore them in the future, and doing so could introduce security vulnerabilities. If you
* want to re-add them, please discuss that with the Security team first.
*
* @since 5.0.0
*
* @ticket 42720
*/
function test_exclusion_of_flash() {
$mejs_folder = dirname( ABSPATH ) . '/build/' . WPINC . '/js/mediaelement';
$js_files = glob( $mejs_folder . '/*.js' );
/*
* The path in $mejs_folder is hardcoded, so this is just a sanity check to make sure the
* correct directory is used, in case it gets renamed in the future.
*/
$this->assertGreaterThan( 0, count( $js_files ) );
$mejs_directory_iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $mejs_folder ) );
$mejs_swf_iterator = new RegexIterator( $mejs_directory_iterator, '/\.swf$/i', RecursiveRegexIterator::GET_MATCH );
// Make sure the Flash files haven't been re-added accidentally.
$this->assertCount( 0, iterator_to_array( $mejs_swf_iterator ) );
}
}