Skip to content

Commit

Permalink
Merge pull request #762 from Automattic/fix/740-includingfile-prevent…
Browse files Browse the repository at this point in the history
…-some-false-positives
  • Loading branch information
GaryJones authored Aug 23, 2023
2 parents 3e73ba2 + 08c3909 commit c15f4b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
26 changes: 23 additions & 3 deletions WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,33 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
* @var array
*/
public $getPathFunctions = [
'plugin_dir_path',
'dirname',
'get_404_template',
'get_archive_template',
'get_attachment_template',
'get_author_template',
'get_category_template',
'get_date_template',
'get_embed_template',
'get_front_page_template',
'get_page_template',
'get_paged_template', // Deprecated, but should still be accepted for the purpose of this sniff.
'get_home_template',
'get_index_template',
'get_parent_theme_file_path',
'get_privacy_policy_template',
'get_query_template',
'get_search_template',
'get_single_template',
'get_singular_template',
'get_stylesheet_directory',
'get_tag_template',
'get_taxonomy_template',
'get_template_directory',
'locate_template',
'get_parent_theme_file_path',
'get_theme_file_path',
'locate_block_template',
'locate_template',
'plugin_dir_path',
];

/**
Expand Down
7 changes: 6 additions & 1 deletion WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ include_once dir_function(); // Error - custom functionm with keyword from $al
require CUSTOM_CONSTANT_DIR . 'file.php'; // OK.
require_once ( VIPCS_PATH ) . 'file.php'; // OK.
include_once
DIR_CUSTOM , 'file.php'; // OK.
DIR_CUSTOM , 'file.php'; // OK.

// These are valid (previously false positives).
include( get_404_template() );
require get_query_template( 'post' );
include_once locate_block_template( __DIR__, 'silly_block' );

0 comments on commit c15f4b2

Please sign in to comment.