Skip to content

Commit 4cf4545

Browse files
committed
Whitelist for CSRF, not XSS
1 parent b15e24d commit 4cf4545

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

inc/admin/namespace.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function get_url( $params = [] ) {
4747
* @return string One of 'add', 'edit', 'delete', or '' for default (list)
4848
*/
4949
function get_page_action() {
50-
return isset( $_GET['action'] ) ? $_GET['action'] : ''; // WPCS: XSS OK
50+
return isset( $_GET['action'] ) ? $_GET['action'] : ''; // WPCS: CSRF OK
5151
}
5252

5353
/**
@@ -118,9 +118,9 @@ class="add-new-h2"><?php echo esc_html_x( 'Add New', 'application', 'oauth2' );
118118
?>
119119
</h2>
120120
<?php
121-
if ( ! empty( $_GET['deleted'] ) ) { // WPCS: XSS OK
121+
if ( ! empty( $_GET['deleted'] ) ) { // WPCS: CSRF OK
122122
echo '<div id="message" class="updated"><p>' . esc_html__( 'Deleted application.', 'oauth2' ) . '</p></div>';
123-
} elseif ( ! empty( $_GET['approved'] ) ) { // WPCS: XSS OK
123+
} elseif ( ! empty( $_GET['approved'] ) ) { // WPCS: CSRF OK
124124
echo '<div id="message" class="updated"><p>' . esc_html__( 'Approved application.', 'oauth2' ) . '</p></div>';
125125
}
126126
?>

inc/admin/profile/namespace.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ function output_profile_messages() {
124124
return;
125125
}
126126

127-
if ( ! empty( $_GET['oauth2_revoked'] ) ) {
127+
if ( ! empty( $_GET['oauth2_revoked'] ) ) { // WPCS: CSRF OK
128128
echo '<div id="message" class="updated"><p>' . __( 'Token revoked.', 'oauth2' ) . '</p></div>';
129129
}
130-
if ( ! empty( $_GET['oauth2_revocation_failed'] ) ) {
130+
if ( ! empty( $_GET['oauth2_revocation_failed'] ) ) { // WPCS: CSRF OK
131131
echo '<div id="message" class="updated"><p>' . __( 'Unable to revoke token.', 'oauth2' ) . '</p></div>';
132132
}
133133
}

inc/authentication/namespace.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ function get_token_from_bearer_header( $header ) {
7575
* @return string|null Token on succes, null on failure.
7676
*/
7777
function get_token_from_request() {
78-
if ( empty( $_GET['access_token'] ) ) { // WPCS: XSS OK
78+
if ( empty( $_GET['access_token'] ) ) { // WPCS: CSRF OK
7979
return null;
8080
}
8181

82-
$token = $_GET['access_token']; // WPCS: XSS OK
82+
$token = $_GET['access_token']; // WPCS: CSRF OK
8383
if ( is_string( $token ) ) {
8484
return $token;
8585
}

inc/endpoints/class-authorization.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public function register_hooks() {
1818

1919
public function handle_request() {
2020
// If the form hasn't been submitted, show it.
21-
if ( isset( $_GET['response_type'] ) ) { // WPCS: XSS OK
22-
$type = wp_unslash( $_GET['response_type'] ); // WPCS: XSS OK
21+
if ( isset( $_GET['response_type'] ) ) { // WPCS: CSRF OK
22+
$type = wp_unslash( $_GET['response_type'] ); // WPCS: CSRF OK
2323
} else {
2424
$type = null;
2525
}

inc/types/class-base.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public function handle_authorisation() {
3535
}
3636

3737
// Gather parameters.
38-
$client_id = wp_unslash( $_GET['client_id'] ); // WPCS: XSS OK
39-
$redirect_uri = isset( $_GET['redirect_uri'] ) ? wp_unslash( $_GET['redirect_uri'] ) : null; // WPCS: XSS OK
40-
$scope = isset( $_GET['scope'] ) ? wp_unslash( $_GET['scope'] ) : null; // WPCS: XSS OK
41-
$state = isset( $_GET['state'] ) ? wp_unslash( $_GET['state'] ) : null; // WPCS: XSS OK
38+
$client_id = wp_unslash( $_GET['client_id'] ); // WPCS: CSRF OK
39+
$redirect_uri = isset( $_GET['redirect_uri'] ) ? wp_unslash( $_GET['redirect_uri'] ) : null; // WPCS: CSRF OK
40+
$scope = isset( $_GET['scope'] ) ? wp_unslash( $_GET['scope'] ) : null; // WPCS: CSRF OK
41+
$state = isset( $_GET['state'] ) ? wp_unslash( $_GET['state'] ) : null; // WPCS: CSRF OK
4242

4343
$client = Client::get_by_id( $client_id );
4444
if ( empty( $client ) ) {

0 commit comments

Comments
 (0)