github.com/criyle/go-sandbox@v0.10.3/ptracer/tracer.go (about) 1 package ptracer 2 3 import "github.com/criyle/go-sandbox/runner" 4 5 // TraceAction defines the action returned by TraceHandle 6 type TraceAction int 7 8 const ( 9 // TraceAllow does not do anything 10 TraceAllow TraceAction = iota 11 // TraceBan skips the syscall and set the return code specified by SetReturnCode 12 TraceBan 13 // TraceKill referred as dangerous action have been detected 14 TraceKill 15 ) 16 17 // Tracer defines a ptracer instance 18 type Tracer struct { 19 Handler 20 Runner 21 runner.Limit 22 } 23 24 // Runner represents the process runner 25 type Runner interface { 26 // Starts starts the child process and return pid and error if failed 27 // the child process should enable ptrace and should stop before ptrace 28 Start() (int, error) 29 } 30 31 // Handler defines customized handler for traced syscall 32 type Handler interface { 33 // Handle returns action take to the traced program 34 Handle(*Context) TraceAction 35 36 // Debug prints debug information when in debug mode 37 Debug(v ...interface{}) 38 }