prepping for walkers to be plugins
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
790ac3077a
commit
339b6145f9
2 changed files with 51 additions and 1 deletions
|
@ -1,8 +1,34 @@
|
|||
package walker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"plugin"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LoadPlugin loads the file path and returns a Fuzzer
|
||||
func LoadPlugin(path string) (Fuzzer, error) {
|
||||
p, err := plugin.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sym, err := p.Lookup("MyFuzzerFunc")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mff, ok := sym.(Fuzzer)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("plugin at %q did not provide a FuzzFunc named MyFuzzerFunc", path)
|
||||
}
|
||||
return mff, nil
|
||||
}
|
||||
|
||||
// Fuzzer is a struct that produces a FuzzFunc
|
||||
type Fuzzer interface {
|
||||
Name() string
|
||||
Func() FuzzFunc
|
||||
}
|
||||
|
||||
// FuzzFunc is like filepath.WalkerFunc, but for poking at `path`
|
||||
type FuzzFunc func(path string, info os.FileInfo, timeout time.Duration) error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue