]> git.proxmox.com Git - pmg-api.git/commitdiff
DBTools: add new default rule/objects for attachment quarantine
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 10 Oct 2019 09:22:00 +0000 (11:22 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Oct 2019 13:59:32 +0000 (15:59 +0200)
the new rule is disabled by default

also adapt the ruledb test for default rules

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/DBTools.pm
src/tests/testdb.txt

index c675e2f055e39b28299fa8cb1f91421bd60de919..66dfc289061f0a7883d637d857882568b6be2650 100644 (file)
@@ -711,6 +711,16 @@ sub init_ruledb {
     my $add_discl = $ruledb->create_group_with_obj(
        $obj, 'Disclaimer', 'Add Disclaimer');
 
+    # Move to attachment quarantine
+    $obj = PMG::RuleDB::Remove->new(0, undef, undef, 1);
+    my $attach_quar = $ruledb->create_group_with_obj(
+       $obj, 'Attachment Quarantine (remove matching)', 'Remove matching attachments and move the whole mail to the attachment quarantine.');
+
+    # Remove all attachments
+    $obj = PMG::RuleDB::Remove->new(1, undef, undef, 1);
+    my $attach_quar_all = $ruledb->create_group_with_obj(
+       $obj, 'Attachment Quarantine (remove all)', 'Remove all attachments and move the whole mail to the attachment quarantine.');
+
     # Attach original mail
     #$obj = Proxmox::RuleDB::Attach->new ();
     #my $attach_orig = $ruledb->create_group_with_obj ($obj, 'Attach Original Mail',
@@ -822,6 +832,13 @@ sub init_ruledb {
     $ruledb->rule_add_what_group ($rule, $mm_content);
     $ruledb->rule_add_action ($rule, $remove);
 
+    # Quarantine Office Files
+    $rule = PMG::RuleDB::Rule->new ('Quarantine Office Files', 89, 0, 0);
+    $ruledb->save_rule ($rule);
+
+    $ruledb->rule_add_what_group ($rule, $office_content);
+    $ruledb->rule_add_action ($rule, $attach_quar);
+
     #$ruledb->rule_add_from_group ($rule, $anybody);
     #$ruledb->rule_add_from_group ($rule, $trusted);
     #$ruledb->rule_add_to_group ($rule, $anybody);
index c69f4ed8847a8702920f5a80be2dbdcb088ee08e..dc08df8d66e83d63b3b5dee759529dbe4ec2b9f9 100644 (file)
@@ -31,6 +31,17 @@ Found RULE 1: Block Dangerous Files
     OBJECT 21: filename=.*\.\{.+\}
   FOUND ACTION GROUP 14: Remove attachments
     OBJECT 28: remove matching attachments
+Found RULE 12: Quarantine Office Files
+  FOUND WHAT GROUP 6: Office Files
+    OBJECT 9: content-type=application/msword
+    OBJECT 7: content-type=application/vnd\.ms-excel
+    OBJECT 8: content-type=application/vnd\.ms-powerpoint
+    OBJECT 11: content-type=application/vnd\.oasis\.opendocument\..*
+    OBJECT 10: content-type=application/vnd\.openxmlformats-officedocument\..*
+    OBJECT 12: content-type=application/vnd\.stardivision\..*
+    OBJECT 13: content-type=application/vnd\.sun\.xml\..*
+  FOUND ACTION GROUP 22: Attachment Quarantine (remove matching)
+    OBJECT 36: remove matching attachments
 Found RULE 11: Block Multimedia Files
   FOUND WHAT GROUP 5: Multimedia
     OBJECT 5: content-type=audio/.*