WordPress / WordPress/WordPress-Coding-Standards

The function rest_is_ip_address should be not issue for sanitize

Open
#2,483 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

A user is reporting in Plugin Check Plugin using WPCS Sanitize check, a possible false positive with the function rest_is_ip_address.

The code shared was this:

// Generate a unique session id
function wppa_get_session_id() {
global $wppa_version;
static $session_id;

	// Found already?
	if ( $session_id ) {
		return $session_id;
	}

	// Look for a cookie
	if ( isset( $_COOKIE['wppa_session_id'] ) ) {
(30)		$t = rest_is_ip_address( wp_unslash( $_COOKIE['wppa_session_id'] ) );
		if ( $t ) {
			$session_id = $t;
			return $session_id;
		}
	}

You can see it in this support post

I believe that this function does not need to have sanitized data as is checking if it's a correct IP.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WPCS Sanitize check and reproduce the reported snippet using rest_is_ip_address with the Plugin Check Plugin. Determine how the check treats this function; done means the valid use no longer produces a false positive while other sanitize violations remain detected.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.