-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (41 loc) · 991 Bytes
/
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
package main
import (
"fmt"
"os"
sg "github.com/subgraph/go-seccomp"
"github.com/twtiger/go-seccomp-tester/helpers"
"github.com/twtiger/gosecco/asm"
)
func fileExists(filename string) bool {
_, err := os.Stat(filename)
return err == nil
}
func checkArgs() bool {
return len(os.Args) < 4 ||
(os.Args[1] != "white" && os.Args[1] != "black") ||
(os.Args[2] != "true" && os.Args[2] != "false") ||
!fileExists(os.Args[3])
}
func main() {
if checkArgs() {
fmt.Println("Usage: go-seccomp-tester [white|black] <enforce> <filename>")
return
}
whiteList := os.Args[1] == "white"
enforce := os.Args[2] == "true"
filename := os.Args[3]
sg.CheckSupport()
var e error
var filters []sg.SockFilter
if whiteList {
filters, e = sg.Compile(filename, enforce)
} else {
filters, e = sg.CompileBlacklist(filename, enforce)
}
if e != nil {
fmt.Printf("Had error when compiling: %#v\n", e)
} else {
our := helpers.CopyFilters(filters)
fmt.Print(asm.Dump(our))
}
}