From b1708129055bd2e5a6904586f5503a330e7044a9 Mon Sep 17 00:00:00 2001 From: roble Date: Sat, 7 Nov 2026 12:55:10 +0000 Subject: [PATCH 1/3] fix: sanitise product descriptions on read with core's SanitizedHtml cast (sc-1131) Co-Authored-By: Claude Opus 5.5 --- .../skills/saucebase-billing-development/SKILL.md | 1 + src/Models/Product.php | 3 +++ tests/Feature/BillingPlansPageTest.php | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/resources/boost/skills/saucebase-billing-development/SKILL.md b/resources/boost/skills/saucebase-billing-development/SKILL.md index fb51319..bdb9c66 100644 --- a/resources/boost/skills/saucebase-billing-development/SKILL.md +++ b/resources/boost/skills/saucebase-billing-development/SKILL.md @@ -261,6 +261,7 @@ purpose allows it by pattern, e.g. - **Runs on SQLite, MySQL and PostgreSQL.** Raw SQL that differs between them goes through one place: month grouping is `Filament\Traits\GroupsByMonth::monthOf()`, and counting matches is `SUM(CASE WHEN … THEN 1 ELSE 0 END)` (PostgreSQL cannot `SUM` a boolean). Any value typed into a URL that reaches a `uuid` column must be checked first (`whereUuid()` on routes, `Str::isUuid()` otherwise): PostgreSQL rejects a malformed UUID with an error, not an empty result. The suite passes on PostgreSQL with `DB_CONNECTION=pgsql` and the usual `DB_*` variables +- `Product::description` is rich-editor HTML, also imported from the provider, rendered with `v-html` on the pricing and checkout pages. It is cast with core's `SanitizedHtml` (`Str::sanitizeHtml()` on read, stored as written), so every read is safe markup (sc-1131) - `CheckoutSession` uses `uuid` as the route key (not `id`) — always resolve via UUID in URLs - Every `provider_*_id` is namespaced by a `provider` column (the gateway driver slug). Look rows up with both, never by the provider ID alone; uniqueness is `(provider, provider_x_id)` - `subscriptions.last_event_at` is when the last applied provider event happened. `SubscriptionUpdated`/`Deleted` skip events older than it, so a late delivery cannot roll state back diff --git a/src/Models/Product.php b/src/Models/Product.php index fb6776b..10e21bb 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -15,6 +15,7 @@ use Modules\Billing\Data\Entitlements; use Modules\Billing\Enums\CheckoutSessionStatus; use Modules\Billing\Enums\PlanKind; +use Saucebase\Core\Casts\SanitizedHtml; /** * @property int $id @@ -119,6 +120,8 @@ protected function casts(): array 'entitlements' => 'array', 'trial_entitlements' => 'array', 'trial_days' => 'integer', + // The pricing and checkout pages render it as markup; also imported from the provider. + 'description' => SanitizedHtml::class, ]; } diff --git a/tests/Feature/BillingPlansPageTest.php b/tests/Feature/BillingPlansPageTest.php index 8ad2234..7df40bc 100644 --- a/tests/Feature/BillingPlansPageTest.php +++ b/tests/Feature/BillingPlansPageTest.php @@ -49,6 +49,20 @@ public function test_only_active_and_visible_plans_are_offered(): void ); } + /** The description is rendered as HTML for every visitor, so markup that runs is stripped. */ + public function test_a_plan_description_is_sanitised(): void + { + $this->plan('Pro', ['description' => '

Best

']); + + $this->get(route('billing.plans')) + ->assertInertia( + fn (AssertableInertia $page) => $page + ->where('products.0.description', fn (string $html): bool => str_contains($html, 'Best') + && ! str_contains($html, 'onerror') + && ! str_contains($html, ' Date: Sat, 7 Nov 2026 16:20:08 +0000 Subject: [PATCH 2/3] fix: stop registering billing's deleted views folder, which failed php artisan optimize sc-1113 removed resources/views but the provider still loaded it, so view:cache threw and optimize skipped every later step (modules, Filament, data and settings caches). Co-Authored-By: Claude Opus 5.5 --- src/Providers/BillingServiceProvider.php | 2 -- tests/Feature/ViewPathsTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/ViewPathsTest.php diff --git a/src/Providers/BillingServiceProvider.php b/src/Providers/BillingServiceProvider.php index d1389e5..2c46cd0 100644 --- a/src/Providers/BillingServiceProvider.php +++ b/src/Providers/BillingServiceProvider.php @@ -30,8 +30,6 @@ public function boot(): void { parent::boot(); - $this->loadViewsFrom(module_path('billing', 'resources/views'), 'billing'); - $this->callAfterResolving(Schedule::class, function (Schedule $schedule): void { $schedule->command('billing:expire-checkout-sessions')->everyThirtyMinutes(); $schedule->command('billing:sync-catalog')->daily(); diff --git a/tests/Feature/ViewPathsTest.php b/tests/Feature/ViewPathsTest.php new file mode 100644 index 0000000..85514c9 --- /dev/null +++ b/tests/Feature/ViewPathsTest.php @@ -0,0 +1,24 @@ +getHints()['billing'] ?? []; + + foreach ($paths as $path) { + $this->assertDirectoryExists($path); + } + + $this->addToAssertionCount(1); + } +} From f2234cb36a387bb4df5f9a339dc29274b6e3fce2 Mon Sep 17 00:00:00 2001 From: roble Date: Sat, 7 Nov 2026 16:55:07 +0000 Subject: [PATCH 3/3] chore: require core ^2.12.0 for the SanitizedHtml cast Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5bd5dc0..3428ed7 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "saucebase/core": "^2.11.0", + "saucebase/core": "^2.12.0", "stripe/stripe-php": "^22.0" }, "license": "MIT",