-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-32hw-3pvh-vcvc
* Fixing xss on common controller for Mautic 3.x branch. * Add test cases to validate xss filteration.
- Loading branch information
1 parent
e6a4059
commit 942cb69
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/bundles/UserBundle/Tests/Functional/Controller/PublicControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* @copyright 2021 Mautic Contributors. All rights reserved | ||
* @author Mautic | ||
* | ||
* @link http://mautic.org | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace Mautic\UserBundle\Tests\Functional\Controller; | ||
|
||
use Mautic\CoreBundle\Test\MauticMysqlTestCase; | ||
|
||
class PublicControllerTest extends MauticMysqlTestCase | ||
{ | ||
/** | ||
* Tests to ensure that xss is prevented on password reset page. | ||
*/ | ||
public function testXssFilterOnPasswordReset(): void | ||
{ | ||
$this->client->request('GET', '/passwordreset?bundle=%27-alert("XSS%20TEST%20Mautic")-%27'); | ||
$clientResponse = $this->client->getResponse(); | ||
$this->assertSame(200, $clientResponse->getStatusCode(), 'Return code must be 200.'); | ||
$responseData = $clientResponse->getContent(); | ||
// Tests that actual string is not present. | ||
$this->assertStringNotContainsString('-alert("xss test mautic")-', $responseData, 'XSS injection attempt is filtered.'); | ||
// Tests that sanitized string is passed. | ||
$this->assertStringContainsString('alertxsstestmautic', $responseData, 'XSS sanitized string is present.'); | ||
} | ||
} |