/nim-seccomp

Seccomp (libseccomp2) adapter for the Nim language

Primary LanguageNimGNU Lesser General Public License v2.1LGPL-2.1

nim-seccomp

Nim adapter for the Seccomp sandbox facility

badge tags License

Features

  • Provides a high-level adaptor in seccomp.nim

  • Low-level wrapper in seccomp_lowlevel.nim

  • Tested on Linux

  • Basic tests

Installation

sudo apt-get install libseccomp2
nimble install seccomp

Usage

Refer to the generated documentation for the seccomp and seccomp_lowlevel modules

import seccomp

setSeccomp("write exit_group")

echo """Seccomp is now enabled. Future attempts to change the Seccomp configuration
or to call forbidden system calls will cause the process to be terminated"""

# e.g. createDir("/tmp/foo")

or:

import seccomp

let ctx = seccomp_ctx()
ctx.add_rule(Allow, "write")
ctx.add_rule(Allow, "exit_group")
ctx.load()

tests/trigger_seccomp.nim contains running examples of syscalls that will be blocked

Contributing

Testing and PRs are welcome.

Running tests:

nimble test
nimble test_trigger_seccomp