Fix five findings from a security assessment of the plugin
CI / Coding Standards (pull_request) Failing after 28s
CI / Tests (PHP 8.5) (pull_request) Failing after 27s
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.1) (pull_request) Failing after 39s
CI / Tests (PHP 8.3) (pull_request) Failing after 1m7s
CI / Tests (PHP 8.2) (pull_request) Failing after 1m8s
CI / Static Analysis (pull_request) Successful in 1m17s
CI / Build Plugin Zip (pull_request) Skipped
CI / Coding Standards (pull_request) Failing after 28s
CI / Tests (PHP 8.5) (pull_request) Failing after 27s
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.1) (pull_request) Failing after 39s
CI / Tests (PHP 8.3) (pull_request) Failing after 1m7s
CI / Tests (PHP 8.2) (pull_request) Failing after 1m8s
CI / Static Analysis (pull_request) Successful in 1m17s
CI / Build Plugin Zip (pull_request) Skipped
The assessment looked for three things: whether students can reach each other's bookings, whether payment settings can be dodged, and whether the plugin opens a way into the rest of the install. The student-isolation and payment paths held up. These are what did not. - The front-end login form told WordPress not to work out whether the site was secure, so on HTTPS every student's session cookie was issued without the Secure flag. wp_signon() only derives it from is_ssl() when the second argument is left at its default; an explicit false reads like "no preference" and is not. - The update check took whatever download URL the release API returned and handed it to core, which unpacks it over the installed plugin. The package must now be https on git.unsupervised.ca exactly, compared on the parsed host so a lookalike name cannot pass. - Uninstalling dropped 2 of 14 tables and left the Stripe secret and webhook signing key in wp_options. Removal is now a choice made in advance on Access -> Plugin removal: records are kept unless the owner opts in (with a typed confirmation), while credentials and the borrowed core registration settings go every time. - Open registration switches on the site-wide users_can_register and makes Student the default role, arming any other signup form on the site to mint students who could book and be billed immediately. The pending state is now decided once, on user_register, rather than by whichever form created the account. - Cancel and withdraw answered "not yours" differently from "does not exist", which let a signed-in student enumerate the studio's bookings. Both now give the same 404. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -9,6 +9,7 @@ use Unsupervised\Schedular\Auth\Invite;
|
||||
use Unsupervised\Schedular\Auth\InviteRepository;
|
||||
use Unsupervised\Schedular\Auth\RegistrationMailer;
|
||||
use Unsupervised\Schedular\Auth\RegistrationPage;
|
||||
use Unsupervised\Schedular\Auth\RegistrationStatus;
|
||||
use Unsupervised\Schedular\GroupClass\GroupAccessRepository;
|
||||
use Unsupervised\Schedular\Guardian\GuardianService;
|
||||
use Unsupervised\Schedular\Payment\StudioSettings;
|
||||
@@ -29,6 +30,9 @@ class RegistrationPageTest extends TestCase
|
||||
/** @var array<string, mixed> */
|
||||
private array $ctx;
|
||||
|
||||
/** @var list<string> User meta keys cleared during the submit under test. */
|
||||
private array $clearedMeta = [];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -52,6 +56,20 @@ class RegistrationPageTest extends TestCase
|
||||
Functions\when('wp_enqueue_script')->justReturn(null);
|
||||
Functions\when('wp_localize_script')->justReturn(true);
|
||||
|
||||
// Both success branches clear pending meta on the account they just
|
||||
// created — the invited student is approved outright, the self-signup is
|
||||
// marked unconfirmed. Recorded rather than counted so a test can say
|
||||
// which, without every other test having to expect the calls.
|
||||
$this->clearedMeta = [];
|
||||
$cleared = &$this->clearedMeta;
|
||||
Functions\when('delete_user_meta')->alias(
|
||||
static function (int $userId, string $key) use (&$cleared): bool {
|
||||
$cleared[] = $key;
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
$invites = Mockery::mock(InviteRepository::class);
|
||||
$policies = Mockery::mock(PolicyRepository::class);
|
||||
$questions = Mockery::mock(QuestionRepository::class);
|
||||
@@ -149,6 +167,24 @@ class RegistrationPageTest extends TestCase
|
||||
self::assertSame('invite', $this->submit($invite, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* The registration gate holds every student account created by an
|
||||
* unauthenticated request, which is what a signup is — so the invite branch
|
||||
* has to say that this one is different. Without it an invited student is
|
||||
* logged straight in and then told they cannot book.
|
||||
*/
|
||||
public function testInvitedStudentIsApprovedRatherThanLeftAwaitingApproval(): void
|
||||
{
|
||||
$_POST = [ 'password' => 'thistle-marrow-42', 'display_name' => 'Ada', 'birth_year' => '1990' ];
|
||||
|
||||
$this->stubInviteSuccess();
|
||||
|
||||
$invite = new Invite(email: '[email protected]', token: 'hash');
|
||||
|
||||
self::assertSame('invite', $this->submit($invite, false));
|
||||
self::assertContains(RegistrationStatus::META_AWAITING_APPROVAL, $this->clearedMeta);
|
||||
}
|
||||
|
||||
public function testInviteAcceptanceLinksClassGrantForTheEmail(): void
|
||||
{
|
||||
$_POST = [ 'password' => 'thistle-marrow-42', 'display_name' => 'Ada', 'birth_year' => '1990' ];
|
||||
|
||||
Reference in New Issue
Block a user