Coder Social home page Coder Social logo

carlostrub / sisyphus Goto Github PK

View Code? Open in Web Editor NEW
89.0 5.0 5.0 1.23 MB

Intelligent Junk Mail Handler

License: BSD 3-Clause "New" or "Revised" License

Go 95.44% Makefile 4.56%
go golang-application spam-filtering spam maildir junkmail spam-protection spam-detection spam-analyzer junk mail

sisyphus's Introduction

Sisyphus: Intelligent Junk Mail Handler

As we all know too well, many mails we receive are undesired for various reasons. Sometimes, we just do not want to be part of a scam, sometimes we really prefer no to have this latest joke mail sent by our beloved friends -- even though we are happy to exchange serious messages with them.

Sisyphus is a junk mail handler of the latest generation. It has the following features:

  • requires zero configuration, neither on the server nor on the client
  • works with any MTA and any client
  • learns about your preferences based on all messages in your inbox and your junk folder
  • can handle multiple mail accounts with independant junk mail preferences
  • requires minimal resources, e.g. learning over 50000 mails and keeping track of roughly 90000 words requires only 10MB of storage

Build Status Go Report Card GoDoc Documentation Codebeat Coverage Quality Gate Status

How it works

Sisyphus analyzes each mail in the inbox and the junk folder and uses its subject and text to improve the learning algorithm. Whenever a new mail arrives in the Maildir/new directory, Sisyphus classifies this mail based on its content. Junk mails are then moved automatically to the Maildir/.Junk directory, while good mails are left untouched. See the following blog post on a rather non-technical explanation.

Technically, Sisyphus applies a classic Bayesian Update algorithm to classify mails. However, in contrast to many traditional junk mail filters, classification is based on all mails ever received. This includes mails that are classified by the user as junk by moving them manually into the junk folder, or mails that have been correctly classified by Sisyphus previously. This is only possible with limited resources by applying the HyperLogLog algorithm to store the learned mails.

The learned information is stored in a local database called sisyphus.db which is located in each Maildir directory.

Install

Sisyphus can be installed by downloading the released binary package.

To build from source, you can

  1. Clone this repository into $GOPATH/src/github.com/carlostrub/sisyphus and change directory into it
  2. Run make build

This will leave you with ./sisyphus in the sisyphus directory, which you can put in your $PATH. (You can also take a look at make install to install for you.)

Usage

First, set the environment variable necessary for operation:

$ setenv SISYPHUS_DIRS PATHTOMAILDIR

or

$ export SISYPHUS_DIRS=PATHTOMAILDIR

or for Windows

$ set SISYPHUS_DIRS=PATHTOMAILDIR

For all other configuration options, please consult the help. It can be started by running

$ sisyphus help

To start sisyphus, do

$ sisyphus run

To display various statistics, do

$ sisyphus stats

(caveat: run at least one learning cycle)

See the help for more details.

License

Sisyphus is licensed under the 3-Clause BSD license. See the LICENSE file for detailed information.

sisyphus's People

Contributors

carlostrub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sisyphus's Issues

Add --noop flag

I'm hesitant of trying sisyphus because afaik it potentially moves messaged on the first run.
It would be great to that a --noop flag (or sth similar) to see what it would do instead of actually doing.

sisyphus help should not depend on env vars

It would be good if a user can get help right away, before setting required env vars. Warn instead of bailing out ?

» sisyphus --help
FATA[0000] Environment variable SISYPHUS_DIRS not set.  

Learn from other mailboxes

Hi and thanks for this great project! I have used it for about 3 weeks now and it already works better than my previous solution.

What do you think about adding an option to add more mailboxes to learn from? I am trying to keep my inbox tidy. This means I only keep mails I have to catch up on in my inbox. Other things go to the .Archive folder as soon as I have read them. This means Sisyphus cannot learn from these archived mails, unless I keep them in the inbox until Sisyphus had the chance to learn it.

The folder structure looks (simplified) like this:

|- cur
|- new
|- .Archive
   |- cur
   |- new

So what Sisyphus should do is to learn from either all of the cur folders in the mailbox directory (except ./.Junk/cur). Or better, accept an option to configure which ones.

