]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5265 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 May 2022 09:41:53 +0000 (11:41 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 May 2022 09:41:53 +0000 (11:41 +0200)
.idea/workspace.xml
app/Models/CubedesignersEmails.php
composer.json
resources/emailconfig/postfix-main.cf
resources/emailconfig/spamassassin-rules.cf [new file with mode: 0644]

index 4539a062f81b559e3c93dc58e54c1603a58585e3..7e07c4e532ee6ded40f162a2ee30b14ae796bab4 100644 (file)
     <select />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5265 @0.5">
+    <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5228 @1.5">
+      <change afterPath="$PROJECT_DIR$/resources/emailconfig/spamassassin-rules.cf" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/Tools/PDF2SVGOperation.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/Tools/PDF2SVGOperation.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/app/Models/CubedesignersEmails.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/CubedesignersEmails.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Models/FluidbookQuote.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/FluidbookQuote.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/resources/emailconfig/postfix-main.cf" beforeDir="false" afterPath="$PROJECT_DIR$/resources/emailconfig/postfix-main.cf" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showLibraryContents" value="true" />
   </component>
-  <component name="PropertiesComponent">{
-  &quot;keyToString&quot;: {
-    &quot;WebServerToolWindowFactoryState&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.highlight.mappings&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.highlight.symlinks&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.show.date&quot;: &quot;false&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.show.permissions&quot;: &quot;false&quot;,
-    &quot;WebServerToolWindowPanel.toolwindow.show.size&quot;: &quot;false&quot;,
-    &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
-    &quot;ruby.rails.projectView.checked&quot;: &quot;true&quot;,
-    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "WebServerToolWindowFactoryState": "true",
+    "WebServerToolWindowPanel.toolwindow.highlight.mappings": "true",
+    "WebServerToolWindowPanel.toolwindow.highlight.symlinks": "true",
+    "WebServerToolWindowPanel.toolwindow.show.date": "false",
+    "WebServerToolWindowPanel.toolwindow.show.permissions": "false",
+    "WebServerToolWindowPanel.toolwindow.show.size": "false",
+    "last_opened_file_path": "D:/Works/FluidbookToolbox/resources/emailconfig",
+    "nodejs_package_manager_path": "npm",
+    "ruby.rails.projectView.checked": "true",
+    "vue.rearranger.settings.migration": "true"
   }
-}</component>
+}]]></component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\Works\FluidbookToolbox\resources\emailconfig" />
       <recent name="D:\Works\FluidbookToolbox\app\Fields" />
       <recent name="D:\Works\FluidbookToolbox\resources\pdfjs" />
       <recent name="D:\Works\FluidbookToolbox\resources\views\vendor\backpack\crud\buttons" />
       <recent name="D:\Works\FluidbookToolbox\app\Http\Controllers\Admin\Operations" />
-      <recent name="D:\Works\FluidbookToolbox\resources\elearningpackage\js" />
     </key>
     <key name="MoveFile.RECENT_KEYS">
+      <recent name="D:\Works\FluidbookToolbox\resources\emailconfig" />
       <recent name="D:\Works\FluidbookToolbox\resources\elearningpackage" />
       <recent name="D:\Works\FluidbookToolbox\resources\elearningmedia" />
       <recent name="D:\Works\FluidbookToolbox\resources\elearningpackage\sass" />
       <recent name="D:\Works\FluidbookToolbox\resources\elearningpackage\fonts" />
-      <recent name="D:\Works\FluidbookToolbox\resources\pdfjs" />
     </key>
   </component>
   <component name="RunManager">
       <workItem from="1651587683461" duration="1063000" />
       <workItem from="1651655455708" duration="641000" />
       <workItem from="1651746630722" duration="1339000" />
