Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
be3f4634
Commit
be3f4634
authored
16 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Send quarantine DSN to SPF PASS only.
parent
a420148b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bms.py
+37
-20
37 additions, 20 deletions
bms.py
milter.cfg
+1
-1
1 addition, 1 deletion
milter.cfg
with
38 additions
and
21 deletions
bms.py
+
37
−
20
View file @
be3f4634
#!/usr/bin/env python
# A simple milter that has grown quite a bit.
# $Log$
# Revision 1.123 2008/07/29 21:59:29 customdesigned
# Parse ESMTP params
#
# Revision 1.122 2008/05/08 21:35:56 customdesigned
# Allow explicitly whitelisted email from banned_users.
#
...
...
@@ -1580,7 +1583,7 @@ class bmsMilter(Milter.Milter):
ds
.
check_spam
(
screener
,
txt
,
self
.
recipients
,
force_result
=
dspam
.
DSR_ISINNOCENT
)
return
False
if
self
.
reject_spam
:
if
self
.
reject_spam
and
self
.
spf
.
result
!=
'
pass
'
:
self
.
log
(
"
DSPAM:
"
,
screener
,
'
REJECT: X-DSpam-Score: %f
'
%
ds
.
probability
)
self
.
setreply
(
'
550
'
,
'
5.7.1
'
,
'
Your Message looks spammy
'
)
...
...
@@ -1590,12 +1593,18 @@ class bmsMilter(Milter.Milter):
if
self
.
spf
and
self
.
mailfrom
!=
'
<>
'
:
# check that sender accepts quarantine DSN
self
.
fp
.
seek
(
0
)
if
self
.
spf
.
result
==
'
pass
'
or
self
.
cbv_needed
:
msg
=
mime
.
message_from_file
(
self
.
fp
)
if
self
.
spf
.
result
==
'
pass
'
:
rc
=
self
.
send_dsn
(
self
.
spf
,
msg
,
'
quarantine
'
)
else
:
rc
=
self
.
do_needed_cbv
(
msg
)
del
msg
else
:
rc
=
self
.
send_dsn
(
self
.
spf
)
if
rc
!=
Milter
.
CONTINUE
:
self
.
fp
=
None
return
rc
del
msg
if
not
ds
.
check_spam
(
screener
,
txt
,
self
.
recipients
,
classify
=
True
):
self
.
fp
=
None
return
Milter
.
DISCARD
...
...
@@ -1638,6 +1647,25 @@ class bmsMilter(Milter.Milter):
quarantine
=
False
)
self
.
log
(
"
TRAINSPAM:
"
,
screener
,
'
X-Dspam-Score: %f
'
%
ds
.
probability
)
def
do_needed_cbv
(
self
,
msg
):
q
,
res
=
self
.
cbv_needed
if
res
==
'
softfail
'
:
template_name
=
'
softfail
'
elif
res
in
(
'
fail
'
,
'
deny
'
):
template_name
=
'
fail
'
elif
res
in
(
'
unknown
'
,
'
permerror
'
):
template_name
=
'
permerror
'
elif
res
==
'
neutral
'
:
#template_name = 'neutral'
template_name
=
None
elif
res
in
(
'
error
'
,
'
temperror
'
):
template_name
=
'
temperror
'
else
:
template_name
=
'
strike3
'
rc
=
self
.
send_dsn
(
q
,
msg
,
template_name
)
self
.
cbv_needed
=
None
return
rc
def
eom
(
self
):
if
not
self
.
fp
:
return
Milter
.
ACCEPT
# no message collected - so no eom processing
...
...
@@ -1763,21 +1791,7 @@ class bmsMilter(Milter.Milter):
# need CBV. However, whitelisted domains might (to discover
# bogus localparts). Need a way to tell the difference.
if
self
.
cbv_needed
and
not
self
.
internal_domain
:
q
,
res
=
self
.
cbv_needed
if
res
==
'
softfail
'
:
template_name
=
'
softfail
'
elif
res
in
(
'
fail
'
,
'
deny
'
):
template_name
=
'
fail
'
elif
res
in
(
'
unknown
'
,
'
permerror
'
):
template_name
=
'
permerror
'
elif
res
==
'
neutral
'
:
template_name
=
'
neutral
'
elif
res
in
(
'
error
'
,
'
temperror
'
):
template_name
=
'
temperror
'
else
:
template_name
=
'
strike3
'
rc
=
self
.
send_dsn
(
q
,
msg
,
template_name
)
self
.
cbv_needed
=
None
rc
=
self
.
do_needed_cbv
(
msg
)
if
rc
==
Milter
.
REJECT
:
# Do not feedback here, because feedback should only occur
# for messages that have gone to DATA. Reputation lets us
...
...
@@ -1886,7 +1900,10 @@ class bmsMilter(Milter.Milter):
return
Milter
.
TEMPFAIL
cbv_cache
[
sender
]
=
res
self
.
log
(
'
REJECT:
'
,
desc
)
try
:
self
.
setreply
(
'
550
'
,
'
5.7.1
'
,
*
desc
.
splitlines
())
except
TypeError
:
self
.
setreply
(
'
550
'
,
'
5.7.1
'
,
"
Callback failure
"
)
return
Milter
.
REJECT
cbv_cache
[
sender
]
=
res
return
Milter
.
CONTINUE
...
...
This diff is collapsed.
Click to expand it.
milter.cfg
+
1
−
1
View file @
be3f4634
...
...
@@ -61,7 +61,7 @@ porn_words = penis, breast, pussy, horse cock, porn, xenical, diet pill, d1ck,
p-e-n-i-s,
hydrocodone,
vicodin,
xanax,
vicod1n,
x@nax,
diazepam,
v1@gra,
xan@x,
cialis,
ci@lis,
frëe,
xãnax,
valíum,
vãlium,
via-gra,
x@n3x,
vicod3n,
penís,
c0d1n,
phentermine,
en1arge,
dip1oma,
v1codin,
valium,
rolex,
sexual,
fuck,
adv1t,
vgaira,
medz
valium,
rolex,
sexual,
fuck,
adv1t,
vgaira,
medz
,
acai
berry
# reject mail with these case sensitive strings in the subject
spam_words
=
$$$, !!!, XXX, FREE, HGH
# attachments with these extensions will be replaced with a warning
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment