Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composer to fix security vulnerabilities #198

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,381 changes: 1,143 additions & 2,238 deletions composer.lock

Large diffs are not rendered by default.

1,723 changes: 917 additions & 806 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Commands/AddUserConcerns.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function handle()
$userContents = $part1 . "\n\n public function canAccessPanel(\$panel): bool\n {\n // This is required on Front and Back end. Add more specific controls with authenticate middleware.\n return true;\n }\n\n" . $part2;
}

if(!strpos($userContents, 'canImpersonate')) {
if (!strpos($userContents, 'canImpersonate')) {
$part1End = strrpos($userContents, '}');
$part1 = substr($userContents, 0, $part1End);
$part2 = substr($userContents, $part1End);
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/SyncSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle()
$this->call('scout:delete-all-indexes');
$this->call('scout:sync-index-settings');

foreach(FilaCms::getRawContentModels() as $model => $resource) {
foreach (FilaCms::getRawContentModels() as $model => $resource) {
$this->call('scout:import', ['model' => $model]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/HasSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected function slugifyField(): string
protected function scopeSlugQuery($query, $slug)
{
$query = $query->where('slug', $slug);
if($this->id) {
if ($this->id) {
$query = $query->where('id', '!=', $this->id);
}
return $query;
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function register(): void
{
$this->reportable(function (Throwable $e) {
// Only throw to Sentry if it's been configured
if(config('sentry.dsn')) {
if (config('sentry.dsn')) {
Integration::captureUnhandledException($e);
}
});
Expand Down
16 changes: 8 additions & 8 deletions src/Filament/Actions/LinkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function setUp(): void

protected function getHref($data)
{
switch($data['link_type']) {
switch ($data['link_type']) {
case 'index-page':
$resourceClass = $data['reference_page'];
return route($resourceClass::getFrontendIndexRoute());
Expand Down Expand Up @@ -201,7 +201,7 @@ protected static function modelQuery($source)
$className = FilaCms::getModelFromResource($source);

if (!$className) {
if($source === FormResource::class) {
if ($source === FormResource::class) {
$query = Form::query();
} else {
$query = Media::query()->where('is_folder', 0);
Expand All @@ -219,12 +219,12 @@ protected function parseArguments($args)
// If the URL is a route, we need to parse it to get the correct arguments
try {
$route = app('router')->getRoutes()->match(app('request')->create($url), 'GET');
if(count($route->parameters) == 0) {
if (count($route->parameters) == 0) {
$args['link_type'] = 'url';
$args['reference_text'] = $url;
return $args;
}
if(isset($route->parameters['model'])) {
if (isset($route->parameters['model'])) {
$model = $route->parameters['model'];
$resource = FilaCms::getContentModelResource($model);
} else {
Expand All @@ -233,20 +233,20 @@ protected function parseArguments($args)
}
$args['reference_page'] = $resource;

if(isset($route->parameters['slug'])) {
if (isset($route->parameters['slug'])) {
$args['link_type'] = 'content';
$args['reference_content'] = $model::query()->where('slug', $route->parameters['slug'])->first()?->id;
} elseif(isset($route->parameters['media'])) {
} elseif (isset($route->parameters['media'])) {
$args['reference_media'] = $route->parameters['media'];
if(isset($route->parameters['mediaExtension'])) {
if (isset($route->parameters['mediaExtension'])) {
$args['link_type'] = 'media';
} else {
$args['link_type'] = 'download';
}
} else {
$args['link_type'] = 'index-page';
}
} catch(\Exception $e) {
} catch (\Exception $e) {
$args['link_type'] = 'url';
$args['reference_text'] = $url;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Exports/FormEntryExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
protected array $columnMap,
protected array $options,
) {
if(isset($options['form'])) {
if (isset($options['form'])) {
static::form($options['form']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/FormBlocks/AbstractFormBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function getField($fieldData, $readOnly = false): Component
$field->readOnly();
}
$field->label($fieldData['field_name'] ?? $fieldData['field_id'] ?? '-');
if(!empty($fieldData['field_id'])) {
if (!empty($fieldData['field_id'])) {
$field->statePath($fieldData['field_id']);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Filament/FormBlocks/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function getFields($fieldData, $readOnly = false): array
$fields = [];
foreach ($fieldData as $key => $field) {

if($readOnly) {
if ($readOnly) {
$field['data']['required'] = false;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ public static function formFieldId(): TextInput
->readOnly()
->required()
->afterStateHydrated(function (TextInput $component, $state) use ($fieldId) {
if(empty($state)) {
if (empty($state)) {
$component->state($fieldId);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/FormBlocks/InformationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getSchema(): Closure|array
->readOnly()
->required()
->afterStateHydrated(function (TextInput $component, $state) {
if(empty($state)) {
if (empty($state)) {
$component->state('Information');
}
}),
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/FormBlocks/RelationshipBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected static function getOptionsQuery($fieldData, $search = null)
}

if ($search) {
if($titleField == 'display_name') {
if ($titleField == 'display_name') {
$query = $query->where('first_name', 'LIKE', '%' . $search . '%')->orWhere('last_name', 'LIKE', '%'. $search . '%');
} else {
$query = $query->where($titleField, 'LIKE', '%' . $search . '%');
Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Pages/EditSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function save(): void
'value' => data_get($formData, $field->getName())
];
$cacheKey = 'setting-' . $field->getName();
if(Cache::has($cacheKey)) {
if (Cache::has($cacheKey)) {
Cache::forget($cacheKey);
}
}
Expand All @@ -76,7 +76,7 @@ public function save(): void
Setting::upsert($records, ['key'], ['value']);

// If the stop words have changed, kick off a reindex
if($oldStopWords !== Setting::get('search.stop_words')) {
if ($oldStopWords !== Setting::get('search.stop_words')) {
$user = auth()->user();
ReindexSearch::dispatch($user);
Notification::make()
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Resources/AbstractContentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ protected static function getAuthorFilter()
}
$authors = Author::whereIn('id', $data['values'])->get()->pluck('display_name');

if(count($authors) === 0) {
if (count($authors) === 0) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public static function table(Table $table): Table
})
];

if(auth()->user()->can('impersonate users')) {
if (auth()->user()->can('impersonate users')) {
$actions[] = Action::make('impersonate')
->label('Impersonate')
->icon('heroicon-s-eye')
->action(function (Model $user) {
Auth::user()->impersonate($user);
if($user->can('access filacms-backend')) {
if ($user->can('access filacms-backend')) {
return redirect(route('filament.admin.pages.dashboard'));
} else {
return redirect('/');
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/SSOController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function redirectToProvider()
$driver = preg_match("/login\/(.*)/", Route::current()->uri(), $matches) ? $matches[1] : null;

$socialiteDriver = $driver;
if(Str::lower($socialiteDriver) === 'linkedin') {
if (Str::lower($socialiteDriver) === 'linkedin') {
$socialiteDriver = 'linkedin-openid';
}

Expand All @@ -39,7 +39,7 @@ public function handleProviderCallback(LoginResponse $loginResponse)
$driver = preg_match("/login\/(.*)\//", Route::current()->uri(), $matches) ? $matches[1] : null;

$socialiteDriver = $driver;
if(Str::lower($socialiteDriver) === 'linkedin') {
if (Str::lower($socialiteDriver) === 'linkedin') {
$socialiteDriver = 'linkedin-openid';
}

Expand Down
6 changes: 3 additions & 3 deletions src/Listeners/CommandFinishedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ class CommandFinishedListener
public function handle(CommandFinished $event): void
{
$indexCommands = ['scout:sync-index-settings','tinker','fila-cms:sync-search'];
if(in_array($event->command, $indexCommands)) {
if (in_array($event->command, $indexCommands)) {
AfterSyncSearchSettings::dispatch();
// Now update the stop words for all the models
// that are searchable
$indexes = config('scout.meilisearch.index-settings');
$stopWords = json_decode(\Portable\FilaCms\Models\Setting::get('search.stop_words'));
if(!is_array($stopWords)) {
if (!is_array($stopWords)) {
$stopWords = [];
}

$client = app(\Laravel\Scout\EngineManager::class)->createMeilisearchDriver();
foreach($indexes as $indexName => $settings) {
foreach ($indexes as $indexName => $settings) {
$client->index($indexName)->updateStopWords($stopWords);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/CommandStartingListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CommandStartingListener
public function handle(CommandStarting $event): void
{
$indexCommands = ['scout:sync-index-settings','tinker','fila-cms:sync-search'];
if(in_array($event->command, $indexCommands)) {
if (in_array($event->command, $indexCommands)) {
FilaCms::setMeilisearchConfigs();
BeforeSyncSearchSettings::dispatch();
}
Expand Down
12 changes: 6 additions & 6 deletions src/Livewire/MediaLibraryTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function breadcrumbs()

public function setParent($id)
{
if(!Media::find($id)) {
if (!Media::find($id)) {
$id = null;
}

Expand Down Expand Up @@ -240,7 +240,7 @@ protected function getNewFolderAction(): Action

public function removeFormUploadedFile(string $statePath, string $fileKey): void
{
foreach($this->getCachedForms() as $form) {
foreach ($this->getCachedForms() as $form) {
foreach ($form->getComponents() as $component) {
if ($component instanceof BaseFileUpload && $component->getStatePath() === $statePath) {
$state = $form->getState();
Expand Down Expand Up @@ -276,15 +276,15 @@ protected function getUploadAction(): Action
->live()
->afterStateUpdated(function (Get $get, Set $set, $state) {
$alts = collect($get('alts'));
foreach($state as $key => $item) {
foreach ($state as $key => $item) {
$arrItem = [
'key' => $key,
'tmppath' => $item->getFilename(),
'filename' => $item->getClientOriginalName(),
'alt_text' => $item->getClientOriginalName(),
];
$alt = $alts->where('key', $key)->first();
if(!$alt) {
if (!$alt) {
$alts->push($arrItem);
}
}
Expand Down Expand Up @@ -315,9 +315,9 @@ protected function getUploadAction(): Action
->reorderable(false)
])
->action(function (array $data) {
if(count($data['upload_media'])) {
if (count($data['upload_media'])) {
$alts = collect($data['alts']);
foreach($data['upload_media'] as $item) {
foreach ($data['upload_media'] as $item) {
$alt = $alts->where('tmppath', $item->getFilename())->first();
$alt = $alt ? $alt['alt_text'] : $item->getClientOriginalName();
$this->saveFile($item, $alt);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/AbstractContentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function url(): Attribute
{
return new Attribute(function () {
$resource = static::$resourceName;
if($resource::getFrontendRoutePrefix() == '') {
if ($resource::getFrontendRoutePrefix() == '') {
return '/' . $this->slug;
} else {
return route(static::$resourceName::getFrontendShowRoute(), $this->slug);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function displaySize(): Attribute
$readableSize = new HumanReadableFileSize();
$readableSize->setSpaceBeforeUnit(true);
return preg_replace('/\.\d{1,2}(K?B)/', '$1', $readableSize->compute($this->size));
} catch(\Exception $e) {
} catch (\Exception $e) {
// Dealing with nulls
return '?';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Traits/ProvidesSearchSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function getSearchableTaxonomies()
try {
$attrs = [];
$taxes = TaxonomyResource::where('resource_class', static::$resourceName)->get();
foreach($taxes as $taxonomyResource) {
foreach ($taxes as $taxonomyResource) {
$fieldName = Str::slug(Str::plural($taxonomyResource->taxonomy->name), '_');
$attrs[] = $fieldName;
}
Expand All @@ -51,7 +51,7 @@ public static function getFilterableTaxonomies()
try {
$attrs = [];
$taxes = TaxonomyResource::where('resource_class', static::$resourceName)->get();
foreach($taxes as $taxonomyResource) {
foreach ($taxes as $taxonomyResource) {
$fieldName = Str::slug(Str::plural($taxonomyResource->taxonomy->name), '_');
$attrs[] = $fieldName . '_ids';
}
Expand Down
12 changes: 6 additions & 6 deletions src/Providers/FilaCmsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function (\Lab404\Impersonate\Events\LeaveImpersonation $event) {
Event::listen(CommandFinished::class, CommandFinishedListener::class);

// Force the Scout commands to be registered, in case we're running jobs syncronously
if(!$this->app->runningInConsole()) {
if (!$this->app->runningInConsole()) {
$this->commands([
FlushCommand::class,
ImportCommand::class,
Expand Down Expand Up @@ -310,11 +310,11 @@ protected function loadSettings()
}
}

if(config('settings.monitoring.sentry.dsn')) {
if (config('settings.monitoring.sentry.dsn')) {
config(['sentry.dsn' => config('settings.monitoring.sentry.dsn')]);
}

if(config('settings.monitoring.ohdear.enabled')) {
if (config('settings.monitoring.ohdear.enabled')) {
config(['schedule-monitor.oh_dear.api_token' => config('settings.monitoring.ohdear.api_token')]);
config(['schedule-monitor.oh_dear.site_id' => config('settings.monitoring.ohdear.site_id')]);
config(['schedule-monitor.oh_dear.queue' => env('OH_DEAR_QUEUE', 'default')]);
Expand Down Expand Up @@ -480,7 +480,7 @@ function ($app) use ($socialite) {

protected function registerHealthChecks()
{
if(app()->runningUnitTests()) {
if (app()->runningUnitTests()) {
return;
}

Expand All @@ -489,7 +489,7 @@ protected function registerHealthChecks()
DatabaseCheck::new(),
];
$meili = MeiliSearchCheck::new()->url(config('scout.meilisearch.host') . '/health');
if(config('scout.meilisearch.key')) {
if (config('scout.meilisearch.key')) {
$meili = $meili->token(config('scout.meilisearch.key'));
}
$checks[] = $meili;
Expand All @@ -499,7 +499,7 @@ protected function registerHealthChecks()
$checks[] = RedisCheck::new();
}

if(config('queue.default') === 'redis') {
if (config('queue.default') === 'redis') {
$checks[] = HorizonCheck::new();
}
Health::checks($checks);
Expand Down
6 changes: 3 additions & 3 deletions tests/Factories/FormEntryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public function definition(): array
$fields = FormFactory::getFields();
$values = [];

foreach($fields as $field) {
foreach ($fields as $field) {
$fieldName = data_get($field, 'data.' . FormBuilder::$fieldId);
if(!$fieldName) {
if (!$fieldName) {
continue;
}

if($fieldName === 'Text Area') {
if ($fieldName === 'Text Area') {
$values[$fieldName] = $this->faker->sentence;

} else {
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/SearchIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Portable\FilaCms\Models\Page;
use Portable\FilaCms\Models\Setting;
use Portable\FilaCms\Models\Taxonomy;

use Portable\FilaCms\Tests\TestCase;

class SearchIndexTest extends TestCase
Expand Down
Loading