Skip to content

Commit fba9562

Browse files
committed
Merge branch 'hotfix/21.0.9' into develop
2 parents ce2824a + 02de3b2 commit fba9562

23 files changed

+56
-47
lines changed

src/lib/src/ActionRouter/Actions/MfaEmailAutoLogin.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class MfaEmailAutoLogin extends BaseAction {
1919
protected function exec() {
2020
$con = self::con();
2121
$mfaCon = $con->comps->mfa;
22+
$userID = (int)$this->action_data[ 'user_id' ];
2223

23-
$user = Services::WpUsers()->getUserById( $this->action_data[ 'user_id' ] );
24+
$user = Services::WpUsers()->getUserById( $userID );
2425
if ( empty( $user ) ) {
2526
throw new ActionException( __( 'No such user', 'wp-simple-firewall' ) );
2627
}
@@ -43,19 +44,19 @@ protected function exec() {
4344
if ( $emailProvider->validateLoginIntent( $mfaCon->findHashedNonce( $user, $this->action_data[ 'login_nonce' ] ) ) ) {
4445
$success = true;
4546
$emailProvider->postSuccessActions();
46-
wp_set_auth_cookie( $this->action_data[ 'user_id' ], true );
47-
$con->fireEvent( '2fa_success' );
47+
wp_set_auth_cookie( $userID, true );
48+
$con->comps->events->fireEvent( '2fa_success' );
4849
}
4950
}
5051
catch ( \Exception $e ) {
5152
error_log( 'failed auto login:'.$e->getMessage() );
5253
}
5354
finally {
54-
$con->fireEvent(
55+
$con->comps->events->fireEvent(
5556
$success ? '2fa_verify_success' : '2fa_verify_fail',
5657
[
5758
'audit_params' => [
58-
'user_login' => $this->action_data[ 'user_id' ],
59+
'user_login' => $userID,
5960
'method' => $emailProvider->getProviderName(),
6061
]
6162
]

src/lib/src/ActionRouter/Actions/Render/Components/Email/MfaLoginCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ protected function getBodyData() :array {
2828
],
2929
'hrefs' => [
3030
'login_link' => 'https://clk.shldscrty.com/96',
31-
'auto_login' => $this->action_data[ 'url_auto_login' ],
31+
'auto_login' => esc_url( $this->action_data[ 'url_auto_login' ] ), // Internally generated via noncedPluginAction(); template uses |raw
3232
],
3333
'strings' => [
3434
'someone' => __( 'Someone attempted to login into this WordPress site using your account.', 'wp-simple-firewall' ),
3535
'requires' => __( 'Login requires verification with the following code.', 'wp-simple-firewall' ),
3636
'verification' => __( 'Verification Code', 'wp-simple-firewall' ),
3737
'auto_login' => __( 'Autologin URL', 'wp-simple-firewall' ),
3838
'details_heading' => __( 'Login Details', 'wp-simple-firewall' ),
39-
'details_url' => sprintf( '%s: %s', $common[ 'url_label' ], $this->action_data[ 'home_url' ] ),
39+
'details_url' => sprintf( '%s: %s', $common[ 'url_label' ], $this->action_data[ 'home_url' ] ), // Internally generated via getHomeUrl()
4040
'details_username' => sprintf( '%s: %s', $common[ 'username' ],
4141
Services::WpUsers()->getUserById( $this->action_data[ 'user_id' ] )->user_login ),
4242
'details_ip' => sprintf( '%s: %s', $common[ 'ip_address' ], $this->action_data[ 'ip' ] ),

src/lib/src/ActionRouter/Actions/Render/Components/Email/UnblockMagicLink.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function getBodyData() :array {
1919
$con = self::con();
2020
$user = Services::WpUsers()->getUserById( $this->action_data[ 'user_id' ] )->user_login;
2121
$ip = $this->action_data[ 'ip' ];
22-
$homeURL = $this->action_data[ 'home_url' ];
22+
$homeURL = $this->action_data[ 'home_url' ]; // Internally generated via getHomeUrl()
2323
$common = CommonDisplayStrings::pick( [
2424
'important_label',
2525
'details_label',
@@ -30,6 +30,7 @@ protected function getBodyData() :array {
3030

3131
return [
3232
'hrefs' => [
33+
// Internally generated - don't escape here as template auto-escapes
3334
'unblock' => $con->plugin_urls->noncedPluginAction(
3435
IpAutoUnblockShieldUserLinkVerify::class,
3536
$homeURL,

src/lib/src/ActionRouter/Actions/Render/Components/Email/UserLoginNotice.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class UserLoginNotice extends EmailBase {
1111
public const SLUG = 'email_user_login_notice';
1212
public const TEMPLATE = '/email/user_login_notice.twig';
1313

14+
// URLs are internally generated via getHomeUrl() - don't escape here as template auto-escapes
1415
protected function getBodyData() :array {
1516
$common = CommonDisplayStrings::pick( [
1617
'site_url_label',

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/Activity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Activity extends Base {
1313
public const TEMPLATE = '/wpadmin/components/ip_analyse/ip_audittrail.twig';
1414

1515
protected function getRenderData() :array {
16-
$logLoader = ( new LoadLogs() )->setIP( $this->action_data[ 'ip' ] );
16+
$logLoader = ( new LoadLogs() )->setIP( $this->getAnalyseIP() );
1717
$logLoader->limit = 100;
1818

1919
$logs = [];

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/Base.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace FernleafSystems\Wordpress\Plugin\Shield\ActionRouter\Actions\Render\Components\IpAnalyse;
44

55
use FernleafSystems\Wordpress\Plugin\Shield\ActionRouter\Actions\Render;
6+
use FernleafSystems\Wordpress\Plugin\Shield\ActionRouter\Exceptions\ActionException;
67
use FernleafSystems\Wordpress\Services\Services;
78

89
class Base extends Render\BaseRender {
@@ -19,4 +20,14 @@ protected function getTimeAgo( int $ts ) :string {
1920
->setTimestamp( $ts )
2021
->diffForHumans();
2122
}
23+
24+
/**
25+
* @throws ActionException
26+
*/
27+
protected function getAnalyseIP() :string {
28+
if ( !Services::IP()->isValidIp( $this->action_data[ 'ip' ] ) ) {
29+
throw new ActionException( __( "A valid IP address wasn't provided.", 'wp-simple-firewall' ) );
30+
}
31+
return $this->action_data[ 'ip' ];
32+
}
2233
}

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/BotSignals.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class BotSignals extends Base {
1515
protected function getRenderData() :array {
1616
$signals = [];
1717
$scores = ( new CalculateVisitorBotScores() )
18-
->setIP( $this->action_data[ 'ip' ] )
18+
->setIP( $this->getAnalyseIP() )
1919
->scores();
2020
try {
2121
$record = ( new BotSignalsRecord() )
22-
->setIP( $this->action_data[ 'ip' ] )
22+
->setIP( $this->getAnalyseIP() )
2323
->retrieve();
2424
}
2525
catch ( \Exception $e ) {

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/Container.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ class Container extends Base {
1111
public const TEMPLATE = '/wpadmin/components/ip_analyse/container.twig';
1212

1313
protected function getRenderData() :array {
14-
$ip = $this->action_data[ 'ip' ];
15-
if ( !Services::IP()->isValidIp( $ip ) ) {
16-
throw new \Exception( __( "A valid IP address wasn't provided.", 'wp-simple-firewall' ) );
17-
}
14+
$ip = $this->getAnalyseIP();
1815
$actionRouter = self::con()->action_router;
1916
return [
2017
'content' => [

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/General.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class General extends Base {
2121
public const TEMPLATE = '/wpadmin/components/ip_analyse/ip_general.twig';
2222

2323
protected function getRenderData() :array {
24-
$ip = $this->action_data[ 'ip' ];
24+
$ip = $this->getAnalyseIP();
2525

2626
$countryCode = ( new LookupMeta() )
2727
->setIP( $ip )

src/lib/src/ActionRouter/Actions/Render/Components/IpAnalyse/Sessions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function getRenderData() :array {
1515
$WP = Services::WpGeneral();
1616

1717
$allSessions = [];
18-
foreach ( ( new FindSessions() )->byIP( $this->action_data[ 'ip' ] ) as /* $userID => */ $sessions ) {
18+
foreach ( ( new FindSessions() )->byIP( $this->getAnalyseIP() ) as /* $userID => */ $sessions ) {
1919
foreach ( $sessions as $session ) {
2020
$loginAt = $session[ 'login' ];
2121
$activityAt = $session[ 'shield' ][ 'last_activity_at' ] ?? $loginAt;

0 commit comments

Comments
 (0)