#sandbox #cli

bin+lib catj

A light process isolation sandbox used for competitive programming contest

11 releases

0.2.3 Oct 6, 2023
0.2.2 Oct 6, 2023
0.2.0 Jan 30, 2023
0.1.5 Jan 27, 2023
0.0.0 Jan 20, 2023

#897 in Command line utilities

Download history 6/week @ 2023-10-14 9/week @ 2023-10-21 14/week @ 2023-10-28 1/week @ 2023-11-11 7/week @ 2023-11-18 57/week @ 2023-11-25 11/week @ 2023-12-02 11/week @ 2023-12-09 22/week @ 2023-12-23 11/week @ 2024-01-06 53/week @ 2024-01-27

64 downloads per month

MIT license

81KB
2.5K SLoC

CatJ

CI

A light process isolation sandbox used for Competitive Programming contest.

Features

  • cgroups: Record cpu and memory usage (may fall back to getrusage)
  • mount and chroot: Created an isolated file system
  • setrlimit: Set resource limits (cpu, address size, stack size, file size)
  • setuid and setgid: Run submission under another user and group
  • ptrace: Filter submission syscall

Note

To enable all of above features, it is highly recommended to use it under the root user, otherwise it may fall back automatically.

Installation

# Install using cargo
$ cargo install catj

# Or you can download binary with installation script
$ curl -fsSL https://bina.egoist.sh/CaCatHead/CatBox | sh

# Check installation
$ catj --version
catj 0.2.3

# Init cgroup for current user
$ ./init.sh $USER

Usage

# Compile C++ source code
$ catj compile ./fixtures/aplusb/source/ac.cpp -o a.out

# Run a.out
$ catj run --stdin ./fixtures/aplusb/testcases/1.in --read . -- ./a.out
2

# Generate report
$ catj --report run --stdin ./fixtures/aplusb/testcases/1.in --stdout ./sub.out --read . -- ./a.out
# or
$ catj -r run -i ./fixtures/aplusb/testcases/1.in -o ./sub.out -R . -- ./a.out
Status     0
Signal     ✓
Time       1 ms
Time user  1 ms
Time sys   0 ms
Memory     0 KB

License

MIT License © 2023 XLor

Dependencies

~9–21MB
~286K SLoC