Added regex options to rule conditions

This commit is contained in:
Will Browning 2024-07-24 12:35:24 +01:00
parent 18e1223b90
commit 28cf7b475e
53 changed files with 188 additions and 133 deletions

View File

@ -55,14 +55,14 @@ class CreateUser extends Command
'regex:/^[a-zA-Z0-9]*$/',
'max:20',
'unique:usernames,username',
new NotDeletedUsername(),
new NotDeletedUsername,
],
'email' => [
'required',
'email:rfc,dns',
'max:254',
new RegisterUniqueRecipient(),
new NotLocalRecipient(),
new RegisterUniqueRecipient,
new NotLocalRecipient,
],
]);

View File

@ -454,7 +454,7 @@ class ReceiveEmail extends Command
}
if ($user->nearBandwidthLimit() && ! Cache::has("user:{$user->id}:near-bandwidth")) {
$user->notify(new NearBandwidthLimit());
$user->notify(new NearBandwidthLimit);
Cache::put("user:{$user->id}:near-bandwidth", now()->toDateTimeString(), now()->addDay());
}
@ -491,7 +491,7 @@ class ReceiveEmail extends Command
protected function getParser($file)
{
$parser = new Parser();
$parser = new Parser;
// Fix some edge cases in from name e.g. "\" John Doe \"" <johndoe@example.com>
$parser->addMiddleware(function ($mimePart, $next) {

View File

@ -84,7 +84,7 @@ class CustomMailer extends Mailer
$recipient->update(['should_encrypt' => false]);
$recipient->notify(new GpgKeyExpired());
$recipient->notify(new GpgKeyExpired);
}
if ($encryptedSymfonyMessage) {
@ -101,7 +101,7 @@ class CustomMailer extends Mailer
if (isset($data['needsDkimSignature']) && $data['needsDkimSignature'] && ! is_null(config('anonaddy.dkim_signing_key'))) {
$dkimSigner = new DkimSigner(config('anonaddy.dkim_signing_key'), $data['aliasDomain'], config('anonaddy.dkim_selector'));
$options = (new DkimOptions())->headersToIgnore([
$options = (new DkimOptions)->headersToIgnore([
'List-Unsubscribe',
'List-Unsubscribe-Post',
'Return-Path',

View File

@ -220,7 +220,7 @@ class OpenPGPEncrypter
}
if (! $this->gnupg) {
$this->gnupg = new \gnupg();
$this->gnupg = new \gnupg;
}
$this->gnupg->seterrormode(\gnupg::ERROR_EXCEPTION);

View File

@ -86,7 +86,7 @@ class EncryptedPart extends AbstractPart
public function getPreparedHeaders(): Headers
{
return clone new Headers();
return clone new Headers;
}
public function asDebugString(): string
@ -104,7 +104,7 @@ class EncryptedPart extends AbstractPart
private function getEncoder(): ContentEncoderInterface
{
return new RawContentEncoder();
return new RawContentEncoder;
}
public function __sleep(): array

View File

@ -13,6 +13,6 @@ class AliasExportController extends Controller
return back()->withErrors(['aliases_export' => 'You don\'t have any aliases to export.']);
}
return Excel::download(new AliasesExport(), 'aliases-'.now()->toDateString().'.csv');
return Excel::download(new AliasesExport, 'aliases-'.now()->toDateString().'.csv');
}
}

View File

@ -217,7 +217,7 @@ class AliasBulkController extends Controller
'recipient_ids' => [
'array',
'max:10',
new VerifiedRecipientId(),
new VerifiedRecipientId,
],
'recipient_ids.*' => 'required|uuid|distinct',
]);

View File

@ -29,7 +29,7 @@ class DomainController extends Controller
public function store(StoreDomainRequest $request)
{
$domain = new Domain();
$domain = new Domain;
$domain->domain = $request->domain;
if (! $domain->checkVerification()) {

View File

@ -12,7 +12,7 @@ class RecipientKeyController extends Controller
public function __construct()
{
$this->gnupg = new \gnupg();
$this->gnupg = new \gnupg;
}
public function update(UpdateRecipientKeyRequest $request, $id)

View File

@ -85,7 +85,7 @@ class ApiAuthenticationController extends Controller
], 401);
}
$google2fa = new Google2FA();
$google2fa = new Google2FA;
$lastTimeStamp = Cache::get('2fa_ts:'.$user->id, 0);
$timestamp = $google2fa->verifyKeyNewer($user->two_factor_secret, $request->otp, $lastTimeStamp, config('google2fa.window'));

View File

@ -36,7 +36,7 @@ class PersonalAccessTokenController extends Controller
return [
'token' => new PersonalAccessTokenResource($token->accessToken),
'accessToken' => $accessToken,
'qrCode' => (new QRCode())->render(config('app.url').'|'.$accessToken),
'qrCode' => (new QRCode)->render(config('app.url').'|'.$accessToken),
];
}

