Skip to content

Commit

Permalink
Amend login failure event being reported by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
estringana committed Feb 18, 2025
1 parent 30bf5fd commit b6cdc6b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/DDTrace/Integrations/WordPress/WordPressIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ function ($args, $retval) {
if (!function_exists('\datadog\appsec\track_user_login_failure_event_automated')) {
return;
}
if (empty($username)) {
return;
}
$errorClass = '\WP_Error';
$exists = $retval instanceof $errorClass &&
\property_exists($retval, 'errors') &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public function testUserLoginSuccessEvent()
$this->assertEquals($name, $events[0]['metadata']['name']);
}

public function testHittingLoginPageDoesNotGenerateUserEvent()
{
$spec = GetSpec::create('request', '/wp-login.php');
$this->call($spec, [CURLOPT_FOLLOWLOCATION => true, CURLOPT_COOKIESESSION => true]);

$events = AppsecStatus::getInstance()->getEvents(['track_user_login_failure_event_automated']);
$this->assertEquals(0, count($events));
}

public function testUserLoginFailureEventWhenUserDoesNotExists()
{
$email = '[email protected]';
Expand Down
18 changes: 18 additions & 0 deletions tests/Integrations/WordPress/V6_1/AutomatedLoginEventsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace DDTrace\Tests\Integrations\WordPress\V6_1;

use DDTrace\Tests\Integrations\WordPress\AutomatedLoginEventsTestSuite;

/**
* @group appsec
*/
class AutomatedLoginEventsTest extends AutomatedLoginEventsTestSuite
{
public static $database = "wp61";

public static function getAppIndexScript()
{
return __DIR__ . '/../../../Frameworks/WordPress/Version_6_1/index.php';
}
}

0 comments on commit b6cdc6b

Please sign in to comment.