]> git.proxmox.com Git - proxmox-spamassassin.git/blame - sa-updates/20_html_tests.cf
update SpamAssassin signatures
[proxmox-spamassassin.git] / sa-updates / 20_html_tests.cf
CommitLineData
b780ea8d
SI
1# SpamAssassin rules file: HTML tests
2#
3# Please don't modify this file as your changes will be overwritten with
4# the next update. Use /etc/mail/spamassassin/local.cf instead.
5# See 'perldoc Mail::SpamAssassin::Conf' for details.
6#
7# <@LICENSE>
8# Licensed to the Apache Software Foundation (ASF) under one or more
9# contributor license agreements. See the NOTICE file distributed with
10# this work for additional information regarding copyright ownership.
11# The ASF licenses this file to you under the Apache License, Version 2.0
12# (the "License"); you may not use this file except in compliance with
13# the License. You may obtain a copy of the License at:
14#
15# http://www.apache.org/licenses/LICENSE-2.0
16#
17# Unless required by applicable law or agreed to in writing, software
18# distributed under the License is distributed on an "AS IS" BASIS,
19# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20# See the License for the specific language governing permissions and
21# limitations under the License.
22# </@LICENSE>
23#
24###########################################################################
25
26require_version 3.004005
27
28# HTML parser tests
29#
30# please sort these by eval type then name
31
32meta HTML_SHORT_LINK_IMG_1 __HTML_LENGTH_0000_1024 && __HTML_LINK_IMAGE
33meta HTML_SHORT_LINK_IMG_2 __HTML_LENGTH_1024_1536 && __HTML_LINK_IMAGE
34meta HTML_SHORT_LINK_IMG_3 __HTML_LENGTH_1536_2048 && __HTML_LINK_IMAGE
35describe HTML_SHORT_LINK_IMG_1 HTML is very short with a linked image
36describe HTML_SHORT_LINK_IMG_2 HTML is very short with a linked image
37describe HTML_SHORT_LINK_IMG_3 HTML is very short with a linked image
38
39
40meta HTML_SHORT_CENTER (__HTML_LENGTH_384 && __TAG_EXISTS_CENTER)
41describe HTML_SHORT_CENTER HTML is very short with CENTER tag
42
43
44meta HTML_TITLE_SUBJ_DIFF __HTML_TITLE_SUBJ_DIFF && !__MIME_ATTACHMENT
45
46meta HTML_CHARSET_FARAWAY (__HTML_CHARSET_FARAWAY && __HIGHBITS)
47describe HTML_CHARSET_FARAWAY A foreign language charset used in HTML markup
48tflags HTML_CHARSET_FARAWAY userconf
49
50meta HTML_MIME_NO_HTML_TAG MIME_HTML_ONLY && !__TAG_EXISTS_HTML
51describe HTML_MIME_NO_HTML_TAG HTML-only message, but there is no HTML tag
52
53meta HTML_MISSING_CTYPE (!__MIME_HTML && HTML_MESSAGE)
54describe HTML_MISSING_CTYPE Message is HTML without HTML Content-Type
55
56###########################################################################
57# rawbody HTML tests
58
59rawbody HIDE_WIN_STATUS /<[^>]{1,1000}onMouseOver=[^>]{1,1000}window\.status=/i
60describe HIDE_WIN_STATUS Javascript to hide URLs in browser
61
62rawbody __OBFUSCATING_COMMENT_A /\w(?:<![^>]*>)+\w/
63rawbody __OBFUSCATING_COMMENT_B /[^\s>](?:<![^>]*>)+[^\s<]/
64ifplugin Mail::SpamAssassin::Plugin::HTMLEval
65ifplugin Mail::SpamAssassin::Plugin::MIMEEval
66meta OBFUSCATING_COMMENT ((__OBFUSCATING_COMMENT_A && HTML_MESSAGE) || (__OBFUSCATING_COMMENT_B && MIME_HTML_ONLY)) && !__ISO_2022_JP_DELIM
67describe OBFUSCATING_COMMENT HTML comments which obfuscate text
68endif
69endif
70
71# spams that are assembled from a Javascript array
72# look for the XOR op
73rawbody __JS_FROMCHARCODE /String\.fromCharCode\s*\(\s*\S+\s*\[\s*\S+\s*\]\s*\^/
74rawbody __JS_DOCWRITE /document\.write/
75meta JS_FROMCHARCODE (__JS_FROMCHARCODE && __JS_DOCWRITE)
76describe JS_FROMCHARCODE Document is built from a Javascript charcode array
77
78# a good possible rule that may resurface
79# ! $ % ' ( ) , - . / : ; = ? @ _
80#rawbody ENTITY_DEC_OTHER /\&\#0*(?:3[3679]|4[014567]|5[89]|6[134]|95)\;/
81#describe ENTITY_DEC_OTHER HTML contains needlessly encoded punctuation
82
83body __HIGHBITS /(?:[\x80-\xff].?){4}/
84# note: __HIGHBITS is used by HTML_CHARSET_FARAWAY
85
86###########################################################################
87
88ifplugin Mail::SpamAssassin::Plugin::HTMLEval
89
90# HTML control test, HTML spam rules should all have better S/O than this
91body HTML_MESSAGE eval:html_test('html')
92describe HTML_MESSAGE HTML included in message
93
94# HTML comment tests
95body HTML_COMMENT_SHORT eval:html_text_match('comment', '<!(?!-).{0,6}>')
96describe HTML_COMMENT_SHORT HTML comment is very short
97
98body HTML_COMMENT_SAVED_URL eval:html_text_match('comment', '<!-- saved from url=\(\d{4}\)')
99describe HTML_COMMENT_SAVED_URL HTML message is a saved web page
100
101body HTML_EMBEDS eval:html_test('embeds')
102describe HTML_EMBEDS HTML with embedded plugin object
103
104
105body HTML_EXTRA_CLOSE eval:html_range('closed_extra_ratio', '0.09', 'inf')
106describe HTML_EXTRA_CLOSE HTML contains far too many close tags
107
108
109
110body HTML_FONT_SIZE_LARGE eval:html_range('max_size', '5', '6')
111describe HTML_FONT_SIZE_LARGE HTML font size is large
112
113body HTML_FONT_SIZE_HUGE eval:html_range('max_size', '6', 'inf')
114describe HTML_FONT_SIZE_HUGE HTML font size is huge
115
116
117
118
119body HTML_FONT_LOW_CONTRAST eval:html_test('font_low_contrast')
120describe HTML_FONT_LOW_CONTRAST HTML font color similar or identical to background
121
122body HTML_FONT_FACE_BAD eval:html_test('font_face_bad')
123describe HTML_FONT_FACE_BAD HTML font face is not a word
124
125
126body HTML_FORMACTION_MAILTO eval:html_test('form_action_mailto')
127describe HTML_FORMACTION_MAILTO HTML includes a form which sends mail
128
129# HTML_IMAGE_ONLY - not much raw HTML with images (absolute)
130body HTML_IMAGE_ONLY_04 eval:html_image_only('0000','0400')
131body HTML_IMAGE_ONLY_08 eval:html_image_only('0400','0800')
132body HTML_IMAGE_ONLY_12 eval:html_image_only('0800','1200')
133body HTML_IMAGE_ONLY_16 eval:html_image_only('1200','1600')
134body HTML_IMAGE_ONLY_20 eval:html_image_only('1600','2000')
135body HTML_IMAGE_ONLY_24 eval:html_image_only('2000','2400')
136body HTML_IMAGE_ONLY_28 eval:html_image_only('2400','2800')
137body HTML_IMAGE_ONLY_32 eval:html_image_only('2800','3200')
138describe HTML_IMAGE_ONLY_04 HTML: images with 0-400 bytes of words
139describe HTML_IMAGE_ONLY_08 HTML: images with 400-800 bytes of words
140describe HTML_IMAGE_ONLY_12 HTML: images with 800-1200 bytes of words
141describe HTML_IMAGE_ONLY_16 HTML: images with 1200-1600 bytes of words
142describe HTML_IMAGE_ONLY_20 HTML: images with 1600-2000 bytes of words
143describe HTML_IMAGE_ONLY_24 HTML: images with 2000-2400 bytes of words
144describe HTML_IMAGE_ONLY_28 HTML: images with 2400-2800 bytes of words
145describe HTML_IMAGE_ONLY_32 HTML: images with 2800-3200 bytes of words
146
147# HTML_IMAGE_RATIO - more image area than text (ratio)
148body HTML_IMAGE_RATIO_02 eval:html_image_ratio('0.000','0.002')
149body HTML_IMAGE_RATIO_04 eval:html_image_ratio('0.002','0.004')
150body HTML_IMAGE_RATIO_06 eval:html_image_ratio('0.004','0.006')
151body HTML_IMAGE_RATIO_08 eval:html_image_ratio('0.006','0.008')
152describe HTML_IMAGE_RATIO_02 HTML has a low ratio of text to image area
153describe HTML_IMAGE_RATIO_04 HTML has a low ratio of text to image area
154describe HTML_IMAGE_RATIO_06 HTML has a low ratio of text to image area
155describe HTML_IMAGE_RATIO_08 HTML has a low ratio of text to image area
156
157# HTML obfuscation
158body HTML_OBFUSCATE_05_10 eval:html_range('obfuscation_ratio','.05','.1')
159body HTML_OBFUSCATE_10_20 eval:html_range('obfuscation_ratio','.1','.2')
160body HTML_OBFUSCATE_20_30 eval:html_range('obfuscation_ratio','.2','.3')
161body HTML_OBFUSCATE_30_40 eval:html_range('obfuscation_ratio','.3','.4')
162body HTML_OBFUSCATE_50_60 eval:html_range('obfuscation_ratio','.5','.6')
163body HTML_OBFUSCATE_70_80 eval:html_range('obfuscation_ratio','.7','.8')
164body HTML_OBFUSCATE_90_100 eval:html_range('obfuscation_ratio','.9','1.0')
165describe HTML_OBFUSCATE_05_10 Message is 5% to 10% HTML obfuscation
166describe HTML_OBFUSCATE_10_20 Message is 10% to 20% HTML obfuscation
167describe HTML_OBFUSCATE_20_30 Message is 20% to 30% HTML obfuscation
168describe HTML_OBFUSCATE_30_40 Message is 30% to 40% HTML obfuscation
169describe HTML_OBFUSCATE_50_60 Message is 50% to 60% HTML obfuscation
170describe HTML_OBFUSCATE_70_80 Message is 70% to 80% HTML obfuscation
171describe HTML_OBFUSCATE_90_100 Message is 90% to 100% HTML obfuscation
172
173body HTML_TAG_BALANCE_BODY eval:html_tag_balance('body', '!= 0')
174describe HTML_TAG_BALANCE_BODY HTML has unbalanced "body" tags
175
176body HTML_TAG_BALANCE_HEAD eval:html_tag_balance('head', '!= 0')
177describe HTML_TAG_BALANCE_HEAD HTML has unbalanced "head" tags
178
179body HTML_TAG_EXIST_BGSOUND eval:html_tag_exists('bgsound')
180describe HTML_TAG_EXIST_BGSOUND HTML has "bgsound" tag
181
182# percentage of tags that are not legal elements in HTML
183body HTML_BADTAG_40_50 eval:html_range('bad_tag_ratio','0.40','0.50')
184body HTML_BADTAG_50_60 eval:html_range('bad_tag_ratio','0.50','0.60')
185body HTML_BADTAG_60_70 eval:html_range('bad_tag_ratio','0.60','0.70')
186body HTML_BADTAG_90_100 eval:html_range('bad_tag_ratio','0.90','1.00')
187describe HTML_BADTAG_40_50 HTML message is 40% to 50% bad tags
188describe HTML_BADTAG_50_60 HTML message is 50% to 60% bad tags
189describe HTML_BADTAG_60_70 HTML message is 60% to 70% bad tags
190describe HTML_BADTAG_90_100 HTML message is 90% to 100% bad tags
191
192# percentage of unique non-elements in HTML
193body HTML_NONELEMENT_30_40 eval:html_range('non_element_ratio','0.30','0.40')
194body HTML_NONELEMENT_40_50 eval:html_range('non_element_ratio','0.40','0.50')
195body HTML_NONELEMENT_60_70 eval:html_range('non_element_ratio','0.60','0.70')
196body HTML_NONELEMENT_80_90 eval:html_range('non_element_ratio','0.80','0.90')
197describe HTML_NONELEMENT_30_40 30% to 40% of HTML elements are non-standard
198describe HTML_NONELEMENT_40_50 40% to 50% of HTML elements are non-standard
199describe HTML_NONELEMENT_60_70 60% to 70% of HTML elements are non-standard
200describe HTML_NONELEMENT_80_90 80% to 90% of HTML elements are non-standard
201
202# short HTML messages with certain attributes
203body __HTML_LINK_IMAGE eval:html_text_match('anchor', '<img>')
204body __HTML_LENGTH_0000_1024 eval:html_range('length', '0', '1024')
205body __HTML_LENGTH_1024_1536 eval:html_range('length', '1024', '1536')
206body __HTML_LENGTH_1536_2048 eval:html_range('length', '1536', '2048')
207
208body __HTML_LENGTH_512 eval:html_eval('length', '< 512')
209body __COMMENT_EXISTS eval:html_text_match('comment', '<!.*?>')
210
211body __HTML_LENGTH_384 eval:html_eval('length', '< 384')
212body __TAG_EXISTS_CENTER eval:html_tag_exists('center')
213
214body __HTML_TITLE_120 eval:html_text_match('title', '.{120}')
215
216body __HTML_TITLE_SUBJ_DIFF eval:html_title_subject_ratio('3.5')
217
218
219body __HTML_CHARSET_FARAWAY eval:html_charset_faraway()
220
221body HTML_IFRAME_SRC eval:check_iframe_src()
222describe HTML_IFRAME_SRC Message has HTML IFRAME tag with SRC URI
223
224else
225
226meta __COMMENT_EXISTS 0
227meta __TAG_EXISTS_CENTER 0
228
229endif
230
231###########################################################################
232
233ifplugin Mail::SpamAssassin::Plugin::MIMEEval
234
235# __MIME_ATTACHMENT also used in 20_meta_tests.cf
236body __MIME_ATTACHMENT eval:check_for_mime('mime_attachment')
237
238endif