Fix Semgrep Security Scan Issues (https://github.com/woocommerce/woocommerce-blocks/pull/9204)
* Add late escaping to call in MiniCart. * Add escaping to call in AssetsController. * Add escaping to calls in StoreAPI pagination utils. * Add ignore line to file require - OK. * Minor update to grammar in code comment.
This commit is contained in:
parent
96bd0432cd
commit
aa219a1aa1
|
@ -95,6 +95,8 @@ class Api {
|
|||
);
|
||||
|
||||
if ( file_exists( $asset_path ) ) {
|
||||
// The following require is safe because we are checking if the file exists and it is not a user input.
|
||||
// nosemgrep audit.php.lang.security.file.inclusion-arg.
|
||||
$asset = require $asset_path;
|
||||
$dependencies = isset( $asset['dependencies'] ) ? array_merge( $asset['dependencies'], $dependencies ) : $dependencies;
|
||||
$version = ! empty( $asset['version'] ) ? $asset['version'] : $this->get_file_version( $relative_src );
|
||||
|
|
|
@ -182,7 +182,7 @@ final class AssetsController {
|
|||
$this->api->get_block_asset_build_path( $filename )
|
||||
);
|
||||
$resources = array_merge(
|
||||
[ add_query_arg( 'ver', $script_data['version'], $script_data['src'] ) ],
|
||||
[ esc_url( add_query_arg( 'ver', $script_data['version'], $script_data['src'] ) ) ],
|
||||
$this->get_script_dependency_src_array( $script_data['dependencies'] )
|
||||
);
|
||||
return array_map(
|
||||
|
@ -208,7 +208,7 @@ final class AssetsController {
|
|||
$dependencies,
|
||||
function( $src, $handle ) use ( $wp_scripts ) {
|
||||
if ( isset( $wp_scripts->registered[ $handle ] ) ) {
|
||||
$src[] = add_query_arg( 'ver', $wp_scripts->registered[ $handle ]->ver, $this->get_absolute_url( $wp_scripts->registered[ $handle ]->src ) );
|
||||
$src[] = esc_url( add_query_arg( 'ver', $wp_scripts->registered[ $handle ]->ver, $this->get_absolute_url( $wp_scripts->registered[ $handle ]->src ) ) );
|
||||
$src = array_merge( $src, $this->get_script_dependency_src_array( $wp_scripts->registered[ $handle ]->deps ) );
|
||||
}
|
||||
return $src;
|
||||
|
|
|
@ -181,12 +181,14 @@ class MiniCart extends AbstractBlock {
|
|||
);
|
||||
}
|
||||
|
||||
$template_part_edit_uri = add_query_arg(
|
||||
array(
|
||||
'postId' => sprintf( '%s//%s', $theme_slug, 'mini-cart' ),
|
||||
'postType' => 'wp_template_part',
|
||||
),
|
||||
$site_editor_uri
|
||||
$template_part_edit_uri = esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'postId' => sprintf( '%s//%s', $theme_slug, 'mini-cart' ),
|
||||
'postType' => 'wp_template_part',
|
||||
),
|
||||
$site_editor_uri
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class Pagination {
|
|||
* @return string
|
||||
*/
|
||||
protected function get_link_base( $request ) {
|
||||
return add_query_arg( $request->get_query_params(), rest_url( $request->get_route() ) );
|
||||
return esc_url( add_query_arg( $request->get_query_params(), rest_url( $request->get_route() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue