diff --git a/bscdiff.go b/bscdiff.go index 0f6cdef..f2f6301 100644 --- a/bscdiff.go +++ b/bscdiff.go @@ -64,8 +64,23 @@ func main() { } } - searchResults1 := scanFile(args[1]) - searchResults2 := scanFile(args[2]) + c1 := make(chan []searchResult) + c2 := make(chan []searchResult) + var searchResults1 []searchResult + var searchResults2 []searchResult + + go scanFile(args[1], c1) + go scanFile(args[2], c2) + + for i := 0; i < 2; i++ { + select { + case msg1 := <-c1: + searchResults1 = msg1 + case msg2 := <-c2: + searchResults2 = msg2 + } + } + missingBscs := findMissingBsc(searchResults1, searchResults2) prettyPrintMissingBscs(searchResults1, missingBscs, out) } @@ -115,7 +130,7 @@ func getBscs(res []searchResult) []string { } // Scans the file for bsc, CVE and issue numbers and returns the search results. -func scanFile(pathToFile string) []searchResult { +func scanFile(pathToFile string, ch chan<- []searchResult) { var regexes []*regexp.Regexp // creating the regexes with the regex-strings from main(). for _, regexString := range regexStrings { @@ -139,7 +154,7 @@ func scanFile(pathToFile string) []searchResult { } } } - return searchResults + ch <- searchResults } // Returns the given file as an array of lines. diff --git a/syscall-restrictions-linux.go b/syscall-restrictions-linux.go index 47dfaaf..62913c2 100644 --- a/syscall-restrictions-linux.go +++ b/syscall-restrictions-linux.go @@ -10,11 +10,14 @@ import ( ) func applySyscallRestrictions() { - var syscalls = []string{"read", "write", "close", "mmap", "munmap", - "rt_sigaction", "rt_sigprocmask", "clone", "execve", "sigaltstack", - "arch_prctl", "gettid", "futex", "sched_getaffinity", "epoll_ctl", - "openat", "newfstatat", "readlinkat", "pselect6", "epoll_pwait", - "epoll_create1", "exit_group"} + + var syscalls = []string{"read", "write", "close", "fstat", "mmap", + "mprotect", "munmap", "brk", "rt_sigaction", "rt_sigprocmask", + "access", "nanosleep", "clone", "execve", "uname", "fcntl", + "sigaltstack", "arch_prctl", "gettid", "futex", "sched_getaffinity", + "set_tid_address", "epoll_ctl", "openat", "newfstatat", + "readlinkat", "set_robust_list", "epoll_create1", "pipe2", + "prlimit64", "exit_group"} whiteList(syscalls) } diff --git a/whitelist.py b/whitelist.py index 5e51c86..73136b8 100644 --- a/whitelist.py +++ b/whitelist.py @@ -1,28 +1,37 @@ # You can get a list of syscalls via strace: -# $ strace -qcf ./team-suse +# $ strace -qcf ./bscdiff dump = """\ read write close +fstat mmap +mprotect munmap +brk rt_sigaction rt_sigprocmask +access +nanosleep clone execve +uname +fcntl sigaltstack arch_prctl gettid futex sched_getaffinity +set_tid_address epoll_ctl openat newfstatat readlinkat -pselect6 -epoll_pwait -epoll_create1""" +set_robust_list +epoll_create1 +pipe2 +prlimit64""" whitelist = dump.split("\n") whitelist.append("exit_group") # I guess we alwas need to exit the program