switching to plugins

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2018-06-06 10:42:39 -04:00
parent 339b6145f9
commit 0f0ce2af37
Signed by: vbatts
GPG key ID: 10937E57733F1362
5 changed files with 70 additions and 42 deletions

View file

@ -0,0 +1,42 @@
package main
import (
"fmt"
"io"
"io/ioutil"
"os"
"time"
"git.thisco.de/vbatts/fuzz-walker/walker"
)
func NewFuzzer() (walker.Fuzzer, error) {
return &myFuzzer{}, nil
}
type myFuzzer struct{}
func (mf myFuzzer) Name() string {
return "readFuzz"
}
func (mf myFuzzer) Func(path string, info os.FileInfo, timeout time.Duration) error {
c1 := make(chan error, 1)
go func() {
fd, err := os.Open(path)
if err != nil {
c1 <- err
}
defer fd.Close()
_, err = io.Copy(ioutil.Discard, fd)
c1 <- err
}()
select {
case err := <-c1:
return err
case <-time.After(timeout):
return fmt.Errorf("timeout reached")
}
return nil
}