Like this I could keep my workflow and additionally Sisyphus could learn from all my 20'000 e-mails in the archive.

Use logrus

Implement logging with sirupsen/logrus and --verbose and --debug flags to adjust log level.

Randomize words in wordlist

Instead of setting a hard limit of words to analyze, select a random number of words for analysis, but learn all.

crashes everywhere

./sisyphus i
INFO[0000] Create missing directories                    dir=/home/admin/Maildir/
INFO[0000] All databases loaded
INFO[0000] Database closed                               maildir=/home/admin/Maildir/
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4e1847]

goroutine 1 [running]:
github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt.(*Bucket).Cursor(...)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt/bucket.go:91
github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt.(*Bucket).Get(0x0, 0xc42003b798, 0xd, 0x20, 0xd, 0x20, 0xc42001c000)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt/bucket.go:267 +0x37
github.com/carlostrub/sisyphus.Info.func1(0xc4200f2000, 0x73ab90, 0xc4200f2000)
	/home/cs/go/src/github.com/carlostrub/sisyphus/info.go:13 +0xf8
github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt.(*DB).View(0xc4200ec000, 0xc42003b890, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt/db.go:629 +0x9a
github.com/carlostrub/sisyphus.Info(0xc4200ec000, 0x0, 0x0, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/info.go:11 +0x83
main.main.func3(0xc420070580)
	/home/cs/go/src/github.com/carlostrub/sisyphus/sisyphus/sisyphus.go:242 +0x1c4
github.com/carlostrub/sisyphus/vendor/github.com/urfave/cli.HandleAction(0x6c8120, 0xc42000a3a0, 0xc420070580, 0xc420052300, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/urfave/cli/app.go:492 +0x7c
github.com/carlostrub/sisyphus/vendor/github.com/urfave/cli.Command.Run(0x727f82, 0x5, 0x0, 0x0, 0xc4200447d0, 0x1, 0x1, 0x72d83d, 0xf, 0x0, ...)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/urfave/cli/command.go:210 +0xa95
github.com/carlostrub/sisyphus/vendor/github.com/urfave/cli.(*App).Run(0xc4200664e0, 0xc42000a080, 0x2, 0x2, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/urfave/cli/app.go:255 +0x6f8
main.main()
	/home/cs/go/src/github.com/carlostrub/sisyphus/sisyphus/sisyphus.go:254 +0x62e

and again:

INFO[0008] All mails learned
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4e7989]

goroutine 7 [running]:
github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt.(*DB).beginTx(0x0, 0x0, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt/db.go:470 +0x29
github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt.(*DB).Begin(0x0, 0xc42005d500, 0x0, 0x0, 0x1)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt/db.go:463 +0x6e
github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt.(*DB).View(0x0, 0xc420105be0, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/vendor/github.com/boltdb/bolt/db.go:613 +0x46
github.com/carlostrub/sisyphus.classificationStatistics(0x0, 0x0, 0x0, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/classify.go:64 +0x84
github.com/carlostrub/sisyphus.classificationPrior(0x0, 0x0, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/classify.go:18 +0x2b
github.com/carlostrub/sisyphus.classificationWord(0x0, 0xc4200f687e, 0x4, 0x20, 0x0, 0x0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/classify.go:128 +0x2f
github.com/carlostrub/sisyphus.Junk(0x0, 0xc4201ea400, 0x1f, 0x20, 0x0, 0x0, 0x3f, 0x13)
	/home/cs/go/src/github.com/carlostrub/sisyphus/classify.go:202 +0xbc
github.com/carlostrub/sisyphus.(*Mail).Classify(0xc420105f10, 0x0, 0xc420050000, 0x13, 0x8f60c0, 0x2)
	/home/cs/go/src/github.com/carlostrub/sisyphus/classify.go:161 +0xa9
main.main.func2.2(0xc42006a690, 0xc420044860, 0xc420060fc0)
	/home/cs/go/src/github.com/carlostrub/sisyphus/sisyphus/sisyphus.go:189 +0x277
created by main.main.func2
	/home/cs/go/src/github.com/carlostrub/sisyphus/sisyphus/sisyphus.go:179 +0x2a6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.