Debian Codegraph @

test/functional/cases/270_regexp_maps.robot

raw
1 *** Settings ***
2 Suite Setup Rspamd Setup
3 Suite Teardown Rspamd Teardown
4 Library ${RSPAMD_TESTDIR}/lib/rspamd.py
5 Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
6 Variables ${RSPAMD_TESTDIR}/lib/vars.py
7
8 *** Variables ***
9 ${CONFIG} ${RSPAMD_TESTDIR}/configs/regexp_maps.conf
10 ${MESSAGE1} ${RSPAMD_TESTDIR}/messages/advance_fee_fraud.eml
11 ${MESSAGE2} ${RSPAMD_TESTDIR}/messages/sa_header_body_raw.eml
12 ${FULLMSG} ${RSPAMD_TESTDIR}/messages/sa_full_boundary.eml
13 ${URL1} ${RSPAMD_TESTDIR}/messages/url1.eml
14 ${RSPAMD_SCOPE} Suite
15 ${RSPAMD_URL_TLD} ${RSPAMD_TESTDIR}/../lua/unit/test_tld.dat
16
17 *** Test Cases ***
18 Advance Fee Fraud Detection
19 [Documentation] Test that advance fee fraud rules match correctly
20 Scan File ${MESSAGE1}
21 Expect Symbol ADVANCE_FEE_2
22 Expect Symbol ADVANCE_FEE_3
23 # Verify filtered options (no __ atoms, max 5 options)
24 ${symbols} = Get From Dictionary ${SCAN_RESULT}[symbols] ADVANCE_FEE_2
25 ${options} = Get From Dictionary ${symbols} options
26 ${options_count} = Get Length ${options}
27 Should Be True ${options_count} <= 5 msg=Too many options: ${options_count}
28 FOR ${option} IN @{options}
29 Should Not Match Regexp ${option} ^__ msg=Option should not start with __: ${option}
30 END
31
32 Meta Rule Combination
33 [Documentation] Test that meta rules correctly combine atom results
34 Scan File ${MESSAGE1}
35 Expect Symbol With Score ADVANCE_FEE_2 4.0
36 Expect Symbol With Score ADVANCE_FEE_3 5.0
37
38 No False Positives on Ham
39 [Documentation] Test that regexp rules don't trigger on legitimate messages
40 Scan File ${MESSAGE2}
41 Do Not Expect Symbol ADVANCE_FEE_2
42 Do Not Expect Symbol ADVANCE_FEE_3
43
44 Atom Rules Availability
45 [Documentation] Test that individual atom rules are available for combination
46 Scan File ${MESSAGE1}
47 # These should be available internally but not shown as main results
48 # We test by ensuring the meta rules work correctly
49 Expect Symbol ADVANCE_FEE_2
50 Expect Symbol ADVANCE_FEE_3
51
52 SA-Like: Header Atom
53 [Documentation] Header regexp atom works (SA_HDR_SUBJ)
54 Scan File ${MESSAGE2}
55 Expect Symbol SA_HDR_SUBJ
56
57 SA-Like: Body Atom
58 [Documentation] Body regexp atom works (SA_BODY_SIMPLE)
59 Scan File ${MESSAGE2}
60 Expect Symbol SA_BODY_SIMPLE
61
62 SA-Like: Rawbody Atom
63 [Documentation] Rawbody regexp atom works (SA_RAW_SIMPLE)
64 Scan File ${MESSAGE2}
65 Expect Symbol SA_RAW_SIMPLE
66
67 SA-Like: URI Atom
68 [Documentation] URI regexp atom works (SA_URI_SHORT)
69 Scan File ${URL1}
70 Expect Symbol SA_URI_SHORT
71
72 SA-Like: Full Atom
73 [Documentation] Full message regexp atom works (SA_FULL_BOUNDARY)
74 Scan File ${FULLMSG}
75 Expect Symbol SA_FULL_BOUNDARY
76
77 SA-Like: Selector From Domain
78 [Documentation] Selector-based atom (from:domain) works (SA_SEL_FROM_DOM)
79 Scan File ${MESSAGE2}
80 Expect Symbol SA_SEL_FROM_DOM
81
82 SA-Like: Selector URL TLD
83 [Documentation] Selector-based atom (specific_urls:tld) works (SA_SEL_URL_TLD)
84 Scan File ${URL1}
85 Expect Symbol SA_SEL_URL_TLD
86
87 SA-Like: Selector Negation
88 [Documentation] Selector negation works (SA_SEL_NOT_CORP)
89 Scan File ${MESSAGE2}
90 Expect Symbol SA_SEL_NOT_CORP
91
92 SA-Like: Meta AND
93 [Documentation] Meta rule with AND over header+body+selector
94 Scan File ${MESSAGE2}
95 Expect Symbol SA_META_AND
96
97 SA-Like: Meta OR
98 [Documentation] Meta rule with OR over uri+selector
99 Scan File ${URL1}
100 Expect Symbol SA_META_OR
101
102 SA-Like: Meta Complex
103 [Documentation] Complex meta combining negation and rawbody
104 Scan File ${MESSAGE2}
105 Expect Symbol SA_META_COMPLEX