-
Notifications
You must be signed in to change notification settings - Fork 70
/
priorities_welcome_block.t
executable file
·175 lines (139 loc) · 5.83 KB
/
priorities_welcome_block.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/perl -T
use lib '.'; use lib 't';
use SATest; sa_t_init("priorities_welcome_block");
use strict;
use Test::More tests => 10;
use Mail::SpamAssassin;
tstlocalrules (q{
body BAYES_99 eval:check_bayes('0.99', '1.00')
tflags BAYES_99 learn
score BAYES_99 0 0 3.5 3.5
if !can(Mail::SpamAssassin::Conf::compat_welcomelist_blocklist)
meta USER_IN_BLACKLIST (USER_IN_BLOCKLIST)
describe USER_IN_BLACKLIST DEPRECATED: See USER_IN_BLOCKLIST
tflags USER_IN_BLACKLIST userconf nice noautolearn
score USER_IN_BLACKLIST 100
score USER_IN_BLOCKLIST 0.01
endif
header USER_IN_WELCOMELIST eval:check_from_in_welcomelist()
describe USER_IN_WELCOMELIST User is listed in 'welcomelist_from'
tflags USER_IN_WELCOMELIST userconf nice noautolearn
score USER_IN_WELCOMELIST -100
if !can(Mail::SpamAssassin::Conf::compat_welcomelist_blocklist)
meta USER_IN_WHITELIST (USER_IN_WELCOMELIST)
describe USER_IN_WHITELIST DEPRECATED: See USER_IN_WELCOMELIST
tflags USER_IN_WHITELIST userconf nice noautolearn
score USER_IN_WHITELIST -100
score USER_IN_WELCOMELIST -0.01
endif
header USER_IN_DEF_WELCOMELIST eval:check_from_in_default_welcomelist()
describe USER_IN_DEF_WELCOMELIST From: user is listed in the default welcome-list
tflags USER_IN_DEF_WELCOMELIST userconf nice noautolearn
score USER_IN_DEF_WELCOMELIST -15
if !can(Mail::SpamAssassin::Conf::compat_welcomelist_blocklist)
meta USER_IN_DEF_WHITELIST (USER_IN_DEF_WELCOMELIST)
describe USER_IN_DEF_WHITELIST DEPRECATED: See USER_IN_WELCOMELIST
tflags USER_IN_DEF_WHITELIST userconf nice noautolearn
score USER_IN_DEF_WHITELIST -15
score USER_IN_DEF_WELCOMELIST -0.01
endif
header USER_IN_BLOCKLIST_TO eval:check_to_in_blocklist()
describe USER_IN_BLOCKLIST_TO User is listed in 'blocklist_to'
tflags USER_IN_BLOCKLIST_TO userconf nice noautolearn
score USER_IN_BLOCKLIST_TO 10
if !can(Mail::SpamAssassin::Conf::compat_welcomelist_blocklist)
meta USER_IN_BLACKLIST_TO (USER_IN_BLOCKLIST_TO)
describe USER_IN_BLACKLIST_TO DEPRECATED: See USER_IN_BLOCKLIST_TO
tflags USER_IN_BLACKLIST_TO userconf nice noautolearn
score USER_IN_BLACKLIST_TO 10
score USER_IN_BLOCKLIST_TO 0.01
endif
header USER_IN_WELCOMELIST_TO eval:check_to_in_welcomelist()
describe USER_IN_WELCOMELIST_TO User is listed in 'welcomelist_to'
tflags USER_IN_WELCOMELIST_TO userconf nice noautolearn
score USER_IN_WELCOMELIST_TO -6
if !can(Mail::SpamAssassin::Conf::compat_welcomelist_blocklist)
meta USER_IN_WHITELIST_TO (USER_IN_WELCOMELIST_TO)
describe USER_IN_WHITELIST_TO DEPRECATED: See USER_IN_WELCOMELIST_TO
tflags USER_IN_WHITELIST_TO userconf nice noautolearn
score USER_IN_WHITELIST_TO -6
score USER_IN_WELCOMELIST_TO -0.01
endif
header USER_IN_ALL_SPAM_TO eval:check_to_in_all_spam()
tflags USER_IN_ALL_SPAM_TO userconf nice noautolearn
priority USER_IN_WELCOMELIST -1000
priority USER_IN_DEF_WELCOMELIST -1000
priority USER_IN_ALL_SPAM_TO -1000
priority SUBJECT_IN_WELCOMELIST -1000
priority ALL_TRUSTED -950
priority SUBJECT_IN_BLOCKLIST -900
priority USER_IN_BLOCKLIST_TO -900
priority USER_IN_BLOCKLIST -900
priority BAYES_99 -400
header XX_RCVD_IN_SORBS_SMTP eval:check_rbl_sub('sorbs', '127.0.0.5')
tflags XX_RCVD_IN_SORBS_SMTP net
score XX_RCVD_IN_SORBS_SMTP 1
meta SC_URIBL_SURBL (URIBL_BLACK && (URIBL_SC_SURBL || URIBL_JP_SURBL || URIBL_OB_SURBL ) && RCVD_IN_SORBS_SMTP)
meta SC_URIBL_HASH ((URIBL_BLACK || URIBL_SC_SURBL || URIBL_JP_SURBL || URIBL_OB_SURBL) && (RAZOR2_CHECK || DCC_CHECK || PYZOR_CHECK))
meta SC_URIBL_SBL ((URIBL_BLACK || URIBL_SC_SURBL || URIBL_JP_SURBL || URIBL_OB_SURBL) && URIBL_SBL)
meta SC_URIBL_BAYES ((URIBL_BLACK || URIBL_SC_SURBL || URIBL_JP_SURBL || URIBL_OB_SURBL) && BAYES_99)
shortcircuit SC_URIBL_SURBL spam
shortcircuit SC_URIBL_HASH spam
shortcircuit SC_URIBL_SBL spam
shortcircuit SC_URIBL_BAYES spam
priority SC_URIBL_SURBL -530
priority SC_URIBL_HASH -510
priority SC_URIBL_SBL -510
priority SC_URIBL_BAYES -510
shortcircuit DIGEST_MULTIPLE spam
priority DIGEST_MULTIPLE -300
meta FOO1 (FOO2 && FOO3)
meta FOO2 (1)
meta FOO3 (FOO4 && FOO5)
meta FOO4 (2)
meta FOO5 (3)
priority FOO5 -23
priority FOO1 -28
});
my $sa = create_saobj({
dont_copy_prefs => 1,
# debug => 1
});
$sa->init(0); # parse rules
ok($sa);
my $conf = $sa->{conf};
sub assert_rule_pri;
ok assert_rule_pri 'USER_IN_WELCOMELIST', -1000;
ok assert_rule_pri 'SC_URIBL_SURBL', -530;
ok assert_rule_pri 'SC_URIBL_HASH', -510;
ok assert_rule_pri 'SC_URIBL_SBL', -510;
ok assert_rule_pri 'SC_URIBL_BAYES', -510;
ok assert_rule_pri 'XX_RCVD_IN_SORBS_SMTP', -530;
# SC_URIBL_BAYES will have overridden its base priority setting
ok assert_rule_pri 'BAYES_99', -510;
ok assert_rule_pri 'FOO5', -28;
ok assert_rule_pri 'FOO1', -28;
# ---------------------------------------------------------------------------
sub assert_rule_pri {
my ($r, $pri) = @_;
if (defined $conf->{rbl_evals}->{$r} || defined $conf->{meta_tests}->{$r}) {
# ignore rbl_evals and metas; they do not use the priority system at all
return 1;
}
foreach my $ruletype (qw(
body_tests head_tests meta_tests uri_tests rawbody_tests full_tests
full_evals rawbody_evals head_evals body_evals
))
{
if (defined $conf->{$ruletype}->{$pri}->{$r}) {
return 1;
}
foreach my $foundpri (keys %{$conf->{priorities}}) {
next unless (defined $conf->{$ruletype}->{$foundpri}->{$r});
warn "FAIL: rule '$r' not found at priority $pri; found at $foundpri\n";
return 0;
}
}
warn "FAIL: no rule '$r' found of any type at any priority\n";
return 0;
}