Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update devdependencies (non-major) #258

Merged
merged 2 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions composer.lock

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

12 changes: 4 additions & 8 deletions inc/class-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public function wp_ajax_webauthn_register(): void {
$context
);

// phpcs:ignore WordPress.Security.NonceVerification.Missing -- false positive, check_registration_nonce() does that
$name = sanitize_text_field( (string) ( $_POST['name'] ?? '' ) );
$name = Utils::get_post_field_as_string( 'name' );
$store = new WebAuthn_Credential_Store();
$key = $store->save_user_key( $name, $result );
if ( null === $key ) {
Expand Down Expand Up @@ -163,8 +162,7 @@ public function wp_ajax_webauthn_register(): void {
}

public function wp_ajax_webauthn_delete_key(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- verify_nonce() checks the nonce
$handle = sanitize_text_field( (string) ( $_POST['handle'] ?? '' ) );
$handle = Utils::get_post_field_as_string( 'handle' );
$this->verify_nonce( "delete-key_{$handle}" );

$store = new WebAuthn_Credential_Store();
Expand All @@ -173,12 +171,10 @@ public function wp_ajax_webauthn_delete_key(): void {
}

public function wp_ajax_webauthn_rename_key(): void {
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- verify_nonce() checks the nonce
$handle = sanitize_text_field( (string) ( $_POST['handle'] ?? '' ) );
$handle = Utils::get_post_field_as_string( 'handle' );
$this->verify_nonce( "rename-key_{$handle}" );

// phpcs:ignore WordPress.Security.NonceVerification.Missing -- verify_nonce() checks the nonce
$name = wp_unslash( sanitize_text_field( (string) ( $_POST['name'] ?? '' ) ) );
$name = Utils::get_post_field_as_string( 'name' );
if ( empty( $name ) ) {
wp_send_json_error( __( 'Key name cannot be empty.', 'two-factor-provider-webauthn' ), 400 );
}
Expand Down
11 changes: 11 additions & 0 deletions inc/class-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,15 @@ public static function create_webauthn_server(): ServerInterface {
$builder->enableExtensions( 'appid' );
return $builder->build();
}

public static function get_post_field_as_string( string $field ): string {
// phpcs:disable WordPress.Security.NonceVerification.Missing
if ( isset( $_POST[ $field ] ) && is_scalar( $_POST[ $field ] ) ) {
/** @psalm-suppress RedundantCast -- $_POST is controlled by the user, it can have non-string values */
return wp_unslash( sanitize_text_field( (string) $_POST[ $field ] ) );
}
// phpcs:enable WordPress.Security.NonceVerification.Missing

return '';
}
}
Loading