Merge branch 'master' of github.com:akaunting/akaunting

This commit is contained in:
Cüneyt Şentürk 2023-08-09 13:31:29 +03:00
commit 6b9b02ef9a
8 changed files with 107 additions and 86 deletions

View File

@ -5,7 +5,6 @@ namespace App\Listeners\Email;
use Akaunting\Firewall\Events\AttackDetected; use Akaunting\Firewall\Events\AttackDetected;
use Akaunting\Firewall\Traits\Helper; use Akaunting\Firewall\Traits\Helper;
use App\Events\Email\TooManyEmailsSent as Event; use App\Events\Email\TooManyEmailsSent as Event;
use Illuminate\Support\Facades\Config;
class TellFirewallTooManyEmailsSent class TellFirewallTooManyEmailsSent
{ {
@ -17,9 +16,7 @@ class TellFirewallTooManyEmailsSent
$this->middleware = 'too_many_emails_sent'; $this->middleware = 'too_many_emails_sent';
$this->user_id = $event->user_id; $this->user_id = $event->user_id;
$this->loadConfig(); if ($this->skip()) {
if ($this->skip($event)) {
return; return;
} }
@ -28,40 +25,7 @@ class TellFirewallTooManyEmailsSent
event(new AttackDetected($log)); event(new AttackDetected($log));
} }
public function loadConfig(): void public function skip(): bool
{
if (! empty(Config::get('firewall.middleware.' . $this->middleware))) {
return;
}
$config = array_merge_recursive(
Config::get('firewall'),
[
'middleware' => [
$this->middleware => [
'enabled' => env('FIREWALL_MIDDLEWARE_' . strtoupper($this->middleware) . '_ENABLED', Config::get('firewall.enabled', true)),
'methods' => ['post'],
'routes' => [
'only' => [], // i.e. 'contact'
'except' => [], // i.e. 'admin/*'
],
'auto_block' => [
'attempts' => env('FIREWALL_MIDDLEWARE_' . strtoupper($this->middleware) . '_AUTO_BLOCK_ATTEMPTS', 20),
'frequency' => 1 * 60, // 1 minute
'period' => 30 * 60, // 30 minutes
],
],
],
]
);
Config::set('firewall', $config);
}
public function skip($event): bool
{ {
if ($this->isDisabled()) { if ($this->isDisabled()) {
return true; return true;

103
composer.lock generated
View File

@ -4951,16 +4951,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v10.16.1", "version": "v10.17.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "5c93d2795c393b462481179ce42dedfb30cc19b5" "reference": "a0e3f5ac5b6258f6ede9a2a2c5cc3820baea24a2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/5c93d2795c393b462481179ce42dedfb30cc19b5", "url": "https://api.github.com/repos/laravel/framework/zipball/a0e3f5ac5b6258f6ede9a2a2c5cc3820baea24a2",
"reference": "5c93d2795c393b462481179ce42dedfb30cc19b5", "reference": "a0e3f5ac5b6258f6ede9a2a2c5cc3820baea24a2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4978,11 +4978,12 @@
"ext-tokenizer": "*", "ext-tokenizer": "*",
"fruitcake/php-cors": "^1.2", "fruitcake/php-cors": "^1.2",
"guzzlehttp/uri-template": "^1.0", "guzzlehttp/uri-template": "^1.0",
"laravel/prompts": "^0.1",
"laravel/serializable-closure": "^1.3", "laravel/serializable-closure": "^1.3",
"league/commonmark": "^2.2.1", "league/commonmark": "^2.2.1",
"league/flysystem": "^3.8.0", "league/flysystem": "^3.8.0",
"monolog/monolog": "^3.0", "monolog/monolog": "^3.0",
"nesbot/carbon": "^2.62.1", "nesbot/carbon": "^2.67",
"nunomaduro/termwind": "^1.13", "nunomaduro/termwind": "^1.13",
"php": "^8.1", "php": "^8.1",
"psr/container": "^1.1.1|^2.0.1", "psr/container": "^1.1.1|^2.0.1",
@ -5061,7 +5062,6 @@
"mockery/mockery": "^1.5.1", "mockery/mockery": "^1.5.1",
"orchestra/testbench-core": "^8.4", "orchestra/testbench-core": "^8.4",
"pda/pheanstalk": "^4.0", "pda/pheanstalk": "^4.0",
"phpstan/phpdoc-parser": "^1.15",
"phpstan/phpstan": "^1.4.7", "phpstan/phpstan": "^1.4.7",
"phpunit/phpunit": "^10.0.7", "phpunit/phpunit": "^10.0.7",
"predis/predis": "^2.0.2", "predis/predis": "^2.0.2",
@ -5147,7 +5147,55 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2023-07-26T03:30:46+00:00" "time": "2023-08-01T14:08:45+00:00"
},
{
"name": "laravel/prompts",
"version": "v0.1.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/prompts.git",
"reference": "309b30157090a63c40152aa912d198d6aeb60ea6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/prompts/zipball/309b30157090a63c40152aa912d198d6aeb60ea6",
"reference": "309b30157090a63c40152aa912d198d6aeb60ea6",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"illuminate/collections": "^10.0",
"php": "^8.1",
"symfony/console": "^6.2"
},
"require-dev": {
"mockery/mockery": "^1.5",
"pestphp/pest": "^2.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-mockery": "^1.1"
},
"suggest": {
"ext-pcntl": "Required for the spinner to be animated."
},
"type": "library",
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Laravel\\Prompts\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"support": {
"issues": "https://github.com/laravel/prompts/issues",
"source": "https://github.com/laravel/prompts/tree/v0.1.1"
},
"time": "2023-07-31T15:03:02+00:00"
}, },
{ {
"name": "laravel/sanctum", "name": "laravel/sanctum",
@ -9075,16 +9123,16 @@
}, },
{ {
"name": "psy/psysh", "name": "psy/psysh",
"version": "v0.11.19", "version": "v0.11.20",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/bobthecow/psysh.git", "url": "https://github.com/bobthecow/psysh.git",
"reference": "1724ceff278daeeac5a006744633bacbb2dc4706" "reference": "0fa27040553d1d280a67a4393194df5228afea5b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/1724ceff278daeeac5a006744633bacbb2dc4706", "url": "https://api.github.com/repos/bobthecow/psysh/zipball/0fa27040553d1d280a67a4393194df5228afea5b",
"reference": "1724ceff278daeeac5a006744633bacbb2dc4706", "reference": "0fa27040553d1d280a67a4393194df5228afea5b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9145,9 +9193,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/bobthecow/psysh/issues", "issues": "https://github.com/bobthecow/psysh/issues",
"source": "https://github.com/bobthecow/psysh/tree/v0.11.19" "source": "https://github.com/bobthecow/psysh/tree/v0.11.20"
}, },
"time": "2023-07-15T19:42:19+00:00" "time": "2023-07-31T14:32:22+00:00"
}, },
{ {
"name": "ralouphie/getallheaders", "name": "ralouphie/getallheaders",
@ -9691,16 +9739,16 @@
}, },
{ {
"name": "sentry/sentry", "name": "sentry/sentry",
"version": "3.20.1", "version": "3.21.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/getsentry/sentry-php.git", "url": "https://github.com/getsentry/sentry-php.git",
"reference": "644ad9768c18139a80ac510090fad000d9ffd8a4" "reference": "624aafc22b84b089ffa43b71fb01e0096505ec4f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/644ad9768c18139a80ac510090fad000d9ffd8a4", "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/624aafc22b84b089ffa43b71fb01e0096505ec4f",
"reference": "644ad9768c18139a80ac510090fad000d9ffd8a4", "reference": "624aafc22b84b089ffa43b71fb01e0096505ec4f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9744,11 +9792,6 @@
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler." "monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.13.x-dev"
}
},
"autoload": { "autoload": {
"files": [ "files": [
"src/functions.php" "src/functions.php"
@ -9780,7 +9823,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/getsentry/sentry-php/issues", "issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/3.20.1" "source": "https://github.com/getsentry/sentry-php/tree/3.21.0"
}, },
"funding": [ "funding": [
{ {
@ -9792,20 +9835,20 @@
"type": "custom" "type": "custom"
} }
], ],
"time": "2023-06-26T11:01:40+00:00" "time": "2023-07-31T15:31:24+00:00"
}, },
{ {
"name": "sentry/sentry-laravel", "name": "sentry/sentry-laravel",
"version": "3.7.0", "version": "3.7.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/getsentry/sentry-laravel.git", "url": "https://github.com/getsentry/sentry-laravel.git",
"reference": "f6f64312a13f1b801e570713e857cdb83896e58b" "reference": "d1b21a9552db12016d3aeb15f6e6188a03a5dd87"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/f6f64312a13f1b801e570713e857cdb83896e58b", "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/d1b21a9552db12016d3aeb15f6e6188a03a5dd87",
"reference": "f6f64312a13f1b801e570713e857cdb83896e58b", "reference": "d1b21a9552db12016d3aeb15f6e6188a03a5dd87",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9870,7 +9913,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/getsentry/sentry-laravel/issues", "issues": "https://github.com/getsentry/sentry-laravel/issues",
"source": "https://github.com/getsentry/sentry-laravel/tree/3.7.0" "source": "https://github.com/getsentry/sentry-laravel/tree/3.7.1"
}, },
"funding": [ "funding": [
{ {
@ -9882,7 +9925,7 @@
"type": "custom" "type": "custom"
} }
], ],
"time": "2023-07-31T11:54:22+00:00" "time": "2023-08-01T10:02:58+00:00"
}, },
{ {
"name": "simple-icons/simple-icons", "name": "simple-icons/simple-icons",

View File

@ -436,6 +436,24 @@ return [
], ],
], ],
// Custom middleware
'too_many_emails_sent' => [
'enabled' => env('FIREWALL_MIDDLEWARE_TOO_MANY_EMAILS_SENT_ENABLED', env('FIREWALL_ENABLED', true)),
'methods' => ['post'],
'routes' => [
'only' => [], // i.e. 'contact'
'except' => [], // i.e. 'admin/*'
],
'auto_block' => [
'attempts' => env('FIREWALL_MIDDLEWARE_TOO_MANY_EMAILS_SENT_AUTO_BLOCK_ATTEMPTS', 20),
'frequency' => 1 * 60, // 1 minute
'period' => 30 * 60, // 30 minutes
],
],
], ],
]; ];

