Git Product home page Git Product logo

go-clamd's Introduction

go-clamd

Interface to clamd (clamav daemon). You can use go-clamd to implement virus detection capabilities to your application.

GoDoc Build Status

Examples

c := clamd.NewClamd("/tmp/clamd.socket")

reader := bytes.NewReader(clamd.EICAR)
response, err := c.ScanStream(reader, make(chan bool))

for s := range response {
    fmt.Printf("%v %v\n", s, err)
}

Contributions

Contributions are welcome.

Creators

Remco Verhoef

Copyright and license

Code and documentation copyright 2011-2014 Remco Verhoef. Code released under the MIT license.

go-clamd's People

Contributors

freeaqingme avatar nl5887 avatar pweil- 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

go-clamd's Issues

Goroutine leak

The anonymous goroutine introduced in 4ca7e7b will never exit unless the command is aborted. This leaks a goroutine per successful invocation of ScanStream.

Ping core dump

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11268aa]

goroutine 1 [running]:
github.com/dutchcoders/go-clamd.(*Clamd).Ping(0x0?)
/root/GOPATH/pkg/mod/github.com/dutchcoders/[email protected]/clamd.go:118 +0x4a
github.com/chaitin/veinmind-tools/plugins/go/veinmind-malicious/sdk/av/clamav.Active(...)
/root/GOPATH/pkg/mod/github.com/chaitin/veinmind-tools/plugins/go/[email protected]/sdk/av/clamav/client.go:22

Clamd connections are not being closed

I have encountered an issue in this otherwise excellent package, It appears that the connection to clamd is not being closed. I am running this on a Debian jessie system, with go v1.4.2. It's pretty easy to reproduce, just run the example from the README in a loop a thousand times, pause, and check the open files (e.g. using lsof).

package main

import (
    "bufio"
    "bytes"
    "fmt"
    clamd "github.com/dutchcoders/go-clamd"
    "os"
)

func main() {
    for i := 0; i < 1000; i++ {
        sendRequest("/var/run/clamav/clamd.ctl", clamd.EICAR)
    }
    fmt.Println("Hit <enter>")
    bufio.NewReader(os.Stdin).ReadString('\n')
}

func sendRequest(clamav string, content []byte) {
    c := clamd.NewClamd(clamav)

    reader := bytes.NewReader(content)
    response, err := c.ScanStream(reader)

    for s := range response {
        fmt.Printf("%v %v\n", s, err)
    }
}

Looking at the code, it appears that line clamd.go:282 is not firing:

wg.Wait()

On a whim, I changed the return value of conn.go:76 to return a pointer to the WaitGroup, on the hunch that the return value is being copied and so will never fire. This works.

func (c *CLAMDConn) readResponse() (chan string, *sync.WaitGroup, error) {
...
    return ch, &wg, nil

Do you agree with my diagnosis?

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.