Exemple #1
0
func initClamAV() *clamav.Engine {
	if *db == "" {
		*db = clamav.DBDir()
	}
	engine := clamav.New()
	sigs, err := engine.Load(clamav.DBDir(), clamav.DbStdopt)
	if err != nil {
		log.Fatalf("can not initialize ClamAV engine: %v", err)
	}
	if *debug {
		log.Printf("loaded %d signatures", sigs)
	}
	engine.Compile()

	return engine
}
Exemple #2
0
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"runtime"
)

import "github.com/mirtchovski/clamav"

var debug = flag.Bool("debug", false, "enable debugging output")
var clamavdebug = flag.Bool("clamavdebug", false, "enable debugging output from the ClamAV engine")
var clamavversion = flag.Bool("clamavversion", false, "print out the version of ClamAV linked")
var scan = flag.Bool("scan", true, "don't scan files for viruses, only walk directories")
var workers = flag.Int("workers", 8, "number of scanning workers")
var cpus = flag.Int("cpus", 2, "number of active OS threads")
var db = flag.String("db", clamav.DBDir(), "virus definition database")
var testmap = flag.Bool("testfmap", false, "test memory scanning only")

var eicar = []byte(`X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*`)

func usage() {
	fmt.Fprintf(os.Stderr, "usage: %s path [...]\n", os.Args[0])
	flag.PrintDefaults()
	os.Exit(1)
}

// A counter goroutine sits between the walker and the workers and keeps track
// of the walker's progress.
func counter(cnt, out chan string) {
	c := uint64(0)
	for path := range cnt {