mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-03 05:41:52 +09:00
* Validate redirect paths and targets * Sanitize guest client data and misc cleanups * Implement API rate limiting and pruning * Bump `last_patch` setting to 54 * Add tests for `shouldUseTokenLogin` logic Add tests to cover logic added in #3451. * Add order/renewal line config for domain pricing Resolves #2793. * Add PayPalEmail adapter subscription test * Add width/height styling for textarea fields Resolves #2448. * Send invoice-created email on approve Resolves #3012. * Enforce cumulative cart stock and stockSale Resolves #3130. * Centralize subscription period retrieval Resolves #1035. * Support wildcard staff permissions (default.all) Resolves #2376. * Enable quantity selection and enforce stock max Resolves #2573. * Extend order expiry on first paid invoice Resolves #2864. * Rate-limit request prefix; invoice & promo fixes * Update src/modules/Redirect/templates/admin/mod_redirect_settings.html.twig Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Api/Service.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Client/Controller/Client.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Cron/Service.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix quantity not passed to getOrderLineConfig in createOrder Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/669f845c-50c4-4f7e-95cd-f44de162ad72 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Simplify quantity injection into getOrderLineConfig call Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/669f845c-50c4-4f7e-95cd-f44de162ad72 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Fix rate limit prefix isolation, whitelist headers, and staff controller prefix Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/11f3fd58-bb44-46a5-a6cf-0992b038f4a7 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Enforce promo usage limit and add test --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
153 lines
4.5 KiB
PHP
153 lines
4.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Box\Mod\Redirect;
|
|
|
|
use FOSSBilling\Exception;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
|
|
#[Group('Core')]
|
|
final class ServiceTest extends \BBTestCase
|
|
{
|
|
public function testValidateTargetAllowsRelativePath(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('/new-page', $service->validateTarget('/new-page'));
|
|
}
|
|
|
|
public function testValidateTargetAllowsRelativePathWithoutSlash(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('new-page', $service->validateTarget('new-page'));
|
|
}
|
|
|
|
public function testValidateTargetAllowsHttpUrl(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('http://example.com/page', $service->validateTarget('http://example.com/page'));
|
|
}
|
|
|
|
public function testValidateTargetAllowsHttpsUrl(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('https://example.com/page', $service->validateTarget('https://example.com/page'));
|
|
}
|
|
|
|
public function testValidateTargetTrimsWhitespace(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('/new-page', $service->validateTarget(' /new-page '));
|
|
}
|
|
|
|
public function testValidateTargetRejectsEmptyString(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget('');
|
|
}
|
|
|
|
public function testValidateTargetRejectsWhitespaceOnly(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget(' ');
|
|
}
|
|
|
|
public function testValidateTargetRejectsJavascriptScheme(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget('javascript:alert(1)');
|
|
}
|
|
|
|
public function testValidateTargetRejectsJavascriptSchemeMixedCase(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget('JaVaScRiPt:alert(1)');
|
|
}
|
|
|
|
public function testValidateTargetRejectsDataScheme(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget('data:text/html,<h1>test</h1>');
|
|
}
|
|
|
|
public function testValidateTargetRejectsFtpScheme(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget('ftp://example.com/file');
|
|
}
|
|
|
|
public function testValidateTargetRejectsCrLfInjection(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget("/new-page\r\nLocation: https://evil.com");
|
|
}
|
|
|
|
public function testValidateTargetRejectsLfInjection(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget("/new-page\nLocation: https://evil.com");
|
|
}
|
|
|
|
public function testValidateTargetRejectsCrInjection(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validateTarget("/new-page\rLocation: https://evil.com");
|
|
}
|
|
|
|
public function testValidatePathStripsSlashes(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('old-page', $service->validatePath('/old-page/'));
|
|
}
|
|
|
|
public function testValidatePathAllowsNestedPath(): void
|
|
{
|
|
$service = new Service();
|
|
$this->assertSame('some/nested/path', $service->validatePath('/some/nested/path/'));
|
|
}
|
|
|
|
public function testValidatePathRejectsEmptyString(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validatePath('');
|
|
}
|
|
|
|
public function testValidatePathRejectsSlashOnly(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validatePath('/');
|
|
}
|
|
|
|
public function testValidatePathRejectsPathTraversal(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validatePath('../config');
|
|
}
|
|
|
|
public function testValidatePathRejectsEmbeddedPathTraversal(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validatePath('foo/../../etc/passwd');
|
|
}
|
|
|
|
public function testValidatePathRejectsCrLf(): void
|
|
{
|
|
$service = new Service();
|
|
$this->expectException(Exception::class);
|
|
$service->validatePath("old-page\r\nX-Header: evil");
|
|
}
|
|
}
|