View File

@ -79,8 +79,8 @@ class RegisterController extends Controller
'regex:/^[a-zA-Z0-9]*$/',
'max:20',
'unique:usernames,username',
new NotBlacklisted(),
new NotDeletedUsername(),
new NotBlacklisted,
new NotDeletedUsername,
],
'email' => [
'bail',
@ -88,8 +88,8 @@ class RegisterController extends Controller
'email:rfc,dns',
'max:254',
'confirmed',
new RegisterUniqueRecipient(),
new NotLocalRecipient(),
new RegisterUniqueRecipient,
new NotLocalRecipient,
],
'password' => ['required', Password::defaults()],
], [

View File

@ -30,7 +30,7 @@ class EditDefaultRecipientRequest extends FormRequest
'required',
'email:rfc,dns',
'max:254',
new RegisterUniqueRecipient(),
new RegisterUniqueRecipient,
'not_in:'.$this->user()->email,
],
'current' => 'required|string|current_password',

View File

@ -29,7 +29,7 @@ class StoreAliasRecipientRequest extends FormRequest
'bail',
'array',
'max:10',
new VerifiedRecipientId(),
new VerifiedRecipientId,
],
];
}

View File

@ -51,7 +51,7 @@ class StoreAliasRequest extends FormRequest
'nullable',
'array',
'max:10',
new VerifiedRecipientId(),
new VerifiedRecipientId,
],
];
}
@ -65,7 +65,7 @@ class StoreAliasRequest extends FormRequest
Rule::unique('aliases', 'local_part')->where(function ($query) {
return $query->where('domain', $this->validationData()['domain']);
}),
new ValidAliasLocalPart(),
new ValidAliasLocalPart,
], function () {
$format = $this->validationData()['format'] ?? 'random_characters';

View File

@ -33,9 +33,9 @@ class StoreDomainRequest extends FormRequest
'string',
'max:50',
'unique:domains',
new ValidDomain(),
new NotLocalDomain(),
new NotUsedAsRecipientDomain(),
new ValidDomain,
new NotLocalDomain,
new NotUsedAsRecipientDomain,
],
];
}

View File

@ -32,8 +32,8 @@ class StoreRecipientRequest extends FormRequest
'string',
'max:254',
'email:rfc',
new UniqueRecipient(),
new NotLocalRecipient(),
new UniqueRecipient,
new NotLocalRecipient,
],
];
}

View File

@ -28,7 +28,7 @@ class StoreReorderRuleRequest extends FormRequest
'ids' => [
'required',
'array',
new ValidRuleId(),
new ValidRuleId,
],
];
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Requests;
use App\Rules\ValidRegex;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@ -58,15 +59,30 @@ class StoreRuleRequest extends FormRequest
'does not end with',
]),
],
'conditions.*.values' => [
'required',
'array',
'min:1',
'max:10',
],
'conditions.*.values.*' => [
'distinct',
],
'conditions.*.values' => Rule::forEach(function ($value, $attribute, $data, $condition) {
if (in_array($condition['match'], ['matches regex', 'does not match regex'])) {
return [
'required',
'array',
'min:1',
'max:1',
];
}
return [
'required',
'array',
'min:1',
'max:10',
];
}),
'conditions.*.values.*' => Rule::forEach(function ($value, $attribute, $data) {
if (in_array(array_values($data)[1], ['matches regex', 'does not match regex'])) {
return [new ValidRegex];
}
return ['distinct'];
}),
'actions' => [
'required',
'array',

View File

@ -32,8 +32,8 @@ class StoreUsernameRequest extends FormRequest
'regex:/^[a-zA-Z0-9]*$/',
'max:20',
'unique:usernames,username',
new NotBlacklisted(),
new NotDeletedUsername(),
new NotBlacklisted,
new NotDeletedUsername,
],
];
}

