Caching (#1894452: caching data locally) is broken:

      if (!empty($data['email'])) {
        foreach ($data['email'] as $data_email) {
          $expire_email = $data_email['appears'] ? $expire : $expire_false;
          cache_set("email:{$data_email['value']}", $data_email, 'cache_spambot', $expire_email);
        }
      }
      if (!empty($data['username'])) {
        foreach ($data['username'] as $data_username) {
          $expire_username = $data_username['appears'] ? $expire : $expire_false;
          cache_set("username:{$query['username']}", $data_username, 'cache_spambot', $expire_username);
        }
      }
      if (!empty($data['ip'])) {
        $expire_ip = $data['ip']['appears'] ? $expire : $expire_false;
        cache_set("ip:{$query['ip']}", $data['ip'], 'cache_spambot', $expire_ip);
      }

The structure for 'email' and 'username' is the same as for 'ip'. The foreach's are wrong.

The meaning of $expire vs. $expire_false is unclear and there's no explanation -- it's unclear whether 'ip' is doing the right thing...

Comments

salvis created an issue. See original summary.

indigoxela’s picture

Caching is broken:

Almost. It's broken, if usernames get checked.

I'm not sure, if anyone's interested (not much activity here), but this is how we fixed it in Backdrop: https://github.com/backdrop-contrib/spambot/issues/1#issuecomment-903258630

The change it needs is relatively small. And the patch might even apply on the D7 version. I didn't try ;-)

BTW: there's a duplicate issue in this queue: https://www.drupal.org/project/spambot/issues/3180665
Or rather, this here is a duplicate but as this one provides a little more info, I decided to post here.

salvis’s picture

Thank you, indigoxela!

So, email would be correct, just not username?

indigoxela’s picture

So, email would be correct, just not username?

Yes, that was our finding.

You can easily verify by putting a debug($data); into function spambot_sfs_request(). Only email is a nested array.

magicmyth’s picture

StatusFileSize
new820 bytes

This issue seems to now throw a TypeError in newer PHP versions. Attached is a patch porting over the Backdrop fix (https://github.com/backdrop-contrib/spambot/pull/2).

kala4ek’s picture

Assigned: Unassigned » kala4ek
Status: Active » Needs review

  • kala4ek committed 0002549a on 7.x-1.x authored by magicmyth
    Issue #3189946 by magicmyth, salvis, indigoxela, kala4ek: Warning:...
kala4ek’s picture

Assigned: kala4ek » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.