Skip to content
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
6 changes: 6 additions & 0 deletions classes/class-object-sync-sf-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ public function process( WP_REST_Request $request ) {
break;
case 'push':
if ( ( 'POST' === $http_method || 'PUT' === $http_method || 'DELETE' === $http_method ) && isset( $body_params['wordpress_object_type'] ) && isset( $body_params['wordpress_id'] ) ) {
// Reject object types that are not registered WordPress objects. This endpoint is
// reachable by unauthenticated callers, so the untrusted object type must never be
// allowed to reach the database layer where it is used to build queries.
if ( ! in_array( $body_params['wordpress_object_type'], $this->wordpress->get_object_types(), true ) ) {
return new WP_Error( 'rest_invalid_object_type', esc_html__( 'Invalid WordPress object type.', 'object-sync-for-salesforce' ), array( 'status' => 400 ) );
}
$result = $this->push->manual_push( $body_params['wordpress_object_type'], $body_params['wordpress_id'], $http_method );
}
break;
Expand Down
6 changes: 3 additions & 3 deletions classes/class-object-sync-sf-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function get_wordpress_table_structure( $object_type ) {
'id_field' => 'ID',
'meta_table' => $this->wpdb->prefix . 'postmeta',
'meta_join_field' => 'post_id',
'where' => 'AND ' . $this->wpdb->prefix . 'posts.post_type = "' . $object_type . '"',
'where' => $this->wpdb->prepare( 'AND ' . $this->wpdb->prefix . 'posts.post_type = %s', $object_type ),
'ignore_keys' => array(),
);
} elseif ( 'user' === $object_type ) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public function get_wordpress_table_structure( $object_type ) {
'id_field' => 'ID',
'meta_table' => $this->wpdb->prefix . 'postmeta',
'meta_join_field' => 'post_id',
'where' => 'AND ' . $this->wpdb->prefix . 'posts.post_type = "' . $object_type . '"',
'where' => $this->wpdb->prepare( 'AND ' . $this->wpdb->prefix . 'posts.post_type = %s', $object_type ),
'ignore_keys' => array(),
);
} elseif ( 'category' === $object_type || 'tag' === $object_type || 'post_tag' === $object_type ) {
Expand Down Expand Up @@ -325,7 +325,7 @@ public function get_wordpress_table_structure( $object_type ) {
'id_field' => 'ID',
'meta_table' => $this->wpdb->prefix . 'postmeta',
'meta_join_field' => 'post_id',
'where' => 'AND ' . $this->wpdb->prefix . 'posts.post_type = "' . $object_type . '"',
'where' => $this->wpdb->prepare( 'AND ' . $this->wpdb->prefix . 'posts.post_type = %s', $object_type ),
'ignore_keys' => array(),
);
} // End if() statement.
Expand Down
Loading