-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (54 loc) · 1.05 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"log"
"os"
"snoopy/snoopy"
)
func main() {
app := &cli.App{
Name: "Snoopy-eBPF",
Usage: "Catching Program Executions with eBPF",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "max-args",
Value: 16,
Usage: "max # of execution arguments to record, 128 at most",
},
&cli.IntFlag{
Name: "max-envs",
Value: 16,
Usage: "max # of environment variables for the execution to record, 128 at most",
},
&cli.BoolFlag{
Name: "no-envs",
Value: false,
Usage: "don't record environment variables (shortcut for --max-envs 0)",
},
},
Action: func(c *cli.Context) error {
maxArg := c.Int("max-args")
maxEnv := c.Int("max-envs")
if c.Bool("no-envs") {
maxEnv = 0
}
config := snoopy.Config{
MaxArg: maxArg,
MaxEnv: maxEnv,
}
s, err := snoopy.New(config)
if err != nil {
cli.ShowAppHelp(c)
fmt.Println(err)
return err
}
s.Run()
return nil
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}