New builtin filtering system
This filter system should give sufficient flexibility so that most common requirements in
terms of blocking individual spammers can be achieved without needing to resort to perl
scripts (like cleanfeed) although this is NOT intended as a replacement for such scripts
if you really want that level of flexibility this version of dnews does support using such
scripts.
Design Goals:
Fast processing of incoming messages.
A simple clear syntax so rules can easily be understood and modified
Enough power/flexibility to implement 99% of a filter like cleanfeed.
Incorporate regular expression matching.
Not to create a new elaborate language if possible.
There are 5 valid statements in a rule file:
Assignment
Action
if (Conditional_Expression) [and (Conditional_Expression)...] Action
else
end if
Assignment
$variable_name = "quoted string" [+ "quoted string"
[+ $variable ...]]
Action
accept "reason" | reject "reason" | then
| setflag("flagname") | clearflag("flagname")
Conditional_Expression
Any pre defined function, e.g. isbinary(),
isin("subject","free pictures")
Numeric comparisons, e.g. lines()>100
Simple NOT operator, e.g. if (!isbinary()) reject "Only binaries
alowed here mate!"
Calculations are NOT permitted, e.g. lines()+10 would fail
Line continuation
Lines can be continue by ending the line in a '\' character
Quoting strings
All strings and header names should be within double quotes, sometimes
you may get away without doing this, but we don't gaurantee this will work in future.
e.g. use: exists("Supersedes") not exists(Supersedes), quotes can
be escaped in the usual way, e.g. "This \"Word\" has quotes around it"
Assignments are processed at compile time, variables DO NOT exist at run time. Don't
think of this as a programming language, but rather as a list of rules that are processed
with each incoming message. Real run-time variables only exist in the form of the
ifflag("xxx") function and the setflag("xxx") action.
For example the following is NOT VALID, as the assignment is processed before the rules
are run. The rejection would always read "big message"
$fred = "small message"
if (lines()>100) then
$fred = "big message" (this will not
work as expected)
end if
reject $fred
Builtin Functions - details below
isin("header","string-not-case-sensitive")
rexp("header","regular-expression")
match("header","wildcard")
size()
matchall("header","wildcardlist")
matchone("header","wildcardlist")
ifflag("flag-name")
exists("header")
isbinary()
ishtml()
isencodedhtml()
isencodedtext()
isencodedurl()
isbase64()
isimage()
lines()
allmod()
New tellnews commands:
tellnews rules_reload
tellnews rules_trace rulefile.rul testmessages.txt
In newsfeeds.conf you specify a rule file like this:
site me
groups *
rules d:\dnews\me.rul
...
Sample Rules File
A sample rules file is available here. We make no claims with regard to its correctness/completeness but it should demonstrate the sort of thing that is possible with the new rules system. If you choose to base your rules file on it then we recommend you customise it to make sure it meets your specific needs.
You may also be interested in NoCem support or External Filters
This is a simple 'content' searching function, if the named header contains the string (a non case sensitive match is used) e.g.
if (isin("Subject","Free")) reject "Probably a spammer selling something"
This would reject a message containing a subject of "Get your Free pictures here", it would also reject a message containing a subject of "Is there any real freedom in the world?" so it's probably not a good rule :-)
This function searches the named header for a regular expression, the matching is not case sensitive, use rexp_case() for a case sensitive version.
This function applies a simple wild card matching algorithym as is typically used to match file names, e.g. match("From","*@netwin.co.nz*") would match against a message from that domain.
Returns the size in bytes of the current message, can be used with > and < operators.
Used for matching a single wild card, against a header which contains a list of values, like Newsgroups:, Path:, etc..., The match is TRUE only if all entries in the list match, e.g. if (matchall("Newsgroups","news.filters.*")) accept "It is only in the filters list so we will accept it"
Identical to the above function, but returns 'TRUE' if any match occurs.
Used to check if a flag variable has been defined as true, this can be done with the setflag("flag-name") action, e.g.
if (size()>100000) setflag("bigitem")
if (isimage()) setflag("bigitem")
if (isflag("bigitem")>100000) reject "It was a big item or had a picture in it"
This is true if the header exists in the message and is non zero in length, e.g. if (exists("supersedes")) then reject "We don't like supersedes headers"
This is true if the message has binary data, either base64 encoding or uuencoded data.
This is true if the message appears to contain HTML instead of plain text data.
This is true if the message appears to contain mime or uuencoded HTML instead of plain text data.
This is true if the message appears to contain mime or uuencoded text data. This will always be true if isencodedhtml() returns true.
This is true if the message appears to contain a uuencoded URL reference.
This is true if the message appears to contain base64 binary encoded data.
This is true if the message appears to contain a picture (either mime or uuencoded)
This returns the number of lines in the message.
This returns true if all the newsgroups in the specified header are moderated.
Actions
accept "reason"
Accepts the current article reporting the "reason" specified in the log files.
reject "reason"
Rejects the current article reporting the "reason" specified in the log files.
setflag("flag-name")
Used to set the specified flag variable to the true state.
clearflag("flag-name")
Used to set the specified flag variable to the false state.
Special Flags
There are three special internal flags that can be used from within a rules file to bypass other spam filter routines internal to dnews.
| Special Flag | Default Value | Description |
| skip_filter | false | Don't check body for words in filter.dat file |
| skip_from | false | Don't apply duplicate FROM filter spam rules |
| skip_dup | false | Don't apply dupliate body filter |
In the rules file you can use actions like setflag("skip_from") to stop dnews from checking the from header, for example if you don't want it to apply the from filter to messages from anyone at 'netwin.co.nz' then:
if (isin("From","@netwin.co.nz")) setflag("skip_from")
| Products | Downloads | Prices | Support | Company |
|---|---|---|---|---|