-      <workItem from="1651753148416" duration="6255000" />
-    </task>
-    <task id="LOCAL-00225" summary="wip #5045 @0.5">
-      <created>1643389174195</created>
-      <option name="number" value="00225" />
-      <option name="presentableId" value="LOCAL-00225" />
-      <option name="project" value="LOCAL" />
-      <updated>1643389174195</updated>
+      <workItem from="1651753148416" duration="9398000" />
+      <workItem from="1652080290830" duration="3185000" />
+      <workItem from="1652177641382" duration="4133000" />
+      <workItem from="1652252396495" duration="6124000" />
     </task>
     <task id="LOCAL-00226" summary="wip #5045">
       <created>1643389205286</created>
       <option name="project" value="LOCAL" />
       <updated>1651655495699</updated>
     </task>
-    <option name="localTasksCounter" value="274" />
+    <task id="LOCAL-00274" summary="wip #5228 @1.5">
+      <created>1651760135587</created>
+      <option name="number" value="00274" />
+      <option name="presentableId" value="LOCAL-00274" />
+      <option name="project" value="LOCAL" />
+      <updated>1651760135587</updated>
+    </task>
+    <option name="localTasksCounter" value="275" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
     <option name="CHECK_NEW_TODO" value="false" />
     <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
-    <MESSAGE value="wip #5041 @1" />
     <MESSAGE value="wip #5093 @2" />
     <MESSAGE value="wip #5093 @0.25" />
     <MESSAGE value="wip #5093 @3" />
     <MESSAGE value="wip #5265 @2" />
     <MESSAGE value="wip #5265 @1" />
     <MESSAGE value="wip #5265 @0.5" />
-    <option name="LAST_COMMIT_MESSAGE" value="wip #5265 @0.5" />
+    <MESSAGE value="wip #5228 @1.5" />
+    <option name="LAST_COMMIT_MESSAGE" value="wip #5228 @1.5" />
   </component>
   <component name="XSLT-Support.FileAssociations.UIState">
     <expand />
index c511673236a06e5bb5f44cfbecf3451d735c4ad3..4af4f1eb14be1d2f5a9ad9451d8465d0da0223e3 100644 (file)
@@ -4,10 +4,8 @@ namespace App\Models;
 
 use Cubist\Backpack\Magic\Fields\Code;
 use Cubist\Backpack\Magic\Fields\Table;
-use Cubist\Backpack\Magic\Fields\Textarea;
 use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
 use Cubist\Net\Util;
-use Cubist\Util\Crypt;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Str;
 
@@ -28,8 +26,10 @@ class CubedesignersEmails extends CubistMagicAbstractModel
         $this->addField('domains', Table::class, __('Domaines'), ['entity_singular' => __('un domaine'), 'columns' => ['domaine' => __('Domaine')], 'translatable' => false, 'tab' => __('Comptes et redirections')]);
         $this->addField('mailboxes', Table::class, __('Boîtes mail'), ['entity_singular' => __('une boîte mail'), 'columns' => ['mailbox' => __('E-mail'), 'password' => __('Mot de passe')], 'translatable' => false, 'hint' => __('Laisser le mot de passe vide pour utiliser celui du compte "Toolbox"'), 'tab' => __('Comptes et redirections')]);
         $this->addField('aliases', Table::class, __('Redirections'), ['entity_singular' => __('une redirection'), 'columns' => ['from' => __('Alias'), 'dest' => __('Destinations')], 'translatable' => false, 'tab' => __('Comptes et redirections')]);
