[pmg-devel] [PATCH pmg-api v3 09/10] DBTools: add new default rule/objects for attachment quarantine
Dominik Csapak
d.csapak at proxmox.com
Thu Oct 10 11:22:00 CEST 2019
the new rule is disabled by default
also adapt the ruledb test for default rules
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/PMG/DBTools.pm | 17 +++++++++++++++++
src/tests/testdb.txt | 11 +++++++++++
2 files changed, 28 insertions(+)
diff --git a/src/PMG/DBTools.pm b/src/PMG/DBTools.pm
index c675e2f..66dfc28 100644
--- a/src/PMG/DBTools.pm
+++ b/src/PMG/DBTools.pm
@@ -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);
diff --git a/src/tests/testdb.txt b/src/tests/testdb.txt
index c69f4ed..dc08df8 100644
--- a/src/tests/testdb.txt
+++ b/src/tests/testdb.txt
@@ -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/.*
--
2.20.1
More information about the pmg-devel
mailing list