Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions bscdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand All @@ -139,7 +154,7 @@ func scanFile(pathToFile string) []searchResult {
}
}
}
return searchResults
ch <- searchResults
}

// Returns the given file as an array of lines.
Expand Down
13 changes: 8 additions & 5 deletions syscall-restrictions-linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
17 changes: 13 additions & 4 deletions whitelist.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down