View File

@ -43,9 +43,6 @@ return [
// Capture Livewire components as breadcrumbs // Capture Livewire components as breadcrumbs
'livewire' => env('SENTRY_BREADCRUMBS_LIVEWIRE_ENABLED', true), 'livewire' => env('SENTRY_BREADCRUMBS_LIVEWIRE_ENABLED', true),
// Capture storage access as breadcrumbs
'storage' => env('SENTRY_BREADCRUMBS_STORAGE_ENABLED', true),
// Capture SQL queries as breadcrumbs // Capture SQL queries as breadcrumbs
'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES_ENABLED', true), 'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES_ENABLED', true),
@ -78,9 +75,6 @@ return [
// Capture views rendered as spans // Capture views rendered as spans
'views' => env('SENTRY_TRACE_VIEWS_ENABLED', true), 'views' => env('SENTRY_TRACE_VIEWS_ENABLED', true),
// Capture storage access as spans
'storage' => env('SENTRY_TRACE_STORAGE_ENABLED', true),
// Capture Livewire components as spans // Capture Livewire components as spans
'livewire' => env('SENTRY_TRACE_LIVEWIRE_ENABLED', true), 'livewire' => env('SENTRY_TRACE_LIVEWIRE_ENABLED', true),

View File

@ -20,16 +20,16 @@
<img v-for="(file, indis) in item.files" :key="indis" v-if="file.media_type == 'image' && file.pivot.zone == 'thumbnail'" <img v-for="(file, indis) in item.files" :key="indis" v-if="file.media_type == 'image' && file.pivot.zone == 'thumbnail'"
:src="file.path_string" :src="file.path_string"
:alt="item.name" :alt="item.name"
class="rounded-lg object-cover" class="rounded-lg object-cover ml-1 mt-0.5"
/> />
</div> </div>
<div class="w-3/4 ltr:pl-2 rtl:pr-2"> <div class="w-3/4">
<span class="font-medium text-sm"> <h4 class="font-medium text-sm pb-1">
{{ item.name }} {{ item.name }}
</span> </h4>
<div class="text-black-300 text-sm mt-1 line-clamp-2 h-10" v-html="item.description"></div> <div class="text-black-300 text-sm mt-1 line-clamp-2 h-10 ltr:pr-0 rtl:pr-2" v-html="item.description"></div>
</div> </div>
</a> </a>
</div> </div>
@ -49,7 +49,7 @@
<div class="flex"> <div class="flex">
<base-button <base-button
class="relative flex items-center justify-center text-base rounded-lg m-auto mt-96 hover:underline py-1.5 -right-20 font-semibold disabled:bg-gray-100 " class="relative rtl:right-20 flex items-center justify-center text-base rounded-lg m-auto mt-96 hover:underline py-1.5 -right-20 font-semibold disabled:bg-gray-100 "
:disabled="anchor_loading" :disabled="anchor_loading"
@click="finish()" @click="finish()"
style="top: 5.9rem" style="top: 5.9rem"
@ -62,10 +62,10 @@
</base-button> </base-button>
<base-button <base-button
class="relative flex items-center justify-center text-base rounded-lg m-auto mt-96 bg-default hover:bg-default-hover text-white py-1.5 px-7 font-medium" class="relative ltr:-right-2 rtl:-left-2 flex items-center justify-center text-base rounded-lg m-auto mt-96 bg-default hover:bg-default-hover text-white py-1.5 px-7 font-medium"
:disabled="anchor_loading" :disabled="anchor_loading"
@click="finish()" @click="finish()"
style="top: 5.9rem; right: -0.6rem;" style="top: 5.9rem;"
> >
<i v-if="anchor_loading" class="animate-submit_second delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-2.5 m-auto before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit_second before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit_second before:-left-3.5 after:-right-3.5 after:delay-[0.42s]"></i> <i v-if="anchor_loading" class="animate-submit_second delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-2.5 m-auto before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit_second before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit_second before:-left-3.5 after:-right-3.5 after:delay-[0.42s]"></i>

View File

@ -28,7 +28,9 @@
@if (! $hideMarkSent) @if (! $hideMarkSent)
@can($permissionUpdate) @can($permissionUpdate)
@if ($document->status == 'draft') @if ($document->status == 'draft')
<x-link id="show-slider-actions-mark-sent-{{ $document->type }}" href="{{ route($markSentRoute, $document->id) }}" @click="e => e.target.classList.add('disabled')"> <x-link
x-data="{ clicked: false }" x-on:click="clicked = true" x-bind:class="{ 'pointer-events-none cursor-default': clicked }" x-bind:disabled="clicked"
id="show-slider-actions-mark-sent-{{ $document->type }}" href="{{ route($markSentRoute, $document->id) }}" @click="e => e.target.classList.add('disabled')">
{{ trans($textMarkSent) }} {{ trans($textMarkSent) }}
</x-link> </x-link>
@else @else

View File

@ -81,7 +81,7 @@
@click="onActionBulkAction" @click="onActionBulkAction"
class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100" class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100"
> >
<i v-if="bulk_action.loading" class="submit-spin absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto"></i> <i v-if="bulk_action.loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit before:-left-3.5 after:-right-3.5 after:delay-[0.42s]"></i>
<span :class="[{'opacity-0': bulk_action.loading}]">{{ trans('general.confirm') }}</span> <span :class="[{'opacity-0': bulk_action.loading}]">{{ trans('general.confirm') }}</span>
</button> </button>
</div> </div>

View File

@ -11,7 +11,7 @@ class TooManyEmailsSentTest extends FeatureTestCase
{ {
$this->loginAs(); $this->loginAs();
config(['firewall.enabled' => true]); config(['firewall.middleware.too_many_emails_sent.enabled' => true]);
for ($i = 0; $i < 19; $i++) { for ($i = 0; $i < 19; $i++) {
event(new TooManyEmailsSent(user_id())); event(new TooManyEmailsSent(user_id()));
@ -31,7 +31,7 @@ class TooManyEmailsSentTest extends FeatureTestCase
{ {
$this->loginAs(); $this->loginAs();
config(['firewall.enabled' => true]); config(['firewall.middleware.too_many_emails_sent.enabled' => true]);
for ($i = 0; $i < 20; $i++) { for ($i = 0; $i < 20; $i++) {
event(new TooManyEmailsSent(user_id())); event(new TooManyEmailsSent(user_id()));