go-sandbox/ptracer/tracer.go
2019-09-01 01:36:01 -07:00

38 lines
850 B
Go

package ptracer
import "github.com/criyle/go-sandbox/types"
// TraceAction defines the action returned by TraceHandle
type TraceAction int
const (
// TraceAllow does not do anything
TraceAllow TraceAction = iota
// TraceBan blocked the syscall and set the return code specified by SetReturnCode
TraceBan
// TraceKill refered as dangerous action have been detacted
TraceKill
)
// Tracer defines a ptracer instance
type Tracer struct {
Handler
Runner
types.Limit
}
// Runner represents the process runner
type Runner interface {
// Starts starts the child process and return pid and error if failed
Start() (int, error)
}
// Handler defines customized handler for traced syscall
type Handler interface {
Handle(*Context) TraceAction
GetSyscallName(*Context) (string, error)
Debug(v ...interface{})
HandlerDisallow(string) error
}