View File

@ -33,7 +33,7 @@ class TestAutoCreateRegexRequest extends FormRequest
],
'local_part' => [
'required',
new ValidAliasLocalPart(),
new ValidAliasLocalPart,
],
];
}

View File

@ -31,7 +31,7 @@ class UpdateDomainRequest extends FormRequest
'nullable',
'string',
'max:100',
new ValidRegex(),
new ValidRegex,
],
];
}

View File

@ -31,7 +31,7 @@ class UpdateUsernameRequest extends FormRequest
'nullable',
'string',
'max:100',
new ValidRegex(),
new ValidRegex,
],
];
}

View File

@ -158,7 +158,7 @@ class AliasesImport implements ShouldQueue, SkipsEmptyRows, SkipsOnError, SkipsO
'required',
'max:64',
'string',
new ValidAliasLocalPart(),
new ValidAliasLocalPart,
],
'domain' => [
'bail',

View File

@ -27,7 +27,7 @@ class SendIncorrectOtpNotification
// Log in auth.log
Log::channel('auth')->info('Failed OTP Notification sent: '.$user->username);
$user->notify(new IncorrectOtpNotification());
$user->notify(new IncorrectOtpNotification);
}
}
}

View File

@ -176,7 +176,7 @@ class EmailData
} else {
if (! str_contains($contentType, '/')) {
if (self::$mimeTypes === null) {
self::$mimeTypes = new MimeTypes();
self::$mimeTypes = new MimeTypes;
}
$contentType = self::$mimeTypes->getMimeTypes($contentType)[0] ?? 'application/octet-stream';
}
@ -203,7 +203,7 @@ class EmailData
private function attemptToDecrypt($part)
{
try {
$gnupg = new \gnupg();
$gnupg = new \gnupg;
$gnupg->cleardecryptkeys();
$gnupg->adddecryptkey(config('anonaddy.signing_key_fingerprint'), null);
@ -214,7 +214,7 @@ class EmailData
if ($decrypted) {
$decryptedParser = new Parser();
$decryptedParser = new Parser;
$decryptedParser->setText($decrypted);
// Set decrypted data as subject (as may have encrypted subject too), html and text
@ -235,7 +235,7 @@ class EmailData
private function attemptToDecryptInline($text)
{
try {
$gnupg = new \gnupg();
$gnupg = new \gnupg;
$gnupg->cleardecryptkeys();
$gnupg->adddecryptkey(config('anonaddy.signing_key_fingerprint'), null);

View File

@ -205,7 +205,7 @@ class Recipient extends Model
*/
public function sendEmailVerificationNotification()
{
$this->notify(new CustomVerifyEmail());
$this->notify(new CustomVerifyEmail);
}
/**
@ -215,7 +215,7 @@ class Recipient extends Model
*/
public function sendUsernameReminderNotification()
{
$this->notify(new UsernameReminder());
$this->notify(new UsernameReminder);
}
/**

View File

@ -414,7 +414,7 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function sendEmailVerificationNotification()
{
$this->notify(new CustomVerifyEmail());
$this->notify(new CustomVerifyEmail);
}
/**
@ -546,7 +546,7 @@ class User extends Authenticatable implements MustVerifyEmail
public function deleteKeyFromKeyring($fingerprint): void
{
$gnupg = new \gnupg();
$gnupg = new \gnupg;
$recipientsUsingFingerprint = $this
->recipients()

View File

@ -59,7 +59,7 @@ class AliasesImportedNotification extends Notification implements ShouldBeEncryp
$recipient = $notifiable->defaultRecipient;
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
return (new MailMessage)
->subject('Your aliases import has finished')
->markdown('mail.aliases_import_finished', [
'totalRows' => $this->totalRows,

View File

@ -37,7 +37,7 @@ class CustomVerifyEmail extends VerifyEmail implements ShouldBeEncrypted, Should
$recipientId = $notifiable instanceof User ? $notifiable->default_recipient_id : $notifiable->id;
$userId = $notifiable instanceof User ? $notifiable->id : $notifiable->user_id;
return (new MailMessage())
return (new MailMessage)
->subject(Lang::get('Verify Email Address'))
->markdown('mail.verify_email', [
'verificationUrl' => $verificationUrl,

View File

@ -44,7 +44,7 @@ class DefaultRecipientUpdated extends Notification implements ShouldBeEncrypted,
*/
public function toMail($notifiable)
{
return (new MailMessage())
return (new MailMessage)
->subject('Your default recipient has just been updated')
->markdown('mail.default_recipient_updated', [
'defaultRecipient' => $notifiable->email,

View File

@ -56,7 +56,7 @@ class DisallowedReplySendAttempt extends Notification implements ShouldBeEncrypt
{
$fingerprint = $notifiable->should_encrypt ? $notifiable->fingerprint : null;
return (new MailMessage())
return (new MailMessage)
->subject('Disallowed reply/send from alias')
->markdown('mail.disallowed_reply_send_attempt', [
'aliasEmail' => $this->aliasEmail,

View File

@ -47,7 +47,7 @@ class DomainMxRecordsInvalid extends Notification implements ShouldBeEncrypted,
$recipient = $notifiable->defaultRecipient;
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
return (new MailMessage)
->subject("Your domain's MX records no longer point to addy.io")
->markdown('mail.domain_mx_records_invalid', [
'domain' => $this->domain,

View File

@ -50,7 +50,7 @@ class DomainUnverifiedForSending extends Notification implements ShouldBeEncrypt
$recipient = $notifiable->defaultRecipient;
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
return (new MailMessage)
->subject('Your domain has been unverified for sending on addy.io')
->markdown('mail.domain_unverified_for_sending', [
'domain' => $this->domain,

View File

@ -58,7 +58,7 @@ class FailedDeliveryNotification extends Notification implements ShouldBeEncrypt
*/
public function toMail($notifiable)
{
return (new MailMessage())
return (new MailMessage)
->subject('New failed delivery on addy.io')
->markdown('mail.failed_delivery_notification', [
'aliasEmail' => $this->aliasEmail,

View File

@ -32,7 +32,7 @@ class GpgKeyExpired extends Notification implements ShouldBeEncrypted, ShouldQue
*/
public function toMail($notifiable)
{
return (new MailMessage())
return (new MailMessage)
->subject('Your GPG key has expired on addy.io')
->markdown('mail.gpg_key_expired', [
'recipient' => $notifiable,

View File

@ -35,7 +35,7 @@ class IncorrectOtpNotification extends Notification implements ShouldBeEncrypted
$recipient = $notifiable->defaultRecipient;
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
return (new MailMessage)
->subject('Failed Two Factor Authentication Login Attempt')
->markdown('mail.failed_login_attempt', [
'userId' => $notifiable->id,

View File

@ -50,7 +50,7 @@ class NearBandwidthLimit extends Notification implements ShouldBeEncrypted, Shou
$recipient = $notifiable->defaultRecipient;
$fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
return (new MailMessage())
return (new MailMessage)
->subject("You're close to your bandwidth limit for ".$this->month)
->markdown('mail.near_bandwidth_limit', [
'bandwidthUsage' => $notifiable->bandwidth_mb,

View File

@ -54,7 +54,7 @@ class SpamReplySendAttempt extends Notification implements ShouldBeEncrypted, Sh
*/
public function toMail($notifiable)
{
return (new MailMessage())
return (new MailMessage)
->subject('Attempted reply/send from alias has failed')
->markdown('mail.spam_reply_send_attempt', [
'aliasEmail' => $this->aliasEmail,

View File

@ -32,7 +32,7 @@ class UsernameReminder extends Notification implements ShouldBeEncrypted, Should
*/
public function toMail($notifiable)
{
return (new MailMessage())
return (new MailMessage)
->subject('addy.io Username Reminder')
->markdown('mail.username_reminder', [
'username' => $notifiable->user->username,

View File

@ -108,7 +108,16 @@ trait CheckUserRules
return ! Str::endsWith($variable, $value);
});
break;
// regex preg_match?
case 'matches regex':
return $values->contains(function ($value) use ($variable) {
return Str::isMatch("/{$value}/", $variable);
});
break;
case 'does not match regex':
return $values->contains(function ($value) use ($variable) {
return ! Str::isMatch("/{$value}/", $variable);
});
break;
}
}

42
composer.lock generated
View File

@ -1196,16 +1196,16 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "7.9.1",
"version": "7.9.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "a629e5b69db96eb4939c1b34114130077dd4c6fc"
"reference": "d281ed313b989f213357e3be1a179f02196ac99b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/a629e5b69db96eb4939c1b34114130077dd4c6fc",
"reference": "a629e5b69db96eb4939c1b34114130077dd4c6fc",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b",
"reference": "d281ed313b989f213357e3be1a179f02196ac99b",
"shasum": ""
},
"require": {
@ -1302,7 +1302,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.9.1"
"source": "https://github.com/guzzle/guzzle/tree/7.9.2"
},
"funding": [
{
@ -1318,7 +1318,7 @@
"type": "tidelift"
}
],
"time": "2024-07-19T16:19:57+00:00"
"time": "2024-07-24T11:22:20+00:00"
},
{
"name": "guzzlehttp/promises",
@ -1767,16 +1767,16 @@
},
{
"name": "laravel/framework",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "bd4808aaf103ccb5cb4b00bcee46140c070c0ec4"
"reference": "42f505a0c8afc0743f73e70bec08e641e2870bd6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/bd4808aaf103ccb5cb4b00bcee46140c070c0ec4",
"reference": "bd4808aaf103ccb5cb4b00bcee46140c070c0ec4",
"url": "https://api.github.com/repos/laravel/framework/zipball/42f505a0c8afc0743f73e70bec08e641e2870bd6",
"reference": "42f505a0c8afc0743f73e70bec08e641e2870bd6",
"shasum": ""
},
"require": {
@ -1969,7 +1969,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-07-16T14:33:07+00:00"
"time": "2024-07-23T16:33:27+00:00"
},
{
"name": "laravel/prompts",
@ -8968,16 +8968,16 @@
},
{
"name": "laravel/pint",
"version": "v1.16.2",
"version": "v1.17.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "51f1ba679a6afe0315621ad143d788bd7ded0eca"
"reference": "4dba80c1de4b81dc4c4fb10ea6f4781495eb29f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/51f1ba679a6afe0315621ad143d788bd7ded0eca",
"reference": "51f1ba679a6afe0315621ad143d788bd7ded0eca",
"url": "https://api.github.com/repos/laravel/pint/zipball/4dba80c1de4b81dc4c4fb10ea6f4781495eb29f5",
"reference": "4dba80c1de4b81dc4c4fb10ea6f4781495eb29f5",
"shasum": ""
},
"require": {
@ -9030,7 +9030,7 @@
"issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint"
},
"time": "2024-07-09T15:58:08+00:00"
"time": "2024-07-23T16:40:20+00:00"
},
{
"name": "mockery/mockery",
@ -9520,16 +9520,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.11.7",
"version": "1.11.8",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d"
"reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/52d2bbfdcae7f895915629e4694e9497d0f8e28d",
"reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec",
"reference": "6adbd118e6c0515dd2f36b06cde1d6da40f1b8ec",
"shasum": ""
},
"require": {
@ -9574,7 +9574,7 @@
"type": "github"
}
],
"time": "2024-07-06T11:17:41+00:00"
"time": "2024-07-24T07:01:22+00:00"
},
{
"name": "phpunit/php-code-coverage",

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration
return new class extends Migration
{
/**
* Run the migrations.

18
package-lock.json generated
View File

@ -723,18 +723,18 @@
"peer": true
},
"node_modules/@types/node": {
"version": "20.14.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz",
"integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==",
"version": "20.14.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz",
"integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==",
"peer": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/@vitejs/plugin-vue": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.5.tgz",
"integrity": "sha512-LOjm7XeIimLBZyzinBQ6OSm3UBCNVCpLkxGC0oWmm2YPzVZoxMsdvNVimLTBzpAnR9hl/yn1SHGuRfe6/Td9rQ==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.1.0.tgz",
"integrity": "sha512-QMRxARyrdiwi1mj3AW4fLByoHTavreXq0itdEW696EihXglf1MB3D4C2gBvE0jMPH29ZjC3iK8aIaUMLf4EOGA==",
"dev": true,
"engines": {
"node": "^18.0.0 || >=20.0.0"
@ -1622,9 +1622,9 @@
}
},
"node_modules/enhanced-resolve": {
"version": "5.17.0",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz",
"integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==",
"version": "5.17.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz",
"integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==",
"peer": true,
"dependencies": {
"graceful-fs": "^4.2.4",

View File

@ -32,7 +32,7 @@ try {
$dotenv = Dotenv\Dotenv::create($repository, dirname(__DIR__));
$dotenv->load();
$database = new Database();
$database = new Database;
$database->addConnection([
'driver' => 'mysql',
@ -171,7 +171,7 @@ try {
// If the alias is inactive or deleted then increment the blocked count
Database::table('aliases')
->where('email', $aliasEmail)
->increment('emails_blocked', 1, ['last_blocked' => new DateTime()]);
->increment('emails_blocked', 1, ['last_blocked' => new DateTime]);
sendAction($aliasAction);
} elseif ($aliasHasSharedDomain || in_array($aliasAction, [ACTION_REJECT, ACTION_DEFER])) {
@ -344,5 +344,5 @@ function endsWith($haystack, $needles)
function logData($data)
{
file_put_contents(__DIR__.'/../storage/logs/postfix-access-policy.log', '['.(new DateTime())->format('Y-m-d H:i:s').'] '.$data.PHP_EOL, FILE_APPEND);
file_put_contents(__DIR__.'/../storage/logs/postfix-access-policy.log', '['.(new DateTime)->format('Y-m-d H:i:s').'] '.$data.PHP_EOL, FILE_APPEND);
}

46
postfix/composer.lock generated
View File

@ -290,16 +290,16 @@
},
{
"name": "illuminate/collections",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "ba2cf689f7d75315f483334b4efc8c6af1d5159c"
"reference": "2be24113fe25ef18be33bbd083ad36bf1e751eb5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/ba2cf689f7d75315f483334b4efc8c6af1d5159c",
"reference": "ba2cf689f7d75315f483334b4efc8c6af1d5159c",
"url": "https://api.github.com/repos/illuminate/collections/zipball/2be24113fe25ef18be33bbd083ad36bf1e751eb5",
"reference": "2be24113fe25ef18be33bbd083ad36bf1e751eb5",
"shasum": ""
},
"require": {
@ -341,11 +341,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-07-15T21:44:45+00:00"
"time": "2024-07-23T14:08:10+00:00"
},
{
"name": "illuminate/conditionable",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/conditionable.git",
@ -391,16 +391,16 @@
},
{
"name": "illuminate/container",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
"reference": "49183db6643a7efbe9902ca379b8f8a55c802f88"
"reference": "c3c2713c66d120bf42865e831cfcef6ed9e10db2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/container/zipball/49183db6643a7efbe9902ca379b8f8a55c802f88",
"reference": "49183db6643a7efbe9902ca379b8f8a55c802f88",
"url": "https://api.github.com/repos/illuminate/container/zipball/c3c2713c66d120bf42865e831cfcef6ed9e10db2",
"reference": "c3c2713c66d120bf42865e831cfcef6ed9e10db2",
"shasum": ""
},
"require": {
@ -438,11 +438,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-07-03T21:04:00+00:00"
"time": "2024-07-18T15:50:24+00:00"
},
{
"name": "illuminate/contracts",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@ -490,16 +490,16 @@
},
{
"name": "illuminate/database",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
"reference": "cf816e7e0d08e2a75b233ad061eed85dd8b6b37f"
"reference": "35a9f2e39aba083835c3a17e18f184b2e2529039"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/cf816e7e0d08e2a75b233ad061eed85dd8b6b37f",
"reference": "cf816e7e0d08e2a75b233ad061eed85dd8b6b37f",
"url": "https://api.github.com/repos/illuminate/database/zipball/35a9f2e39aba083835c3a17e18f184b2e2529039",
"reference": "35a9f2e39aba083835c3a17e18f184b2e2529039",
"shasum": ""
},
"require": {
@ -554,11 +554,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-07-15T22:28:28+00:00"
"time": "2024-07-23T16:22:48+00:00"
},
{
"name": "illuminate/macroable",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -604,16 +604,16 @@
},
{
"name": "illuminate/support",
"version": "v11.16.0",
"version": "v11.17.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
"reference": "4fd85fffd9a4812386b6e10b2a18272ff9040dbe"
"reference": "a348d3fc2ff717da9f7a2fb9c13d3667de6a38cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/4fd85fffd9a4812386b6e10b2a18272ff9040dbe",
"reference": "4fd85fffd9a4812386b6e10b2a18272ff9040dbe",
"url": "https://api.github.com/repos/illuminate/support/zipball/a348d3fc2ff717da9f7a2fb9c13d3667de6a38cd",
"reference": "a348d3fc2ff717da9f7a2fb9c13d3667de6a38cd",
"shasum": ""
},
"require": {
@ -674,7 +674,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-07-16T13:48:58+00:00"
"time": "2024-07-23T14:08:10+00:00"
},
{
"name": "nesbot/carbon",

View File

@ -236,6 +236,7 @@
<div class="relative sm:mr-4">
<select
v-model="createRuleObject.conditions[key].match"
@change="ruleConditionMatchChange(createRuleObject.conditions[key])"
:id="`create_rule_condition_matches_${key}`"
class="block appearance-none w-full sm:w-40 text-grey-700 bg-white p-2 pr-8 rounded shadow focus:ring"
required
@ -561,6 +562,7 @@
<div class="relative sm:mr-4">
<select
v-model="editRuleObject.conditions[key].match"
@change="ruleConditionMatchChange(editRuleObject.conditions[key])"
:id="`edit_rule_condition_matches_${key}`"
class="block appearance-none w-full sm:w-40 text-grey-700 bg-white p-2 pr-8 rounded shadow focus:ring"
required
@ -1251,6 +1253,8 @@ const conditionMatchOptions = (object, key) => {
'does not start with',
'ends with',
'does not end with',
'matches regex',
'does not match regex',
]
}
@ -1274,14 +1278,29 @@ const deleteCondition = (object, key) => {
}
const addValueToCondition = (object, key) => {
if (!object.conditions[key].currentConditionValue) {
return (errors.value.ruleConditions = `You must enter a value to insert`)
}
if (object.conditions[key].values.length >= 10) {
return (errors.value.ruleConditions = `You cannot add more than 10 values per condition`)
}
if (object.conditions[key].currentConditionValue) {
object.conditions[key].values.push(object.conditions[key].currentConditionValue)
if (['matches regex', 'does not match regex'].includes(object.conditions[key].match)) {
try {
let re = new RegExp(object.conditions[key].currentConditionValue)
re.test('')
} catch (e) {
return (errors.value.ruleConditions = `Please enter a valid regular expression`)
}
if (object.conditions[key].values.length >= 1) {
return (errors.value.ruleConditions = `You can only add 1 regex value`)
}
}
object.conditions[key].values.push(object.conditions[key].currentConditionValue)
// Reset current conditon value input
object.conditions[key].currentConditionValue = ''
}
@ -1324,6 +1343,17 @@ const resetCreateRuleObject = () => {
}
}
const ruleConditionMatchChange = condition => {
errors.value.ruleConditions = ''
if (
condition.match === 'matches regex' ||
(condition.match === 'does not match regex' && condition.values.length >= 1)
) {
condition.values = condition.values.splice(0, 1)
}
}
const ruleActionChange = action => {
if (action.type === 'subject' || action.type === 'displayFrom' || action.type === 'select') {
action.value = ''

View File

@ -208,7 +208,7 @@ class RecipientsTest extends TestCase
#[Test]
public function user_can_add_gpg_key_to_recipient()
{
$gnupg = new \gnupg();
$gnupg = new \gnupg;
$gnupg->deletekey('26A987650243B28802524E2F809FD0D502E2F695');
$recipient = Recipient::factory()->create([
@ -257,7 +257,7 @@ class RecipientsTest extends TestCase
#[Test]
public function user_can_remove_gpg_key_from_recipient()
{
$gnupg = new \gnupg();
$gnupg = new \gnupg;
$gnupg->import(file_get_contents(base_path('tests/keys/AnonAddyPublicKey.asc')));
$recipient = Recipient::factory()->create([

View File

@ -470,7 +470,7 @@ class RulesTest extends TestCase
protected function getParser($file)
{
$parser = new Parser();
$parser = new Parser;
// Fix some edge cases in from name e.g. "\" John Doe \"" <johndoe@example.com>
$parser->addMiddleware(function ($mimePart, $next) {