mirror of
https://github.com/criyle/go-sandbox.git
synced 2025-09-26 23:19:11 +08:00
Compare commits
4 Commits
95811db6ca
...
de10456275
Author | SHA1 | Date | |
---|---|---|---|
![]() |
de10456275 | ||
![]() |
369229e0d5 | ||
![]() |
d58b2485a2 | ||
![]() |
6407c89d90 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,7 +2,6 @@
|
||||
.DS_Store
|
||||
|
||||
# Test Env
|
||||
test*/
|
||||
env*.sh
|
||||
|
||||
# Test Files
|
||||
@ -10,3 +9,5 @@ env*.sh
|
||||
/test
|
||||
|
||||
.vscode
|
||||
runprog
|
||||
*.test
|
||||
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM golang
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app/cmd/runprog
|
||||
RUN apt update && apt install -y gcc libstdc++6 libseccomp-dev
|
||||
|
||||
RUN go build
|
@ -16,6 +16,10 @@ var (
|
||||
"/dev/urandom",
|
||||
"/proc/meminfo",
|
||||
"/etc/localtime",
|
||||
"/usr/lib/libstdc++.so.6",
|
||||
"/usr/lib/libc.so.6",
|
||||
"/usr/lib/libm.so.6",
|
||||
"/usr/lib/libgcc_s.so.1",
|
||||
}
|
||||
|
||||
// default write permission files
|
||||
@ -75,6 +79,17 @@ var (
|
||||
"clock_gettime",
|
||||
|
||||
"restart_syscall",
|
||||
|
||||
|
||||
"futex",
|
||||
"gettid",
|
||||
"getpid",
|
||||
"prlimit64",
|
||||
"getrandom",
|
||||
"set_tid_address",
|
||||
"set_robust_list",
|
||||
"rseq",
|
||||
"newfstatat",
|
||||
}
|
||||
|
||||
// default syscalls to trace
|
||||
@ -108,71 +123,11 @@ var (
|
||||
// config for different type of program
|
||||
// workpath and arg0 have additional read / stat permission
|
||||
runptraceConfig = map[string]ProgramConfig{
|
||||
"python2.7": {
|
||||
Syscall: SyscallConfig{
|
||||
ExtraAllow: []string{
|
||||
"futex", "getdents", "getdents64", "prlimit64", "getpid", "sysinfo",
|
||||
},
|
||||
ExtraCount: map[string]int{
|
||||
"set_tid_address": 1,
|
||||
"set_robust_list": 1,
|
||||
},
|
||||
},
|
||||
FileAccess: FileAccessConfig{
|
||||
ExtraRead: []string{
|
||||
"/usr/bin/python2.7",
|
||||
"/usr/lib/python2.7/",
|
||||
"/usr/bin/lib/python2.7/",
|
||||
"/usr/local/lib/python2.7/",
|
||||
"/usr/lib/pymodules/python2.7/",
|
||||
"/usr/bin/Modules/",
|
||||
"/usr/bin/pybuilddir.txt",
|
||||
"/usr/lib/locale/",
|
||||
"./answer.code",
|
||||
},
|
||||
ExtraStat: []string{
|
||||
"/usr", "/usr/bin",
|
||||
},
|
||||
},
|
||||
RunCommand: []string{"/usr/bin/python2.7", "-E", "-s", "-B"},
|
||||
},
|
||||
"python3": {
|
||||
Syscall: SyscallConfig{
|
||||
ExtraAllow: []string{
|
||||
"futex", "getdents", "getdents64", "prlimit64", "getpid", "sysinfo", "getrandom",
|
||||
},
|
||||
ExtraCount: map[string]int{
|
||||
"set_tid_address": 1,
|
||||
"set_robust_list": 1,
|
||||
},
|
||||
},
|
||||
FileAccess: FileAccessConfig{
|
||||
ExtraRead: []string{
|
||||
"/usr/bin/python3",
|
||||
"/usr/lib/python3/",
|
||||
"/usr/bin/python3.6",
|
||||
"/usr/lib/python3.6/",
|
||||
"/usr/bin/lib/python3.6/",
|
||||
"/usr/local/lib/python3.6/",
|
||||
"/usr/bin/pyvenv.cfg",
|
||||
"/usr/pyvenv.cfg",
|
||||
"/usr/bin/Modules",
|
||||
"/usr/bin/pybuilddir.txt",
|
||||
"/usr/lib/dist-python",
|
||||
"/usr/lib/locale/",
|
||||
"./answer.code",
|
||||
},
|
||||
ExtraStat: []string{
|
||||
"/usr", "/usr/bin", "/usr/lib", "/usr/lib/python36.zip",
|
||||
},
|
||||
},
|
||||
RunCommand: []string{"/usr/bin/python3", "-I", "-B"},
|
||||
},
|
||||
"compiler": {
|
||||
Syscall: SyscallConfig{
|
||||
ExtraAllow: []string{
|
||||
"gettid", "set_tid_address", "set_robust_list", "futex",
|
||||
"getpid", "vfork", "fork", "clone", "execve", "wait4",
|
||||
"set_tid_address", "set_robust_list", "futex",
|
||||
"vfork", "fork", "clone", "execve", "wait4",
|
||||
"clock_gettime", "clock_getres",
|
||||
"setrlimit", "pipe",
|
||||
"getdents64", "getdents",
|
||||
|
10
test_c/Makefile
Normal file
10
test_c/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
all: helloworld/main.test nonzeroexit/main.test
|
||||
|
||||
helloworld/main.test: helloworld/main.cpp
|
||||
g++ helloworld/main.cpp -o helloworld/main.test -DNDEBUG -O3
|
||||
|
||||
nonzeroexit/main.test: nonzeroexit/main.cpp
|
||||
g++ nonzeroexit/main.cpp -o nonzeroexit/main.test -DNDEBUG -O3
|
||||
|
||||
clean:
|
||||
rm -rf helloworld/*.test nonzeroexit/*.test
|
6
test_c/helloworld/main.cpp
Normal file
6
test_c/helloworld/main.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include<iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, world" << std::endl;
|
||||
return 0;
|
||||
}
|
3
test_c/nonzeroexit/main.cpp
Normal file
3
test_c/nonzeroexit/main.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return 100;
|
||||
}
|
Loading…
Reference in New Issue
Block a user