User Tools

Site Tools


doc:appunti:linux:sa:spamassassin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:linux:sa:spamassassin [2021/04/16 18:53] – [Regole personalizzate] niccolodoc:appunti:linux:sa:spamassassin [2021/07/08 12:19] (current) – [Verifica punteggio] niccolo
Line 95: Line 95:
  
 <file> <file>
-header   SENDER_GOOGLE_CALENDAR   Sender =~ /calendar-notification\@google\.com/ +header      LOCAL_SENDER_GOOGLE_CALENDAR   Sender =~ /calendar-notification\@google\.com/ 
-describe SENDER_GOOGLE_CALENDAR   Sender is Google Calendar +describe    LOCAL_SENDER_GOOGLE_CALENDAR   Sender is Google Calendar 
-score    SENDER_GOOGLE_CALENDAR   -2.8+score       LOCAL_SENDER_GOOGLE_CALENDAR   -2.8
 </file> </file>
  
 Fare attenzione alla stringa dopo il segno **''=~''**, si tratta di un'espressione regolare racchiusa tra slash. Alcuni caratteri come il punto e il simbolo **@** devono essere preceduti da backslash perché sono simboli speciali nelle espressioni regolari. Fare attenzione alla stringa dopo il segno **''=~''**, si tratta di un'espressione regolare racchiusa tra slash. Alcuni caratteri come il punto e il simbolo **@** devono essere preceduti da backslash perché sono simboli speciali nelle espressioni regolari.
 +
 +Un altro esempio per penalizzare certi top level domain particolarmente utilizzati dagli spammer:
 +
 +<file>
 +header      LOCAL_FROM_SPAMMER_TLD    From   =~ /@[a-z0-9\-\.]+\.(cam|top|xyz)/i
 +describe    LOCAL_FROM_SPAMMER_TLD    Domain originates a lot of spam
 +score       LOCAL_FROM_SPAMMER_TLD    4.0
 +</file>
 +
 +Vedere anche il paragrafo **[[spamassassin_private_dnsbl#configure_spamassassin|come utilizzare una blacklist DNS con SpamAssassin]]**.
  
 ===== AutoWhitelist ===== ===== AutoWhitelist =====
Line 182: Line 192:
 I test network sono disabilitati se il demone **spamd** viene avviato con l'opzione **''%%-L%%''** oppure **''%%--local%%''**. I test network sono disabilitati se il demone **spamd** viene avviato con l'opzione **''%%-L%%''** oppure **''%%--local%%''**.
  
 +===== Verifica punteggio =====
 +
 +Con il seguente script dovrebbe essere possibile verificare il punteggio associato per ciascun test:
 +
 +<code bash>
 +#!/bin/sh
 +TESTS="$1"
 +if [ -z "$TESTS" ]; then
 +    echo "Usage: $(basename $0) [rule1,rule2,...]"
 +    exit 1
 +fi
 +cat << EOF
 +
 +=== Punteggio SpamAssassin ===
 +
 +  * Test Bayes e network disabilitati
 +  * Test Bayes disabilitati, test network abilitati
 +  * Test Bayes abilitati, test network disabilitati
 +  * >>> Test Bayes e network abilitati
 +
 +EOF
 +TESTS="$(echo "$TESTS" | sed 's/,/ /g')"
 +for TEST in $TESTS; do
 +    find /var/lib/spamassassin/ -name "*scores.cf" | while read file; do
 +        SCORE="$(egrep "^score\s+${TEST}\b" "$file")"
 +        if [ -n "$SCORE" ]; then
 +            #echo "$SCORE"
 +            RULE="$(echo "$SCORE" | awk '{print $2}')"
 +            SCORE1="$(echo "$SCORE" | awk '{print $3}')"
 +            SCORE2="$(echo "$SCORE" | awk '{print $4}')"
 +            SCORE3="$(echo "$SCORE" | awk '{print $5}')"
 +            SCORE4="$(echo "$SCORE" | awk '{print $6}')"
 +            printf '%-25s %7.2f %7.2f %7.2f %7.2f\n' "$RULE" "$SCORE1" "$SCORE2" "$SCORE3" "$SCORE4"
 +        fi
 +    done
 +done
 +</code>
 +
 +Ecco un esempio di utilizzo:
 +
 +<code>
 +./spamassassin-score-print HELO_NO_DOMAIN,HTML_MESSAGE,NICE_REPLY_A,RDNS_NONE,SPF_FAIL
 +
 +=== Punteggio SpamAssassin ===
 +
 +  * Test Bayes e network disabilitati
 +  * Test Bayes disabilitati, test network abilitati
 +  * Test Bayes abilitati, test network disabilitati
 +  * >>> Test Bayes e network abilitati
 +
 +HELO_NO_DOMAIN               0.00    4.40    0.00    4.40
 +HTML_MESSAGE                 0.00    0.00    0.00    0.00
 +NICE_REPLY_A                -0.25   -0.00   -0.25   -0.00
 +RDNS_NONE                    2.40    1.27    1.23    0.79
 +SPF_FAIL                     0.00    0.92    0.00    0.00
 +</code>
 ==== Client spamc e IPv6 ==== ==== Client spamc e IPv6 ====
  
doc/appunti/linux/sa/spamassassin.1618592011.txt.gz · Last modified: 2021/04/16 18:53 by niccolo