-        $this->addField('ip_whitelist', Table::class, __('Liste blanche IP'), ['tab' => __('Paramètres avancés'), 'entity_singular' => __('une IP'), 'columns' => ['ip' => __('IP ou nom d\'hôte')], 'translatable' => false,]);
-        $this->addField('postgrey_whitelist', Code::class, __('Liste blanche postgrey'), ['translatable' => false, 'tab' => __('Paramètres avancés'), 'language' => 'properties']);
+        $this->addField('ip_whitelist', Table::class, __('Liste blanche IP'), ['tab' => __('Listes blanches et noires'), 'entity_singular' => __('une IP'), 'columns' => ['ip' => __('IP ou nom d\'hôte')], 'translatable' => false, 'hint' => __('IP qui sont sur la liste blanche (fail2ban, my_networks)')]);
+        $this->addField('postgrey_whitelist', Code::class, __('Liste blanche postgrey'), ['translatable' => false, 'tab' => __('Listes blanches et noires'), 'language' => 'properties', 'hint' => __('Serveurs ignorés par le Grey listing')]);
+        $this->addField('spam_whitelist', Table::class, __('Liste blanche SPAM'), ['tab' => __('Listes blanches et noires'), 'entity_singular' => __('un e-mail'), 'columns' => ['email' => __('E-mail')], 'translatable' => false, 'hint' => __('Les e-mails provenant de ces expéditeurs ne sont jamais considérés comme des spam (expressions régulières possibles)')]);
+        $this->addField('spam_blacklist', Table::class, __('Liste noire SPAM'), ['tab' => __('Listes blanches et noires'), 'entity_singular' => __('un e-mail'), 'columns' => ['email' => __('E-mail')], 'translatable' => false, 'hint' => __('Ces e-mails sont toujours considérés comme des spam (expressions régulières possibles)')]);
 
     }
 
@@ -42,12 +42,26 @@ class CubedesignersEmails extends CubistMagicAbstractModel
         $domains = json_decode($this->domains, true);
         $a = json_decode($this->aliases, true);
         $ip = json_decode($this->ip_whitelist, true);
+        $spam_whitelist = json_decode($this->spam_whitelist, true);
+        $spam_blacklist = json_decode($this->spam_blacklist, true);
+
+        $spam_bl = [];
+        foreach ($spam_blacklist as $item) {
+            $spam_bl[] = 'blacklist_from ' . $item['email'];
+        }
+        $spam_wl = [];
+        foreach ($spam_whitelist as $item) {
+            $spam_wl[] = 'whitelist_from ' . $item['email'];
+        }
 
         $accounts = [];
+        $_mailboxes = [];
         foreach ($mailboxes as $k => $m) {
             if (!isset($m['password'])) {
                 $m['password'] = '';
             }
+            $_mailboxes[] = $m['mailbox'];
+
             $email = $m['mailbox'] . '@' . $maindomain;
             $password = $m['password'] = trim($m['password']);
             if ($m['password'] === '') {
@@ -90,6 +104,9 @@ class CubedesignersEmails extends CubistMagicAbstractModel
                 $aliases[$from] = [];
             }
             $aliases[$from] = array_merge($aliases[$from], explode(',', str_replace('@' . $maindomain, '', $item['dest'])));
+            if (in_array($from, $_mailboxes)) {
+                $aliases[$from][] = $from . '@' . $maindomain;
+            }
         }
         ksort($aliases);
         $savedAliases = [];
@@ -127,6 +144,7 @@ class CubedesignersEmails extends CubistMagicAbstractModel
                     $domaineDest[] = $d . '@' . $maindomain;
                 }
             }
+            $domaineDest = array_unique($domaineDest);
             $aliasesFile[] = $from . ' ' . implode(',', $domaineDest);
         }
 
@@ -147,6 +165,7 @@ class CubedesignersEmails extends CubistMagicAbstractModel
 
         $this->_replaceInFile('postfix-main.cf', ['my_networks' => implode(', ', $my_networks)]);
         $this->_replaceInFile('fail2ban-jail.cf', ['ignoreip' => implode(',', $my_networks)]);
+        $this->_replaceInFile('spamassassin-rules.cf', ['spam_whitelist' => implode("\n", $spam_wl), 'spam_blacklist' => implode("\n", $spam_bl)]);
 
         touch(storage_path('emailconfig/__UPDATED__'));
     }
index 04886302e5ef66dbf939ce25316fefd09ca750c1..10cf0f901284e14c2b529d557bb28ac0778134b8 100644 (file)
@@ -36,7 +36,7 @@
         "mxl/laravel-job": "^1.3",
         "php-ffmpeg/php-ffmpeg": "^0.18.0",
         "phpoffice/phpspreadsheet": "^1.22",
