File: freemail.t

package info (click to toggle)
spamassassin 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,988 kB
  • sloc: perl: 88,863; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (139 lines) | stat: -rwxr-xr-x 3,899 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -T

use lib '.'; use lib 't';
use SATest; sa_t_init("freemail");

use Test::More;

plan tests => 23;

# ---------------------------------------------------------------------------

# Global
tstprefs ("
  freemail_domains gmail.com
");

## Standard + whitelist should not hit

tstlocalrules (q{
  freemail_import_whitelist_auth 0
  whitelist_auth test@gmail.com
  header FREEMAIL_FROM eval:check_freemail_from()
  score FREEMAIL_FROM 3.3
  header FREEMAIL_REPLYXX eval:check_freemail_replyto('reply')
  score FREEMAIL_REPLYXX 3.3
  header FREEMAIL_REPLYTO eval:check_freemail_replyto('replyto')
  score FREEMAIL_REPLYTO 3.3
  header FREEMAIL_REPLYXX eval:check_freemail_replyto('reply')
  score FREEMAIL_REPLYXX 3.3
  header FREEMAIL_ENVFROM_END_DIGIT  eval:check_freemail_header('EnvelopeFrom', '\d@')
  score FREEMAIL_ENVFROM_END_DIGIT 3.3
  header FREEMAIL_REPLYTO_END_DIGIT  eval:check_freemail_header('Reply-To', '\d@')
  score FREEMAIL_REPLYTO_END_DIGIT 3.3
  header FREEMAIL_HDR_REPLYTO eval:check_freemail_header('Reply-To')
  score FREEMAIL_HDR_REPLYTO 3.3
});

%patterns = (
  q{ 3.3 FREEMAIL_FROM }, '',
);
%anti_patterns = (
  # No Reply-To or body
  q{ FREEMAIL_REPLYTO }, '',
  q{ FREEMAIL_REPLYXX }, '',
  q{ FREEMAIL_ENVFROM_END_DIGIT }, '',
  q{ FREEMAIL_REPLYTO_END_DIGIT }, '',
  q{ FREEMAIL_HDR_REPLYTO }, '',
);

ok sarun ("-L -t < data/spam/relayUS.eml", \&patterns_run_cb);
ok_all_patterns();
clear_pattern_counters();

## Now test with freemail_import_whitelist_auth, should not hit

%patterns = ();
%anti_patterns = (
  q{ FREEMAIL_FROM }, '',
);

tstlocalrules (q{
  freemail_import_whitelist_auth 1
  whitelist_auth test@gmail.com
  header FREEMAIL_FROM eval:check_freemail_from()
  score FREEMAIL_FROM 3.3
});

ok sarun ("-L -t < data/spam/relayUS.eml", \&patterns_run_cb);
ok_all_patterns();

## From and Reply-To different

%patterns = (
  q{ 3.3 FREEMAIL_FROM }, '',
  q{ 3.3 FREEMAIL_REPLYTO }, '',
  q{ 3.3 FREEMAIL_REPLYXX }, '',
  q{ 3.3 FREEMAIL_ENVFROM_END_DIGIT }, '',
  q{ 3.3 FREEMAIL_REPLYTO_END_DIGIT }, '',
  q{ 3.3 FREEMAIL_HDR_REPLYTO }, '',
);
%anti_patterns = ();

tstlocalrules (q{
  header FREEMAIL_FROM eval:check_freemail_from()
  score FREEMAIL_FROM 3.3
  header FREEMAIL_REPLYTO eval:check_freemail_replyto('replyto')
  score FREEMAIL_REPLYTO 3.3
  header FREEMAIL_REPLYXX eval:check_freemail_replyto('reply')
  score FREEMAIL_REPLYXX 3.3
  header FREEMAIL_ENVFROM_END_DIGIT  eval:check_freemail_header('EnvelopeFrom', '\d@')
  score FREEMAIL_ENVFROM_END_DIGIT 3.3
  header FREEMAIL_REPLYTO_END_DIGIT  eval:check_freemail_header('Reply-To', '\d@')
  score FREEMAIL_REPLYTO_END_DIGIT 3.3
  header FREEMAIL_HDR_REPLYTO eval:check_freemail_header('Reply-To')
  score FREEMAIL_HDR_REPLYTO 3.3
});

ok sarun ("-L -t < data/spam/freemail1", \&patterns_run_cb);
ok_all_patterns();

## Multiple Reply-To values, no email on body

%patterns = (
  q{ 3.3 FREEMAIL_REPLYTO }, '',
  q{ 3.3 FREEMAIL_REPLYXX }, '',
  q{ 3.3 FREEMAIL_REPLYTO_END_DIGIT }, '',
  q{ 3.3 FREEMAIL_HDR_REPLYTO }, '',
);
%anti_patterns = ();

tstlocalrules (q{
  header FREEMAIL_REPLYTO eval:check_freemail_replyto('replyto')
  score FREEMAIL_REPLYTO 3.3
  header FREEMAIL_REPLYXX eval:check_freemail_replyto('reply')
  score FREEMAIL_REPLYXX 3.3
  header FREEMAIL_REPLYTO_END_DIGIT  eval:check_freemail_header('Reply-To', '\d@')
  score FREEMAIL_REPLYTO_END_DIGIT 3.3
  header FREEMAIL_HDR_REPLYTO eval:check_freemail_header('Reply-To')
  score FREEMAIL_HDR_REPLYTO 3.3
});

ok sarun ("-L -t < data/spam/freemail2", \&patterns_run_cb);
ok_all_patterns();

## No Reply-To, another freemail in body

%patterns = (
  q{ 3.3 FREEMAIL_REPLYXX }, '',
);
%anti_patterns = ();

tstlocalrules (q{
  header FREEMAIL_REPLYXX eval:check_freemail_replyto('reply')
  score FREEMAIL_REPLYXX 3.3
});

ok sarun ("-L -t < data/spam/freemail3", \&patterns_run_cb);
ok_all_patterns();