Add argument validation on telemetry endpoint

Properly validate the platform and version parameters in the request
body for telemetry requests.
This commit is contained in:
Josh Betz 2021-08-26 13:35:20 -05:00
parent 55dd00852a
commit 8175045305
1 changed files with 14 additions and 1 deletions

View File

@ -123,7 +123,20 @@ class WC_REST_Telemetry_V2_Controller extends WC_REST_Controller {
*/
public function get_collection_params() {
return array(
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
'platform' => array(
'description' => __( 'Platform to track.', 'woocommerce' ),
'required' => true,
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
),
'version' => array(
'description' => __( 'Platform version to track.', 'woocommerce' ),
'required' => true,
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
),
);
}
}