https://github.com/dlrobertson/capsicum-rs Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + By Plan + Enterprise + Teams + Compare all + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} dlrobertson / capsicum-rs Public * Notifications * Fork 4 * Star 35 Rust bindings for the FreeBSD capsicum framework License MPL-2.0 license 35 stars 4 forks Star Notifications * Code * Issues 5 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights dlrobertson/capsicum-rs This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/d] Use Git or checkout with SVN using the web URL. [gh repo clone dlrobe] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP * Codespaces is rolling out You don't have access just yet, but in the meantime, you can learn about Codespaces Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @dlrobertson dlrobertson Merge pull request #7 from asomers/test-better ... 5ae555a Nov 8, 2022 Merge pull request #7 from asomers/test-better Improvements to the integration tests: 5ae555a Git stats * 22 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time src Fix doc tests Nov 7, 2022 tests Improvements to the integration tests: Nov 7, 2022 .gitignore Initial Commit Jun 11, 2016 Cargo.toml Improvements to the integration tests: Nov 7, 2022 LICENSE Initial commit Jun 11, 2016 README.md Restructure directory layout Jun 12, 2016 build.rs Initial Commit Jun 11, 2016 View code [ ] capsicum Contain the awesome! Prerequisites Getting Started Get the code Writing code using capsicum-rs Entering capability mode Limit capability rights to files README.md capsicum Current Version Contain the awesome! Rust bindings for the FreeBSD capsicum framework for OS capability and sandboxing Prerequisites Rust, Cargo, and FreeBSD. Note: This currently only compiles on FreeBSD Getting Started Get the code git clone https://github.com/danlrobertson/capsicum-rs cd capsicum-rs cargo build Writing code using capsicum-rs Entering capability mode use capsicum::{enter, sandboxed}; use std::fs::File; use std::io::Read; let mut ok_file = File::open("/tmp/foo").unwrap(); let mut s = String::new(); enter().expect("enter failed!"); assert!(sandboxed(), "application is not sandboxed!"); match File::create("/tmp/cant_touch_this") { Ok(_) => panic!("application is not properly sandboxed!"), Err(e) => println!("properly sandboxed: {:?}", e) } match ok_file.read_to_string(&mut s) { Ok(_) => println!("This is okay since we opened the descriptor before sandboxing"), Err(_) => panic!("application is not properly sandboxed!") } Limit capability rights to files use capsicum::{CapRights, Right, RightsBuilder}; use std::fs::File; use std::io::Read; let x = rand::random::(); let mut ok_file = File::open("/tmp/foo").unwrap(); let mut s = String::new(); let mut builder = RightsBuilder::new(Right::Seek); if x { builder.add(Right::Read); } let rights = builder.finalize().unwrap(); rights.limit(&ok_file).unwrap(); match ok_file.read_to_string(&mut s) { Ok(_) if x => println!("Allowed reading: x = {} ", x), Err(_) if !x => println!("Did not allow reading: x = {}", x), _ => panic!("Not properly sandboxed"), } About Rust bindings for the FreeBSD capsicum framework Topics rust freebsd capsicum Resources Readme License MPL-2.0 license Stars 35 stars Watchers 6 watching Forks 4 forks Releases No releases published Packages 0 No packages published Used by 2 * @cemeyer @cemeyer / ryzen_power Contributors 2 * @dlrobertson dlrobertson Dan Robertson * @asomers asomers Alan Somers Languages * Rust 100.0% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.