{"id":15007465,"url":"https://github.com/libseccomp-rs/libseccomp-rs","last_synced_at":"2025-04-04T10:08:09.243Z","repository":{"id":39538462,"uuid":"344865648","full_name":"libseccomp-rs/libseccomp-rs","owner":"libseccomp-rs","description":"Rust Language Bindings for the libseccomp Library","archived":false,"fork":false,"pushed_at":"2025-03-28T05:14:11.000Z","size":324,"stargazers_count":35,"open_issues_count":12,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T09:08:25.497Z","etag":null,"topics":["api-bindings","containers","libseccomp","linux-kernel","rust","seccomp"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/libseccomp","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libseccomp-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-05T16:17:03.000Z","updated_at":"2025-03-28T05:37:59.000Z","dependencies_parsed_at":"2023-02-14T05:01:33.213Z","dependency_job_id":"423ec2d8-0490-44cd-88b2-9187ea6c3571","html_url":"https://github.com/libseccomp-rs/libseccomp-rs","commit_stats":{"total_commits":172,"total_committers":7,"mean_commits":"24.571428571428573","dds":"0.42441860465116277","last_synced_commit":"04e93b3b8e310e8bfe98464c99b93501a5fe11ab"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libseccomp-rs%2Flibseccomp-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libseccomp-rs%2Flibseccomp-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libseccomp-rs%2Flibseccomp-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libseccomp-rs%2Flibseccomp-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libseccomp-rs","download_url":"https://codeload.github.com/libseccomp-rs/libseccomp-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157283,"owners_count":20893220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-bindings","containers","libseccomp","linux-kernel","rust","seccomp"],"created_at":"2024-09-24T19:10:09.376Z","updated_at":"2025-04-04T10:08:09.222Z","avatar_url":"https://github.com/libseccomp-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libseccomp-rs\n\n[![build-test](https://github.com/libseccomp-rs/libseccomp-rs/actions/workflows/build-test.yaml/badge.svg?branch=main)](https://github.com/libseccomp-rs/libseccomp-rs/actions/workflows/build-test.yaml)\n[![Latest release on crates.io](https://img.shields.io/crates/v/libseccomp.svg)](https://crates.io/crates/libseccomp)\n[![Documentation on docs.rs](https://docs.rs/libseccomp/badge.svg)](https://docs.rs/libseccomp)\n[![codecov](https://codecov.io/gh/libseccomp-rs/libseccomp-rs/branch/main/graph/badge.svg)](https://codecov.io/gh/libseccomp-rs/libseccomp-rs)\n[![MSRV: 1.63](https://img.shields.io/badge/MSRV-1.63-informational)](https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html)\n\nRust Language Bindings for the libseccomp Library\n\nThe libseccomp library provides an easy to use, platform independent, interface to\nthe Linux Kernel's syscall filtering mechanism. The libseccomp API is designed to\nabstract away the underlying BPF based syscall filter language and present a more\nconventional function-call based filtering interface that should be familiar to, and\neasily adopted by, application developers.\n\nThe libseccomp-rs provides a Rust based interface to the libseccomp library.\nThis repository contains libseccomp and libseccomp-sys crates that enable developers\nto use the libseccomp API in Rust.\n\n* **libseccomp**: High-level safe API\n* **libseccomp-sys**: Low-level unsafe API\n\n[CHANGELOG](https://github.com/libseccomp-rs/libseccomp-rs/blob/main/CHANGELOG.md)\n\n## Example\n\nCreate and load a single seccomp rule:\n\n```rust\nuse libseccomp::*;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Creates and returns a new filter context.\n    let mut filter = ScmpFilterContext::new(ScmpAction::Allow)?;\n\n    // Adds an architecture to the filter.\n    filter.add_arch(ScmpArch::X8664)?;\n\n    // Returns the number of a syscall by name.\n    let syscall = ScmpSyscall::from_name(\"dup3\")?;\n\n    // Adds a single rule for an unconditional action on the syscall.\n    filter.add_rule(ScmpAction::Errno(10), syscall)?;\n\n    // Loads the filter context into the kernel.\n    filter.load()?;\n\n    // The syscall fails by the seccomp rule.\n    assert_eq!(unsafe { libc::dup3(0, 100, libc::O_CLOEXEC) }, -libc::EPERM);\n    // The errno is the number specified by the seccomp action.\n    assert_eq!(std::io::Error::last_os_error().raw_os_error().unwrap(), 10);\n\n    Ok(())\n}\n```\n\n## Requirements\nBefore using the libseccomp crate, you need to install the libseccomp library for your system.\nThe libseccomp library version 2.5.0 or newer is required.\n\n### Installing the libseccomp library from a package\n\ne.g. Debian-based Linux\n\n``` sh\n$ sudo apt install libseccomp-dev\n```\n\n### Building and installing the libseccomp library from sources\nIf you want to build the libseccomp library from an official release tarball instead of the package,\nyou should follow the quick step.\n\n```sh\n$ LIBSECCOMP_VERSION=2.5.3\n$ wget https://github.com/seccomp/libseccomp/releases/download/v${LIBSECCOMP_VERSION}/libseccomp-${LIBSECCOMP_VERSION}.tar.gz\n$ tar xvf libseccomp-${LIBSECCOMP_VERSION}.tar.gz\n$ cd libseccomp-${LIBSECCOMP_VERSION}\n$ ./configure\n$ make\n$ sudo make install\n```\n\nFor more details, see the [libseccomp library repository](https://github.com/seccomp/libseccomp).\n\n## Setup\nIf you use the libseccomp crate with dynamically linked the libseccomp library,\nyou do not need additional settings.\n\nHowever, if you want to use the libseccomp crate against musl-libc with statically linked the libseccomp library,\nyou have to set the `LIBSECCOMP_LINK_TYPE` and `LIBSECCOMP_LIB_PATH` environment variables as follows.\n\n```sh\n$ export LIBSECCOMP_LINK_TYPE=static\n$ export LIBSECCOMP_LIB_PATH=\"the path of the directory containing libseccomp.a (e.g. /usr/lib)\"\n```\n\n\u003e **Note**:\n\u003e To build the libseccomp crate against musl-libc, you need to build the libseccomp library manually for musl-libc\n\u003e or use a musl-based distribution that provides a package for the statically-linked libseccomp library\n\nNow, add the following to your `Cargo.toml` to start building the libseccomp crate.\n\n```toml\n[dependencies]\nlibseccomp = \"0.3.0\"\n```\n\n## Minimum Supported Rust Version (MSRV) policy\n\nThe 0.3.x line has 1.46 as MSRV.\n\nStarting with 0.4.0, our MSRV will be increased when necessary or appropriate.\nHowever, it will never be increased to a version greater than the last stable rust version minus two.\n\nA MSRV change is not considered a breaking change.\n\n## Testing the crate\nThe libseccomp crate provides a number of unit tests.\nIf you want to run the standard regression tests, you can execute the following command.\n\n``` sh\n$ make test\n```\n\n## How to contribute\nAnyone is welcome to join and contribute code, documentation, and use cases.\n\nFor details on how to contribute to the libseccomp-rs project, please see the\n[contributing document](https://github.com/libseccomp-rs/libseccomp-rs/blob/main/CONTRIBUTING.md).\n\n## License\nThis crate is licensed under:\n\n- MIT License (see LICENSE-MIT); or\n- Apache 2.0 License (see LICENSE-APACHE),\n\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in libseccomp-rs by you, as defined in the Apache-2.0 license,\nshall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibseccomp-rs%2Flibseccomp-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibseccomp-rs%2Flibseccomp-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibseccomp-rs%2Flibseccomp-rs/lists"}