| 1 |
# SA-like rules set to test selector/header/body/rawbody/uri/full/meta |
| 2 |
|
| 3 |
# Header atom |
| 4 |
header SA_HDR_SUBJ Subject =~ /test\s+subject/i |
| 5 |
|
| 6 |
# Body atom |
| 7 |
body SA_BODY_SIMPLE /hello\s+world/i |
| 8 |
|
| 9 |
# Rawbody atom |
| 10 |
rawbody SA_RAW_SIMPLE /RAW\s+TOKEN/i |
| 11 |
|
| 12 |
# URI atom |
| 13 |
uri SA_URI_SHORT /bit\.ly|tinyurl/i |
| 14 |
|
| 15 |
# Full message atom |
| 16 |
full SA_FULL_BOUNDARY /From:.*\n(?:.*\n)*?Subject:/i |
| 17 |
|
| 18 |
# Selector atom: from domain equals example.com |
| 19 |
selector SA_SEL_FROM_DOM from:domain =~ /^example\.com$/i |
| 20 |
|
| 21 |
# Selector atom: specific_urls tld equals example.com |
| 22 |
selector SA_SEL_URL_TLD specific_urls({need_content = true, limit = 10}):get_tld =~ /^example\.com$/i |
| 23 |
|
| 24 |
# Selector negation (use domain to avoid addr formatting quirks) |
| 25 |
selector SA_SEL_NOT_CORP from:domain !~ /^corp\.example$/i |
| 26 |
|
| 27 |
# Meta rules combining atoms and selectors |
| 28 |
meta SA_META_AND SA_HDR_SUBJ & SA_BODY_SIMPLE & SA_SEL_FROM_DOM |
| 29 |
meta SA_META_OR SA_URI_SHORT | SA_SEL_URL_TLD |
| 30 |
meta SA_META_COMPLEX (SA_BODY_SIMPLE & SA_SEL_NOT_CORP) | SA_RAW_SIMPLE |
| 31 |
|
| 32 |
# Scores |
| 33 |
score SA_HDR_SUBJ 1.0 |
| 34 |
score SA_BODY_SIMPLE 1.0 |
| 35 |
score SA_RAW_SIMPLE 1.0 |
| 36 |
score SA_URI_SHORT 1.0 |
| 37 |
score SA_FULL_BOUNDARY 0.5 |
| 38 |
score SA_SEL_FROM_DOM 1.0 |
| 39 |
score SA_SEL_URL_TLD 1.0 |
| 40 |
score SA_SEL_NOT_CORP 0.5 |
| 41 |
score SA_META_AND 2.5 |
| 42 |
score SA_META_OR 2.0 |
| 43 |
score SA_META_COMPLEX 2.0 |
| 44 |
|
| 45 |
# Descriptions |
| 46 |
describe SA_HDR_SUBJ Subject matches test subject |
| 47 |
describe SA_BODY_SIMPLE Body contains hello world |
| 48 |
describe SA_RAW_SIMPLE Raw body contains RAW TOKEN |
| 49 |
describe SA_URI_SHORT Message contains a shortener URL |
| 50 |
describe SA_FULL_BOUNDARY Header boundary present |
| 51 |
describe SA_SEL_FROM_DOM From domain equals example.com |
| 52 |
describe SA_SEL_URL_TLD URL tld equals example.com |
| 53 |
describe SA_SEL_NOT_CORP From address is not corp.example |
| 54 |
describe SA_META_AND Header+Body+Selector combo |
| 55 |
describe SA_META_OR URI or URL TLD selector |
| 56 |
describe SA_META_COMPLEX Complex combination with negation |