Skip to content

Commit

Permalink
Merge pull request #6080 from Automattic/staging
Browse files Browse the repository at this point in the history
Production release: v20250107.0
  • Loading branch information
luiztiago authored Jan 7, 2025
2 parents bdc8e59 + 38cbe91 commit 2121e08
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-wp-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ runs:
"${PHPUNIT}" ${OPTIONS}
- name: Upload coverage report
uses: codecov/codecov-action@v5.0.7
uses: codecov/codecov-action@v5.1.1
with:
files: ${{ inputs.coverage-file }}
flags: ${{ inputs.coverage-flags }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
uses: actions/[email protected]

- name: Initialize CodeQL
uses: github/codeql-action/[email protected].5
uses: github/codeql-action/[email protected].6
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql-config.yml

- name: Perform CodeQL Analysis
uses: github/codeql-action/[email protected].5
uses: github/codeql-action/[email protected].6
35 changes: 21 additions & 14 deletions files/acl/acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,32 @@ function get_option_as_bool_if_exists( $option_name ) {
/**
* Check if the path is allowed for the current context.
*
* @param string $file_path Path to the file, minus the `/wp-content/uploads/` bit. It's the second portion returned by `Pre_Wp_Utils\prepare_request()`
* @param string $file_path Path to the file, minus the `/wp-content/uploads/` bit.
* This is the second portion returned by `Pre_Wp_Utils\prepare_request()`.
* @return bool True if the file path is valid for the current site, false otherwise.
*/
function is_valid_path_for_site( $file_path ) {
if ( ! is_multisite() ) {
return true;
}

// If main site, don't allow access to /sites/ subdirectories.
if ( is_main_network() && is_main_site() ) {
if ( 0 === strpos( $file_path, 'sites/' ) ) {
return false;
$is_valid = true;

if ( is_multisite() ) {
// If main site, don't allow access to `/sites/` subdirectories.
if ( is_main_network() && is_main_site() ) {
$is_valid = ! str_starts_with( $file_path, 'sites/' );
} else {
// Check if the file path matches the current site ID's directory.
$base_path = sprintf( 'sites/%d', get_current_blog_id() );
$is_valid = str_starts_with( $file_path, $base_path );
}

return true;
}

$base_path = sprintf( 'sites/%d', get_current_blog_id() );

return 0 === strpos( $file_path, $base_path );
/**
* Filter the result of the path validation for the current site.
* Allows to override the logic used to determine if a file path is valid for the current site.
*
* @param bool $is_valid Whether the file path is valid for the current site.
* @param string $file_path Path to the file, minus the `/wp-content/uploads/` bit.
*/
return apply_filters( 'vip_files_acl_is_valid_path_for_site', $is_valid, $file_path );
}

/**
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2121e08

Please sign in to comment.