Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Use sa_unwrap in isbg
Browse files Browse the repository at this point in the history
`isbg.py` now tries to import and use `sa_unwrap.py` to unwrap mails that
are SA reports with the original spam mail embedded.

This only works if the `isbg` module is loaded properly. To stay
compatible with users calling `isbg.py` directly, `unwrap` is replaced
by a dummy no-op function if imprting `sa_unwrap` fails.
  • Loading branch information
duk3luk3 committed Jan 16, 2017
1 parent 45a951e commit 1c61fb4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions isbg/isbg.py
Expand Up @@ -65,6 +65,13 @@

import sys # Because sys.stderr.write() is called bellow

try:
from isbg.sa_unwrap import unwrap
except ImportError:
sys.stderr.write('Cannot load sa_unwrap, please install isbg package properly!')
# Create No-Op dummy function
unwrap = lambda x: None

try:
from docopt import docopt # Creating command-line interface
except ImportError:
Expand Down Expand Up @@ -421,6 +428,10 @@ def spamassassin(self):
for u in uids:
# Retrieve the entire message
body = self.getmessage(u, self.pastuids)
# Unwrap spamassassin reports
unwrapped = unwrap(body)
if unwrapped is not None:
body = unwrapped

# Feed it to SpamAssassin in test mode
if self.dryrun:
Expand Down Expand Up @@ -569,6 +580,10 @@ def spamlearn(self):

for u in uids:
body = self.getmessage(u)
# Unwrap spamassassin reports
unwrapped = unwrap(body)
if unwrapped is not None:
body = unwrapped
if self.dryrun:
out = self.alreadylearnt
code = 0
Expand Down

0 comments on commit 1c61fb4

Please sign in to comment.