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

Purge session tokens as they includes users' IP addresses #18

Merged
merged 1 commit into from
Aug 23, 2024
Merged
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
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