Page MenuHomePhabricator

Special:CheckUserLog and checkuserlog API do not handle IP ranges the same way
Open, Needs TriagePublicBUG REPORT

Description

While writing a script that interfaces with the checkuser log API, I discovered that it does not handle IP ranges in the same way as Special:CheckUserLog. Searching for an IP or range in Special:CheckUserLog will return checks overlapping the search target (so if I search for 192.168.1.0/24, it will return checks made on 192.168.1.1 and on 192.168.0.0/16). The API, on the other hand, only returns exact matches to the IP or range that was searched.

List of steps to reproduce (step by step, including full links if applicable):

What happens?:
The two searches should return the same list of checks.

What should have happened instead?:
The two results differ - Special:CheckUser lists both checks I made (as well as a few past checks that were overly-broad), while the API lists only the range check that I made.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc: I think the API is performing an exact string match rather than handling the IP as an IP - if I search both the Special: page and the API for 192.0.2.1/24 (https://en.wikipedia.org/w/api.php?action=query&format=json&list=checkuserlog&cultarget=192.0.2.1%2F24), Special:CheckUserLog returns the same results (expected) but the API now returns no results (not expected).

Event Timeline

You are right about the comparison being simply text. Relevant code:

if ( isset( $params['target'] ) ) {
	$this->addWhereFld( 'cul_target_text', $params['target'] );
}

I'll write a patch for this.

Change 791792 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@master] Allow CheckUserLog API to parse CIDR ranges

https://gerrit.wikimedia.org/r/791792

I'll claim this as I've written a patch.