Page MenuHomePhabricator

No results on CheckUser query from 127.0.0.1 on PostgreSQL
Closed, ResolvedPublic

Description

When asked for username IP addresses or edits CheckUser might return entries for 127.0.0.1 (for internally generated entries via FauxRequest etc.).

When asked for users on 127.0.0.1 no results are shown, however.

select * from cu_changes where cuc_ip_hex = '7F000001';

returns no results

It seems like 127.0.0.1 entries are stored like this:

# select * from cu_changes where cuc_ip_hex='0';

-[ RECORD 1 ]--+--------------------------------
cuc_id         | 68
cuc_namespace  | 90
cuc_title      | Dyskusja_użytkownika:Saper/test
cuc_user       | 1
cuc_user_text  | Saper
cuc_actiontext | 
cuc_comment    | Nowy wątek  test
cuc_minor      | 1
cuc_page_id    | 1717
cuc_this_oldid | 63082
cuc_last_oldid | 0
cuc_type       | 1
cuc_timestamp  | 2012-05-07 23:21:58+02
cuc_ip         | 127.0.0.1/32
cuc_ip_hex     | 0
cuc_xff        | 
cuc_xff_hex    | 
cuc_agent      |

and have cuc_ip_hex stored as zero instead of 7F0001

For MySQL 127.0.0.1 entries are correct:

        cuc_id: 22
 cuc_namespace: 4
     cuc_title: Książki/Moja_książka
      cuc_user: 1
 cuc_user_text: Saper
cuc_actiontext: 
   cuc_comment: Utworzył nową stronę „{{zapisane_książki}}  == Moja książka == === test === :[[Strona główna]]  [[Kategoria:Książki|Książki/Moja książka]]”
     cuc_minor: 0
   cuc_page_id: 8
cuc_this_oldid: 15
cuc_last_oldid: 0
      cuc_type: 1
 cuc_timestamp: 20120301052308
        cuc_ip: 127.0.0.1
    cuc_ip_hex: 7F000001
       cuc_xff: 
   cuc_xff_hex: NULL
     cuc_agent: 
4 rows in set (0.00 sec)

Version: master
Severity: normal

Details

Reference
bz37971

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:29 AM
bzimport added a project: CheckUser.
bzimport set Reference to bz37971.

overlordq wrote:

If I had to hazard a guess it's because toHex/toUnsigned in the IP class isn't stripping off the prefix size before passing it to ip2long, which then returns false and there's no error checking.

Yes, looks something like that. What wonders me is why other IPv4 addresses work :)

overlordq wrote:

Meh, my first commit in a while, pushed to gerrit.

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

"in review" is not quite the right status here as it's been abandoned since 2013

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.

Dreamy_Jazz subscribed.

Will test that this still is the case. If it's still the case I'll fix it.

Has since been resolved from my testing (var export of the 127.0.0.1 row from the DB shown below):

image.png (37×407 px, 5 KB)