| 1 |
*** Settings *** |
| 2 |
Suite Setup HTML Fuzzy Setup Mumhash |
| 3 |
Suite Teardown Rspamd Redis Teardown |
| 4 |
Resource lib.robot |
| 5 |
|
| 6 |
*** Variables *** |
| 7 |
${HTML_TEMPLATE_1} ${RSPAMD_TESTDIR}/messages/html_template_1.eml |
| 8 |
${HTML_TEMPLATE_1_VAR} ${RSPAMD_TESTDIR}/messages/html_template_1_variation.eml |
| 9 |
${HTML_TEMPLATE_1_FUZZY} ${RSPAMD_TESTDIR}/messages/html_template_1_fuzzy.eml |
| 10 |
${HTML_PHISHING} ${RSPAMD_TESTDIR}/messages/html_phishing.eml |
| 11 |
|
| 12 |
*** Keywords *** |
| 13 |
HTML Fuzzy Setup Mumhash |
| 14 |
Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} mumhash |
| 15 |
Set Suite Variable ${RSPAMD_FUZZY_SERVER_MODE} servers |
| 16 |
# Include HTML-specific settings via FUZZY_INCLUDE |
| 17 |
Set Suite Variable ${RSPAMD_FUZZY_INCLUDE} ${RSPAMD_TESTDIR}/configs/fuzzy-html.conf |
| 18 |
Rspamd Redis Setup |
| 19 |
|
| 20 |
HTML Fuzzy Add Test |
| 21 |
[Documentation] Learn legitimate HTML template |
| 22 |
Set Suite Variable ${RSPAMD_FUZZY_HTML_ADD} 0 |
| 23 |
${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -w 10 -f ${RSPAMD_FLAG1_NUMBER} fuzzy_add ${HTML_TEMPLATE_1} |
| 24 |
Check Rspamc ${result} |
| 25 |
Sync Fuzzy Storage |
| 26 |
Set Suite Variable ${RSPAMD_FUZZY_HTML_ADD} 1 |
| 27 |
|
| 28 |
HTML Fuzzy Check Test |
| 29 |
[Documentation] Check exact match |
| 30 |
IF ${RSPAMD_FUZZY_HTML_ADD} == 0 |
| 31 |
Fail "HTML Fuzzy Add was not run" |
| 32 |
END |
| 33 |
Scan File ${HTML_TEMPLATE_1} |
| 34 |
Expect Symbol ${FLAG1_SYMBOL} |
| 35 |
|
| 36 |
HTML Fuzzy Exact Match Variation Test |
| 37 |
[Documentation] Check exact match with different text but identical HTML structure |
| 38 |
IF ${RSPAMD_FUZZY_HTML_ADD} == 0 |
| 39 |
Fail "HTML Fuzzy Add was not run" |
| 40 |
END |
| 41 |
Scan File ${HTML_TEMPLATE_1_VAR} |
| 42 |
# Should match exactly - same HTML structure, only text differs |
| 43 |
Expect Symbol ${FLAG1_SYMBOL} |
| 44 |
|
| 45 |
HTML Fuzzy Similarity Test |
| 46 |
[Documentation] Check fuzzy (similarity) match with slightly different HTML structure |
| 47 |
IF ${RSPAMD_FUZZY_HTML_ADD} == 0 |
| 48 |
Fail "HTML Fuzzy Add was not run" |
| 49 |
END |
| 50 |
Scan File ${HTML_TEMPLATE_1_FUZZY} |
| 51 |
# Should match via shingles - similar but not identical HTML structure |
| 52 |
# (added spacer div, extra paragraph, second article) |
| 53 |
Expect Symbol ${FLAG1_SYMBOL} |
| 54 |
|
| 55 |
HTML Fuzzy Phishing Test |
| 56 |
[Documentation] Check phishing email with same structure but different CTA domains |
| 57 |
IF ${RSPAMD_FUZZY_HTML_ADD} == 0 |
| 58 |
Fail "HTML Fuzzy Add was not run" |
| 59 |
END |
| 60 |
# Structure similar but CTA domains different |
| 61 |
# Might match with lower score or not match depending on CTA weight |
| 62 |
# Just verify scanning works without crash |
| 63 |
Scan File ${HTML_PHISHING} |
| 64 |
|
| 65 |
HTML Fuzzy Delete Test |
| 66 |
[Documentation] Delete HTML fuzzy hash |
| 67 |
IF ${RSPAMD_FUZZY_HTML_ADD} == 0 |
| 68 |
Fail "HTML Fuzzy Add was not run" |
| 69 |
END |
| 70 |
${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -f ${RSPAMD_FLAG1_NUMBER} fuzzy_del ${HTML_TEMPLATE_1} |
| 71 |
Check Rspamc ${result} |
| 72 |
Sync Fuzzy Storage |
| 73 |
Scan File ${HTML_TEMPLATE_1} |
| 74 |
Do Not Expect Symbol ${FLAG1_SYMBOL} |
| 75 |
|
| 76 |
*** Test Cases *** |
| 77 |
HTML Fuzzy Add |
| 78 |
HTML Fuzzy Add Test |
| 79 |
|
| 80 |
HTML Fuzzy Exact Match |
| 81 |
HTML Fuzzy Check Test |
| 82 |
|
| 83 |
HTML Fuzzy Exact Match With Text Variation |
| 84 |
HTML Fuzzy Exact Match Variation Test |
| 85 |
|
| 86 |
HTML Fuzzy Similarity Match |
| 87 |
HTML Fuzzy Similarity Test |
| 88 |
|
| 89 |
HTML Fuzzy Phishing Detection |
| 90 |
HTML Fuzzy Phishing Test |
| 91 |
|
| 92 |
HTML Fuzzy Delete |
| 93 |
HTML Fuzzy Delete Test |