-        "rustici-software/scormcloud-api-v2-client-php": "^2.0",
+        "rustici-software/scormcloud-api-v2-client-php": "^2.0"
 
     },
     "require-dev": {
index 334838426126150cb4ce109050756e47b1e68cfe..942308b26598f48e192b769965e0eb8319b26232 100644 (file)
@@ -1,5 +1,6 @@
-smtp_bind_address=54.37.95.146
+smtp_bind_address = 54.37.95.146
 enable_original_recipient = yes
+prepend_delivered_header = command, file, forward
 my_networks = $my_networks
 smtpd_recipient_restrictions = check_recipient_access pcre:/etc/postfix/recipient_access.pcre
 
diff --git a/resources/emailconfig/spamassassin-rules.cf b/resources/emailconfig/spamassassin-rules.cf
new file mode 100644 (file)
index 0000000..ca65156
--- /dev/null
@@ -0,0 +1,107 @@
+dns_available yes
+
+# BAYES Filter
+
+use_bayes 1
+use_bayes_rules 1
+bayes_auto_learn 0
+
+score BAYES_00          -4.0
+score BAYES_10          -3.0
+score BAYES_20          -2.0
+score BAYES_30          -1.0
+score BAYES_40          0.001
+score BAYES_50          1.0
+score BAYES_60          3.1
+score BAYES_80          4.1
+score BAYES_95          5.1
+score BAYES_99          5.5
+score BAYES_999         5.6
+
+# TXRep
+
+loadplugin Mail::SpamAssassin::Plugin::TxRep
+ifplugin Mail::SpamAssassin::Plugin::TxRep
+use_txrep 1
+txrep_autolearn 0
+endif
+
+score PYZOR_CHECK       4.5
+
+score SUBJ_ILLEGAL_CHARS      0
+
+loadplugin Mail::SpamAssassin::Plugin::TextCat
+ifplugin Mail::SpamAssassin::Plugin::TextCat
+ok_locales en
+ok_languages en es fr de sv it pt
+score UNWANTED_LANGUAGE_BODY   1.25
+score CHARSET_FARAWAY          1.25
+endif
+
+$spam_whitelist
+
+$spam_blacklist
+
+# These are SpamAssassin rules aimed at detecting messages in Russian.
+# They are intended for users outside Russia who want to block any mail
+# in Russian.
+# Author: Alan Makoev sa-russian@yandex.ru. Feedback is welcome.
+
+# After you have tested this ruleset for absence of FPs - make sure to
+# increase scores.
+
+# IANA states (http://www.iana.org/assignments/character-sets) that csKOI8R
+#is a valid alias for KOI8-R, though I have never seen it in message headers.
+header __HDR_FROM_CYR From:raw =~ /=\?((((cs)?)koi8(-?)r)|(windows-1251))\?/i
+header __HDR_TO_CYR ToCc:raw =~ /=\?((((cs)?)koi8(-?)r)|(windows-1251))\?/i
+header __HDR_SUBJECT_CYR Subject:raw =~ /=\?((((cs)?)koi8(-?)r)|(windows-1251))\?/i
+
+loadplugin Mail::SpamAssassin::Plugin::MIMEHeader
+ifplugin Mail::SpamAssassin::Plugin::MIMEHeader
+mimeheader __MIME_CONTENT_CYR Content-Type:raw =~ /charset=\"((((cs)?)koi8(-?)r)|(windows-1251))\"/ims
+else
+header __MIME_CONTENT_CYR Content-Type:raw =~ /charset=\"((((cs)?)koi8(-?)r)|(windows-1251))\"/i
+endif
+
+meta HDR_CYR __HDR_FROM_CYR || __HDR_TO_CYR || __HDR_SUBJECT_CYR || __MIME_CONTENT_CYR
+score HDR_CYR 1.25
+
+header __HDR_FROM_CYR_UTF8_CHARSET_DEFINITION From:raw =~ /=\?utf-8\?/i
+header __HDR_TO_CYR_UTF8_CHARSET_DEFINITION To:raw =~ /=\?utf-8\?/i
+header __HDR_FROM_CYR_UTF8_CONTENT From =~ /(((\xD0[\x81\x90-\xBF])|(\xD1[\x80-\x8F\x91]))([A-Za-z[:digit:][:blank:][:punct:]])?){3}/
+header __HDR_TO_CYR_UTF8_CONTENT To =~ /(((\xD0[\x81\x90-\xBF])|(\xD1[\x80-\x8F\x91]))([A-Za-z[:digit:][:blank:][:punct:]])?){3}/
+meta __HDR_FROM_CYR_UTF8 __HDR_FROM_CYR_UTF8_CHARSET_DEFINITION && __HDR_FROM_CYR_UTF8_CONTENT
+meta __HDR_TO_CYR_UTF8 __HDR_TO_CYR_UTF8_CHARSET_DEFINITION && __HDR_TO_CYR_UTF8_CONTENT
+meta HDR_ADDR_CYR_UTF8 __HDR_FROM_CYR_UTF8 || __HDR_TO_CYR_UTF8
+score HDR_ADDR_CYR_UTF8 1.25
+
+header __HRD_SENDER_RU From:addr =~ /@((([a-zA-Z0-9])|\.|\-)+)\.ru(\.?)$/i
+header __HRD_RECIPIENT_RU From:addr =~ /@((([a-zA-Z0-9])|\.|\-)+)\.ru(\.?)$/i
+header __HDR_ENVFROM_RU EnvelopeFrom:addr =~ /@((([a-zA-Z0-9])|\.|\-)+)\.ru(\.?)$/i
+header __HDR_RCVD_RU Received:raw =~ /from([[:blank:]]+((([a-zA-Z0-9])|\.|\-)+)\.ru(\.?)[[:blank:]])/i
+meta HDR_CCTLD_RU __HRD_SENDER_RU || __HRD_RECIPIENT_RU || __HDR_ENVFROM_RU || __HDR_RCVD_RU
+score HDR_CCTLD_RU 1.25
+
+uri URI_IN_RU /^(http(s?)\:\/\/)((([a-zA-Z0-9])|\.|\-)+)\.ru(\.?)($|\/)/i
+score URI_IN_RU 1.25
+
+ifplugin Mail::SpamAssassin::Plugin::MIMEHeader
+mimeheader __MIMEPART_NAME_RU Content-Type:raw =~ /name=\"=\?((((cs)?)koi8(-?)r)|(windows-1251))/ims
+mimeheader __MIME_FILENAME_RU Content-Disposition:raw =~ /filename=\"=\?((((cs)?)koi8(-?)r)|(windows-1251))/ims
+meta MIMEPART_NAME_RU __MIMEPART_NAME_RU || __MIME_FILENAME_RU
+score MIMEPART_NAME_RU 1.25
+endif
+
+# Note, that when examining body of a message, SA adds header to it as the
+# first line, so check header and body charset definitions jointly.
+header __HDR_SUBJ_CYR_UTF8_CHARSET_DEFINITION Subject:raw =~ /=\?utf-8\?/i
+
+ifplugin Mail::SpamAssassin::Plugin::MIMEHeader
+mimeheader __HDR_CONTENTTYPE_CYR_UTF8_CHARSET_DEFINITION Content-Type:raw =~ /text\/(.*)charset=utf-8/i
+else
+header __HDR_CONTENTTYPE_CYR_UTF8_CHARSET_DEFINITION Content-Type:raw =~ /text\/(.*)charset=utf-8/i
+endif
+meta __CONTENT_CYR_UTF8_CHARSET_DEFINITION __HDR_SUBJ_CYR_UTF8_CHARSET_DEFINITION || __HDR_CONTENTTYPE_CYR_UTF8_CHARSET_DEFINITION
+body __CONTENT_CYR_UTF8 /(((\xD0[\x81\x90-\xBF])|(\xD1[\x80-\x8F\x91]))([A-Za-z[:digit:][:blank:][:punct:]])?){3}/
+meta CONTENT_CYR_UTF8 __CONTENT_CYR_UTF8_CHARSET_DEFINITION && __CONTENT_CYR_UTF8
+score CONTENT_CYR_UTF8 1.25