There has been an error, we are working on it.
+
Error: {!! $exception->getMessage() !!}
@endif
-
+
From d0c84bc6fa785a085a1af6524dbe764cfb8a71d1 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 18:22:12 +0100
Subject: [PATCH 13/23] fix: indent
---
resources/views/errors/500.blade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php
index 67f0d9fef..d59b5bc28 100644
--- a/resources/views/errors/500.blade.php
+++ b/resources/views/errors/500.blade.php
@@ -3,10 +3,10 @@
500
Wait, this is not cool...
-
There has been an error, we are working on it.
+
There has been an error with the following error message:
@if ($exception->getMessage() !== '')
- Error: {!! $exception->getMessage() !!}
+ {!! $exception->getMessage() !!}
@endif
From fdb5f069fc3d69bdf9902823d66bd19071a5250e Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 18:32:05 +0100
Subject: [PATCH 14/23] chore: ajust time to 50s (tests done)
---
bootstrap/helpers/github.php | 2 +-
resources/views/errors/500.blade.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php
index be9ca9582..b687c0d68 100644
--- a/bootstrap/helpers/github.php
+++ b/bootstrap/helpers/github.php
@@ -19,7 +19,7 @@ function generateGithubToken(GithubApp $source, string $type)
$githubTime = Carbon::parse($response->header('date'));
$timeDiff = abs($serverTime->diffInSeconds($githubTime));
- if ($timeDiff > 0) {
+ if ($timeDiff > 50) {
throw new \Exception(
'System time is out of sync with GitHub API time:
'.
'- System time: '.$serverTime->format('Y-m-d H:i:s').' UTC
'.
diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php
index d59b5bc28..553264f00 100644
--- a/resources/views/errors/500.blade.php
+++ b/resources/views/errors/500.blade.php
@@ -5,7 +5,7 @@
Wait, this is not cool...
There has been an error with the following error message:
@if ($exception->getMessage() !== '')
-
+
{!! $exception->getMessage() !!}
@endif
From 49f468c4b797ea825e4fd64efe5a7e81c44f06aa Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 19:37:51 +0100
Subject: [PATCH 15/23] fix: potential fix for permissions update
---
app/Jobs/GithubAppPermissionJob.php | 2 +-
resources/views/errors/500.blade.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Jobs/GithubAppPermissionJob.php b/app/Jobs/GithubAppPermissionJob.php
index eb2cb673b..1ded6f455 100644
--- a/app/Jobs/GithubAppPermissionJob.php
+++ b/app/Jobs/GithubAppPermissionJob.php
@@ -30,7 +30,7 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
$github_access_token = generateGithubJwt($this->github_app);
$response = Http::withHeaders([
'Authorization' => "Bearer $github_access_token",
- 'Accept' => 'application/vnd.github+json',
+ 'Accept' => 'application/vnd.github.machine-man-preview+json',
])->get("{$this->github_app->api_url}/app");
$response = $response->json();
$permissions = data_get($response, 'permissions');
diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php
index 553264f00..10e9649d7 100644
--- a/resources/views/errors/500.blade.php
+++ b/resources/views/errors/500.blade.php
@@ -19,4 +19,4 @@
-
\ No newline at end of file
+
From 126e5ff57a6a38a1ca41e60d5059c694d6c4c8c5 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 20:56:19 +0100
Subject: [PATCH 16/23] add debug log
---
app/Jobs/GithubAppPermissionJob.php | 48 ++++++++++++++++++++++++++++-
bootstrap/helpers/github.php | 41 +++++++++++++++++++++++-
2 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/app/Jobs/GithubAppPermissionJob.php b/app/Jobs/GithubAppPermissionJob.php
index 1ded6f455..89c3daa12 100644
--- a/app/Jobs/GithubAppPermissionJob.php
+++ b/app/Jobs/GithubAppPermissionJob.php
@@ -10,6 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Log;
class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
{
@@ -26,21 +27,66 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
public function handle()
{
+ Log::debug('Starting GithubAppPermissionJob', [
+ 'app_id' => $this->github_app->app_id,
+ 'installation_id' => $this->github_app->installation_id,
+ 'api_url' => $this->github_app->api_url,
+ ]);
+
try {
+ Log::debug('Generating GitHub JWT token');
$github_access_token = generateGithubJwt($this->github_app);
+
+ Log::debug('Fetching app permissions from GitHub API');
$response = Http::withHeaders([
'Authorization' => "Bearer $github_access_token",
- 'Accept' => 'application/vnd.github.machine-man-preview+json',
+ 'Accept' => 'application/vnd.github+json',
])->get("{$this->github_app->api_url}/app");
+
+ if (! $response->successful()) {
+ Log::error('GitHub API request failed', [
+ 'status_code' => $response->status(),
+ 'error' => $response->body(),
+ 'app_id' => $this->github_app->app_id,
+ ]);
+ throw new \RuntimeException('Failed to fetch GitHub app permissions: '.$response->body());
+ }
+
$response = $response->json();
$permissions = data_get($response, 'permissions');
+
+ Log::debug('Retrieved GitHub permissions', [
+ 'app_id' => $this->github_app->app_id,
+ 'permissions' => $permissions,
+ ]);
+
$this->github_app->contents = data_get($permissions, 'contents');
$this->github_app->metadata = data_get($permissions, 'metadata');
$this->github_app->pull_requests = data_get($permissions, 'pull_requests');
$this->github_app->administration = data_get($permissions, 'administration');
+
+ Log::debug('Saving updated permissions to database', [
+ 'app_id' => $this->github_app->app_id,
+ 'contents' => $this->github_app->contents,
+ 'metadata' => $this->github_app->metadata,
+ 'pull_requests' => $this->github_app->pull_requests,
+ 'administration' => $this->github_app->administration,
+ ]);
+
$this->github_app->save();
$this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret');
+
+ Log::debug('Successfully completed GithubAppPermissionJob', [
+ 'app_id' => $this->github_app->app_id,
+ ]);
+
} catch (\Throwable $e) {
+ Log::error('GithubAppPermissionJob failed', [
+ 'app_id' => $this->github_app->app_id,
+ 'error' => $e->getMessage(),
+ 'trace' => $e->getTraceAsString(),
+ ]);
+
send_internal_notification('GithubAppPermissionJob failed with: '.$e->getMessage());
throw $e;
}
diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php
index b687c0d68..c544ddcfc 100644
--- a/bootstrap/helpers/github.php
+++ b/bootstrap/helpers/github.php
@@ -5,6 +5,7 @@ use App\Models\GitlabApp;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Lcobucci\JWT\Encoding\ChainedFormatter;
use Lcobucci\JWT\Encoding\JoseEncoder;
@@ -14,12 +15,29 @@ use Lcobucci\JWT\Token\Builder;
function generateGithubToken(GithubApp $source, string $type)
{
+ Log::debug('Generating GitHub token', [
+ 'app_id' => $source->app_id,
+ 'type' => $type,
+ 'api_url' => $source->api_url,
+ ]);
+
$response = Http::get("{$source->api_url}/zen");
$serverTime = CarbonImmutable::now()->setTimezone('UTC');
$githubTime = Carbon::parse($response->header('date'));
$timeDiff = abs($serverTime->diffInSeconds($githubTime));
+ Log::debug('Time synchronization check', [
+ 'server_time' => $serverTime->format('Y-m-d H:i:s'),
+ 'github_time' => $githubTime->format('Y-m-d H:i:s'),
+ 'difference_seconds' => $timeDiff,
+ ]);
+
if ($timeDiff > 50) {
+ Log::error('System time out of sync with GitHub', [
+ 'time_difference' => $timeDiff,
+ 'server_time' => $serverTime->format('Y-m-d H:i:s'),
+ 'github_time' => $githubTime->format('Y-m-d H:i:s'),
+ ]);
throw new \Exception(
'System time is out of sync with GitHub API time:
'.
'- System time: '.$serverTime->format('Y-m-d H:i:s').' UTC
'.
@@ -41,18 +59,39 @@ function generateGithubToken(GithubApp $source, string $type)
->getToken($algorithm, $signingKey)
->toString();
+ Log::debug('JWT token generated', [
+ 'token_type' => $type,
+ 'issued_at' => $now->modify('-1 minute')->format('Y-m-d H:i:s'),
+ 'expires_at' => $now->modify('+8 minutes')->format('Y-m-d H:i:s'),
+ ]);
+
return match ($type) {
'jwt' => $jwt,
'installation' => (function () use ($source, $jwt) {
+ Log::debug('Requesting installation token', [
+ 'app_id' => $source->app_id,
+ 'installation_id' => $source->installation_id,
+ ]);
+
$response = Http::withHeaders([
'Authorization' => "Bearer $jwt",
'Accept' => 'application/vnd.github.machine-man-preview+json',
])->post("{$source->api_url}/app/installations/{$source->installation_id}/access_tokens");
if (! $response->successful()) {
- throw new RuntimeException("Failed to get installation token for {$source->name} with error: ".data_get($response->json(), 'message', 'no error message found'));
+ $error = data_get($response->json(), 'message', 'no error message found');
+ Log::error('Failed to get installation token', [
+ 'status_code' => $response->status(),
+ 'error_message' => $error,
+ 'app_id' => $source->app_id,
+ ]);
+ throw new RuntimeException("Failed to get installation token for {$source->name} with error: ".$error);
}
+ Log::debug('Successfully obtained installation token', [
+ 'app_id' => $source->app_id,
+ ]);
+
return $response->json()['token'];
})(),
default => throw new \InvalidArgumentException("Unsupported token type: {$type}")
From deec885fd9899bdd0a350b68bca6c1c0be4b7e3d Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 21:08:22 +0100
Subject: [PATCH 17/23] fix: Expiration time claim ('exp') must be a numeric
value
---
bootstrap/helpers/github.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php
index c544ddcfc..be4ae65c5 100644
--- a/bootstrap/helpers/github.php
+++ b/bootstrap/helpers/github.php
@@ -51,6 +51,7 @@ function generateGithubToken(GithubApp $source, string $type)
$algorithm = new Sha256;
$tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default()));
$now = CarbonImmutable::now()->setTimezone('UTC');
+ $now = $now->setTime($now->format('H'), $now->format('i'), $now->format('s'));
$jwt = $tokenBuilder
->issuedBy($source->app_id)
From 09dfbde676e14e783db66b3b04cc1be59518312f Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 21:14:06 +0100
Subject: [PATCH 18/23] chore: remove debug log, finally found it
---
app/Jobs/GithubAppPermissionJob.php | 25 -------------------------
bootstrap/helpers/github.php | 27 ---------------------------
2 files changed, 52 deletions(-)
diff --git a/app/Jobs/GithubAppPermissionJob.php b/app/Jobs/GithubAppPermissionJob.php
index 89c3daa12..d6da4439c 100644
--- a/app/Jobs/GithubAppPermissionJob.php
+++ b/app/Jobs/GithubAppPermissionJob.php
@@ -27,17 +27,9 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
public function handle()
{
- Log::debug('Starting GithubAppPermissionJob', [
- 'app_id' => $this->github_app->app_id,
- 'installation_id' => $this->github_app->installation_id,
- 'api_url' => $this->github_app->api_url,
- ]);
-
try {
- Log::debug('Generating GitHub JWT token');
$github_access_token = generateGithubJwt($this->github_app);
- Log::debug('Fetching app permissions from GitHub API');
$response = Http::withHeaders([
'Authorization' => "Bearer $github_access_token",
'Accept' => 'application/vnd.github+json',
@@ -55,31 +47,14 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
$response = $response->json();
$permissions = data_get($response, 'permissions');
- Log::debug('Retrieved GitHub permissions', [
- 'app_id' => $this->github_app->app_id,
- 'permissions' => $permissions,
- ]);
-
$this->github_app->contents = data_get($permissions, 'contents');
$this->github_app->metadata = data_get($permissions, 'metadata');
$this->github_app->pull_requests = data_get($permissions, 'pull_requests');
$this->github_app->administration = data_get($permissions, 'administration');
- Log::debug('Saving updated permissions to database', [
- 'app_id' => $this->github_app->app_id,
- 'contents' => $this->github_app->contents,
- 'metadata' => $this->github_app->metadata,
- 'pull_requests' => $this->github_app->pull_requests,
- 'administration' => $this->github_app->administration,
- ]);
-
$this->github_app->save();
$this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret');
- Log::debug('Successfully completed GithubAppPermissionJob', [
- 'app_id' => $this->github_app->app_id,
- ]);
-
} catch (\Throwable $e) {
Log::error('GithubAppPermissionJob failed', [
'app_id' => $this->github_app->app_id,
diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php
index be4ae65c5..168308967 100644
--- a/bootstrap/helpers/github.php
+++ b/bootstrap/helpers/github.php
@@ -15,23 +15,11 @@ use Lcobucci\JWT\Token\Builder;
function generateGithubToken(GithubApp $source, string $type)
{
- Log::debug('Generating GitHub token', [
- 'app_id' => $source->app_id,
- 'type' => $type,
- 'api_url' => $source->api_url,
- ]);
-
$response = Http::get("{$source->api_url}/zen");
$serverTime = CarbonImmutable::now()->setTimezone('UTC');
$githubTime = Carbon::parse($response->header('date'));
$timeDiff = abs($serverTime->diffInSeconds($githubTime));
- Log::debug('Time synchronization check', [
- 'server_time' => $serverTime->format('Y-m-d H:i:s'),
- 'github_time' => $githubTime->format('Y-m-d H:i:s'),
- 'difference_seconds' => $timeDiff,
- ]);
-
if ($timeDiff > 50) {
Log::error('System time out of sync with GitHub', [
'time_difference' => $timeDiff,
@@ -60,20 +48,9 @@ function generateGithubToken(GithubApp $source, string $type)
->getToken($algorithm, $signingKey)
->toString();
- Log::debug('JWT token generated', [
- 'token_type' => $type,
- 'issued_at' => $now->modify('-1 minute')->format('Y-m-d H:i:s'),
- 'expires_at' => $now->modify('+8 minutes')->format('Y-m-d H:i:s'),
- ]);
-
return match ($type) {
'jwt' => $jwt,
'installation' => (function () use ($source, $jwt) {
- Log::debug('Requesting installation token', [
- 'app_id' => $source->app_id,
- 'installation_id' => $source->installation_id,
- ]);
-
$response = Http::withHeaders([
'Authorization' => "Bearer $jwt",
'Accept' => 'application/vnd.github.machine-man-preview+json',
@@ -89,10 +66,6 @@ function generateGithubToken(GithubApp $source, string $type)
throw new RuntimeException("Failed to get installation token for {$source->name} with error: ".$error);
}
- Log::debug('Successfully obtained installation token', [
- 'app_id' => $source->app_id,
- ]);
-
return $response->json()['token'];
})(),
default => throw new \InvalidArgumentException("Unsupported token type: {$type}")
From c789ed6003a4884cfb241fa1bca85fa0a155ed9f Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Mon, 6 Jan 2025 21:16:57 +0100
Subject: [PATCH 19/23] chore: remove more logging
---
app/Jobs/GithubAppPermissionJob.php | 12 ------------
bootstrap/helpers/github.php | 11 -----------
2 files changed, 23 deletions(-)
diff --git a/app/Jobs/GithubAppPermissionJob.php b/app/Jobs/GithubAppPermissionJob.php
index d6da4439c..7cd1b86ac 100644
--- a/app/Jobs/GithubAppPermissionJob.php
+++ b/app/Jobs/GithubAppPermissionJob.php
@@ -10,7 +10,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Log;
class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
{
@@ -36,11 +35,6 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
])->get("{$this->github_app->api_url}/app");
if (! $response->successful()) {
- Log::error('GitHub API request failed', [
- 'status_code' => $response->status(),
- 'error' => $response->body(),
- 'app_id' => $this->github_app->app_id,
- ]);
throw new \RuntimeException('Failed to fetch GitHub app permissions: '.$response->body());
}
@@ -56,12 +50,6 @@ class GithubAppPermissionJob implements ShouldBeEncrypted, ShouldQueue
$this->github_app->makeVisible('client_secret')->makeVisible('webhook_secret');
} catch (\Throwable $e) {
- Log::error('GithubAppPermissionJob failed', [
- 'app_id' => $this->github_app->app_id,
- 'error' => $e->getMessage(),
- 'trace' => $e->getTraceAsString(),
- ]);
-
send_internal_notification('GithubAppPermissionJob failed with: '.$e->getMessage());
throw $e;
}
diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php
index 168308967..3a3f6e7b2 100644
--- a/bootstrap/helpers/github.php
+++ b/bootstrap/helpers/github.php
@@ -5,7 +5,6 @@ use App\Models\GitlabApp;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Lcobucci\JWT\Encoding\ChainedFormatter;
use Lcobucci\JWT\Encoding\JoseEncoder;
@@ -21,11 +20,6 @@ function generateGithubToken(GithubApp $source, string $type)
$timeDiff = abs($serverTime->diffInSeconds($githubTime));
if ($timeDiff > 50) {
- Log::error('System time out of sync with GitHub', [
- 'time_difference' => $timeDiff,
- 'server_time' => $serverTime->format('Y-m-d H:i:s'),
- 'github_time' => $githubTime->format('Y-m-d H:i:s'),
- ]);
throw new \Exception(
'System time is out of sync with GitHub API time:
'.
'- System time: '.$serverTime->format('Y-m-d H:i:s').' UTC
'.
@@ -58,11 +52,6 @@ function generateGithubToken(GithubApp $source, string $type)
if (! $response->successful()) {
$error = data_get($response->json(), 'message', 'no error message found');
- Log::error('Failed to get installation token', [
- 'status_code' => $response->status(),
- 'error_message' => $error,
- 'app_id' => $source->app_id,
- ]);
throw new RuntimeException("Failed to get installation token for {$source->name} with error: ".$error);
}
From 70f93b151371cd3e76add2eed51142b0310f0718 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Tue, 7 Jan 2025 13:38:21 +0100
Subject: [PATCH 20/23] fix: sanitize html error messages
---
resources/views/errors/500.blade.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php
index 10e9649d7..0ea295fe7 100644
--- a/resources/views/errors/500.blade.php
+++ b/resources/views/errors/500.blade.php
@@ -6,7 +6,7 @@
There has been an error with the following error message:
@if ($exception->getMessage() !== '')
- {!! $exception->getMessage() !!}
+ {!! Str::sanitize($exception->getMessage()) !!}
@endif
From 8a80401f156a473d6466cd16e378a89d9d4f9a0a Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Tue, 7 Jan 2025 13:47:16 +0100
Subject: [PATCH 21/23] feat: Purify for better sanitization
---
composer.json | 1 +
composer.lock | 129 ++++++++++++++++++++++++++-
config/purify.php | 115 ++++++++++++++++++++++++
resources/views/errors/500.blade.php | 2 +-
4 files changed, 245 insertions(+), 2 deletions(-)
create mode 100644 config/purify.php
diff --git a/composer.json b/composer.json
index 9bb2d034b..e680ac36c 100644
--- a/composer.json
+++ b/composer.json
@@ -47,6 +47,7 @@
"spatie/laravel-ray": "^1.37",
"spatie/laravel-schemaless-attributes": "^2.4",
"spatie/url": "^2.2",
+ "stevebauman/purify": "^6.2",
"stripe/stripe-php": "^16.2.0",
"symfony/yaml": "^7.1.6",
"visus/cuid2": "^4.1.0",
diff --git a/composer.lock b/composer.lock
index fe0aeafbc..821ee0cec 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "35041f9af7cbf8626f54891f1ede3622",
+ "content-hash": "aa98760c097f486cac380aa701e4317c",
"packages": [
{
"name": "3sidedcube/laravel-redoc",
@@ -1883,6 +1883,67 @@
],
"time": "2024-12-27T00:36:43+00:00"
},
+ {
+ "name": "ezyang/htmlpurifier",
+ "version": "v4.18.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ezyang/htmlpurifier.git",
+ "reference": "cb56001e54359df7ae76dc522d08845dc741621b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/cb56001e54359df7ae76dc522d08845dc741621b",
+ "reference": "cb56001e54359df7ae76dc522d08845dc741621b",
+ "shasum": ""
+ },
+ "require": {
+ "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
+ },
+ "require-dev": {
+ "cerdic/css-tidy": "^1.7 || ^2.0",
+ "simpletest/simpletest": "dev-master"
+ },
+ "suggest": {
+ "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
+ "ext-bcmath": "Used for unit conversion and imagecrash protection",
+ "ext-iconv": "Converts text to and from non-UTF-8 encodings",
+ "ext-tidy": "Used for pretty-printing HTML"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "library/HTMLPurifier.composer.php"
+ ],
+ "psr-0": {
+ "HTMLPurifier": "library/"
+ },
+ "exclude-from-classmap": [
+ "/library/HTMLPurifier/Language/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-2.1-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Edward Z. Yang",
+ "email": "admin@htmlpurifier.org",
+ "homepage": "http://ezyang.com"
+ }
+ ],
+ "description": "Standards compliant HTML filter written in PHP",
+ "homepage": "http://htmlpurifier.org/",
+ "keywords": [
+ "html"
+ ],
+ "support": {
+ "issues": "https://github.com/ezyang/htmlpurifier/issues",
+ "source": "https://github.com/ezyang/htmlpurifier/tree/v4.18.0"
+ },
+ "time": "2024-11-01T03:51:45+00:00"
+ },
{
"name": "firebase/php-jwt",
"version": "v6.10.2",
@@ -8330,6 +8391,72 @@
],
"time": "2024-03-08T11:35:19+00:00"
},
+ {
+ "name": "stevebauman/purify",
+ "version": "v6.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/stevebauman/purify.git",
+ "reference": "a449299a3d5f5f8ef177e626721b3f69143890a4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/stevebauman/purify/zipball/a449299a3d5f5f8ef177e626721b3f69143890a4",
+ "reference": "a449299a3d5f5f8ef177e626721b3f69143890a4",
+ "shasum": ""
+ },
+ "require": {
+ "ezyang/htmlpurifier": "^4.17",
+ "illuminate/contracts": "^7.0|^8.0|^9.0|^10.0|^11.0",
+ "illuminate/support": "^7.0|^8.0|^9.0|^10.0|^11.0",
+ "php": ">=7.4"
+ },
+ "require-dev": {
+ "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0",
+ "phpunit/phpunit": "^8.0|^9.0|^10.0"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "aliases": {
+ "Purify": "Stevebauman\\Purify\\Facades\\Purify"
+ },
+ "providers": [
+ "Stevebauman\\Purify\\PurifyServiceProvider"
+ ]
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Stevebauman\\Purify\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Steve Bauman",
+ "email": "steven_bauman@outlook.com"
+ }
+ ],
+ "description": "An HTML Purifier / Sanitizer for Laravel",
+ "keywords": [
+ "Purifier",
+ "clean",
+ "cleaner",
+ "html",
+ "laravel",
+ "purification",
+ "purify"
+ ],
+ "support": {
+ "issues": "https://github.com/stevebauman/purify/issues",
+ "source": "https://github.com/stevebauman/purify/tree/v6.2.2"
+ },
+ "time": "2024-09-24T12:27:10+00:00"
+ },
{
"name": "stripe/stripe-php",
"version": "v16.4.0",
diff --git a/config/purify.php b/config/purify.php
new file mode 100644
index 000000000..66dbbb568
--- /dev/null
+++ b/config/purify.php
@@ -0,0 +1,115 @@
+ 'default',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Config sets
+ |--------------------------------------------------------------------------
+ |
+ | Here you may configure various sets of configuration for differentiated use of HTMLPurifier.
+ | A specific set of configuration can be applied by calling the "config($name)" method on
+ | a Purify instance. Feel free to add/remove/customize these attributes as you wish.
+ |
+ | Documentation: http://htmlpurifier.org/live/configdoc/plain.html
+ |
+ | Core.Encoding The encoding to convert input to.
+ | HTML.Doctype Doctype to use during filtering.
+ | HTML.Allowed The allowed HTML Elements with their allowed attributes.
+ | HTML.ForbiddenElements The forbidden HTML elements. Elements that are listed in this
+ | string will be removed, however their content will remain.
+ | CSS.AllowedProperties The Allowed CSS properties.
+ | AutoFormat.AutoParagraph Newlines are converted in to paragraphs whenever possible.
+ | AutoFormat.RemoveEmpty Remove empty elements that contribute no semantic information to the document.
+ |
+ */
+
+ 'configs' => [
+
+ 'default' => [
+ 'Core.Encoding' => 'utf-8',
+ 'HTML.Doctype' => 'HTML 4.01 Transitional',
+ 'HTML.Allowed' => 'h1,h2,h3,h4,h5,h6,b,u,strong,i,em,s,del,a[href|title],ul,ol,li,p[style],br,span,img[width|height|alt|src],blockquote',
+ 'HTML.ForbiddenElements' => '',
+ 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
+ 'AutoFormat.AutoParagraph' => false,
+ 'AutoFormat.RemoveEmpty' => false,
+ ],
+
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | HTMLPurifier definitions
+ |--------------------------------------------------------------------------
+ |
+ | Here you may specify a class that augments the HTML definitions used by
+ | HTMLPurifier. Additional HTML5 definitions are provided out of the box.
+ | When specifying a custom class, make sure it implements the interface:
+ |
+ | \Stevebauman\Purify\Definitions\Definition
+ |
+ | Note that these definitions are applied to every Purifier instance.
+ |
+ | Documentation: http://htmlpurifier.org/docs/enduser-customize.html
+ |
+ */
+
+ 'definitions' => Html5Definition::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | HTMLPurifier CSS definitions
+ |--------------------------------------------------------------------------
+ |
+ | Here you may specify a class that augments the CSS definitions used by
+ | HTMLPurifier. When specifying a custom class, make sure it implements
+ | the interface:
+ |
+ | \Stevebauman\Purify\Definitions\CssDefinition
+ |
+ | Note that these definitions are applied to every Purifier instance.
+ |
+ | CSS should be extending $definition->info['css-attribute'] = values
+ | See HTMLPurifier_CSSDefinition for further explanation
+ |
+ */
+
+ 'css-definitions' => null,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Serializer
+ |--------------------------------------------------------------------------
+ |
+ | The storage implementation where HTMLPurifier can store its serializer files.
+ | If the filesystem cache is in use, the path must be writable through the
+ | storage disk by the web server, otherwise an exception will be thrown.
+ |
+ */
+
+ 'serializer' => [
+ 'driver' => env('CACHE_STORE', env('CACHE_DRIVER', 'file')),
+ 'cache' => \Stevebauman\Purify\Cache\CacheDefinitionCache::class,
+ ],
+
+ // 'serializer' => [
+ // 'disk' => env('FILESYSTEM_DISK', 'local'),
+ // 'path' => 'purify',
+ // 'cache' => \Stevebauman\Purify\Cache\FilesystemDefinitionCache::class,
+ // ],
+
+];
diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php
index 0ea295fe7..cc672a324 100644
--- a/resources/views/errors/500.blade.php
+++ b/resources/views/errors/500.blade.php
@@ -6,7 +6,7 @@
There has been an error with the following error message:
@if ($exception->getMessage() !== '')
- {!! Str::sanitize($exception->getMessage()) !!}
+ {!! Purify::clean($exception->getMessage()) !!}
@endif
From 43d526b7735c451526af808ac0185c71372ccc71 Mon Sep 17 00:00:00 2001
From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Date: Thu, 16 Jan 2025 18:06:46 +0100
Subject: [PATCH 22/23] fix: production password rule and cleanup code
---
app/Providers/AppServiceProvider.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 6ed5e654e..c94574ce3 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -45,15 +45,14 @@ class AppServiceProvider extends ServiceProvider
private function configurePasswords(): void
{
Password::defaults(function () {
- $rule = Password::min(8)->letters();
-
return App::isProduction()
- ? $rule->mixedCase()
+ ? Password::min(8)
+ ->mixedCase()
->letters()
->numbers()
->symbols()
->uncompromised()
- : $rule;
+ : Password::min(8)->letters();
});
}
From dd897a11fd1f8b8fd724588b3aed2aeb0a89dd91 Mon Sep 17 00:00:00 2001
From: Andras Bacsai
Date: Thu, 16 Jan 2025 21:07:12 +0100
Subject: [PATCH 23/23] disable model strict mode
---
app/Providers/AppServiceProvider.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index c94574ce3..329482230 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -39,7 +39,8 @@ class AppServiceProvider extends ServiceProvider
private function configureModels(): void
{
- Model::shouldBeStrict();
+ // Disabled because it's causing issues with the application
+ // Model::shouldBeStrict();
}
private function configurePasswords(): void