Skip to content

Commit

Permalink
Purge session tokens as they includes users' IP addresses. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethitter authored Aug 23, 2024
1 parent 592b611 commit a7e23a9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions classes/class-clean-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class Clean_DB {
public function __construct() {
$this->_delete_posts();
$this->_clean_users_table();
$this->_clean_usermeta_table();
$this->_clean_comments_table();
$this->_change_admin_email();
}
Expand Down Expand Up @@ -170,6 +171,25 @@ private function _clean_users_table(): void {
$wpdb->query( "UPDATE {$wpdb->users} SET user_email='[email protected]';" );
}

/**
* Remove sensitive data from the usermeta table.
*
* @return void
*/
private function _clean_usermeta_table(): void {
global $wpdb;

WP_CLI::line( " * Removing PII from {$wpdb->usermeta}." );

// Session tokens include users' IP address.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s;",
'session_tokens'
)
);
}

/**
* Remove sensitive data from the comments table.
*
Expand Down

0 comments on commit a7e23a9

Please sign in to comment.