Making WordPress.org

Changeset 14808


Ignore:
Timestamp:
04/13/2026 03:08:50 AM (6 months ago)
Author:
dd32
Message:

Harden the Community Deputies Caneldar webhook.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/slack/community-deputies-calendly-webhook.php

    r12736 r14808  
    1818        }
    1919
    20         $req = wp_remote_get(
     20        if ( 'api.calendly.com' !== parse_url( $url, PHP_URL_HOST ) ) {
     21                trigger_error(
     22                        'Invalid URL provided to api_request, only api.calendly.com URLs are allowed.',
     23                        E_USER_WARNING
     24                );
     25
     26                return false;
     27        }
     28
     29        $req = wp_safe_remote_get(
    2130                $url,
    2231                [
    … …  
    4150
    4251// Check the request is valid.
    43 if ( empty( $_GET['secret'] ) || $_GET['secret'] !== COMMUNITY_CALENDLY_SECRET ) {
    44         die();
     52if ( empty( $_GET['secret'] ) || ! hash_equals( COMMUNITY_CALENDLY_SECRET, $_GET['secret'] ) ) {
     53        header( 'HTTP/1.1 403 Forbidden' );
     54        die( 'Invalid secret provided.' );
    4555}
    4656
    … …  
    4959$event               = $request_body_parsed->event ?? '';
    5060if ( ! $event ) {
    51         die();
     61        header( 'HTTP/1.1 400 Bad Request' );
     62        die( 'Invalid event provided.' );
    5263}
    5364
Note: See TracChangeset for help on using the changeset viewer.