Problem/Motivation

Related to previous #2181463: New sensor: Botcha bot activity

A sensor to visualize bot activity makes sense.
Unsure about where the data of missing captcha submissions can be queried.

Proposed resolution

Check captcha logging method and trace.

Remaining tasks

User interface changes

API changes

Comments

miro_dietiker’s picture

miro_dietiker’s picture

miro_dietiker’s picture

Priority: Normal » Minor

Lowering priority as this is not a low hanging fruit... With high probability, the captcha module needs improvements in reporting / logs / accessibility of statistics.

berdir’s picture

Priority: Minor » Normal

Actually seems to be not that hard :)

database aggregator sensor on captcha_sessions table, condition 1 on status = 0, condition 2 on attempts > 0. Currently can not be done in the UI, but you can create it except condition 2 and then add that in yml.

Anushka-mp’s picture

Status: Active » Needs review
StatusFileSize
new2.5 KB

Default sensor created for counting the no. of users who has failed attempts. The sensor to count the total number of attempts from all users needs to be created. submitting this for a review.

Anushka-mp’s picture

Test dependancy added.

Anushka-mp’s picture

What about the time interval? failed attempts in past 24 hours? currently there is no time interval added when calculating the result.

The last submitted patch, 5: monitoring-2388713-captcha-bot-activity-5.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 6: monitoring-2388713-captcha-bot-activity-6.patch, failed testing.

berdir’s picture

  1. +++ b/monitoring.install
    @@ -68,6 +68,27 @@ function monitoring_install() {
    +  // Declares captcha faild attempts count sensor.
    +  if (\Drupal::moduleHandler()->moduleExists('captcha')) {
    +    $sensor = SensorConfig::create(array(
    +      'id' => 'captcha_failed_count',
    +      'label' => 'Captcha failed Count',
    +      'description' => 'Monitors the number of failed attempts for Captcha',
    +      'plugin_id' => 'database_aggregator',
    +      'value_label' => 'Attempt(s)',
    +      'value_type' => 'number',
    +      'category' => 'Captcha',
    +      'status' => TRUE,
    +      'settings' => array(
    +        'table' => 'captcha_sessions',
    +        'conditions' => array(
    +          array('field' => 'status', 'value' => 0),
    +        ),
    +      ),
    +    ));
    +    $sensor->save();
    +  }
    

    Move this to default configuration, that's what we have the config/install/$module structure for.

    We only need code for things that are more complex (like dependency on two modules).

    It is also missing the second condition on attempts > 0.

  2. +++ b/src/Tests/MonitoringCaptchaTest.php
    @@ -0,0 +1,52 @@
    +    // Set a CAPTCHA on login form.
    +    captcha_set_form_id_setting('user_login_form', 'captcha/Math');
    

    There is a test captcha plugin that expects a fixed answer. Have a look at their tests. Either that or look up the correct answer in the database after you request the page.

    We need to produce data for all possible combinations:

    - Just visit the form, this should create a session with attempts = 0
    - With a different session/form (you need to check if simply reloading the form is enough to create two rows), submit the form with the wrong answer
    - Yet another session, submit successfully the first time
    - Yet another session, submit first wrong then correct answer.

    Then you should have 4 entries in captcha_sessions (check that with an asserEqual(db_query()->fetchField(), 4). Then run the sensor and it should only report 1.

  • miro_dietiker committed 3523eaa on 8.x-1.x
    Issue #2388713 by miro_dietiker: Test dependency only for New sensor:...
miro_dietiker’s picture

Status: Needs work » Needs review

Test dependency pushed. Let's wait a day and then retest. Should pass all green then.

miro_dietiker’s picture

Status: Needs review » Needs work

Oh, cross post with @sgr review. Needs work then.

Anushka-mp’s picture

Status: Needs work » Needs review
StatusFileSize
new3.46 KB
new2.59 KB

Default configuration created for the sensor and the condition amount > 0 added.
Tests are corrected as mentioned in Berdir's comment.
this would fail, Let's wait for the test dependency and retest.

Status: Needs review » Needs work

The last submitted patch, 14: monitoring-2388713-captcha-bot-activity-14.patch, failed testing.

Anushka-mp’s picture

Interesting, UI test failure. I'll look in to that. :/

Anushka-mp’s picture

UI tests are broken now, created an Issue #2389969: Fix broken UI test due to the core change

miro_dietiker’s picture

Status: Needs work » Fixed

OK. Committed this. UI fails are unrelated.

Status: Fixed » Closed (fixed)

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