ebkalderon / bastille

Process sandboxing library written in Rust
Apache License 2.0
7 stars 0 forks source link

Define core features and platform-specific features #6

Open ebkalderon opened 4 years ago

ebkalderon commented 4 years ago

The current Sandbox API aims to provide a reduced subset of Bubblewrap functionality to multiple platforms, but the precise extent of this API and the definition of what constitutes an essential feature is not decided at the moment.

Core features

Ideally, the Bastille library should continue to model itself around Bubblewrap in terms of feature set while ensuring that this functionality is available on all platforms with as few platform-specific caveats as possible. At the time of writing, some features considered "essential" include:

As mentioned previously, this core feature list is not set in stone and may change over time.

Platform specific features

It is an open question whether we should expose platform-specific functionality in addition to the core platform-agnostic feature set described above, and if so, how to do so in an ergonomic way. Most likely, these extra features would be exposed as additional builder methods on Sandbox guarded by doc-cfg (works on stable Rust).

I believe that Bastille should take a similar approach to the Rust standard library, which is roughly the following:

  1. If a feature exists on all platforms in its full form, it is considered fully agnostic. It is exposed as a Sandbox method on all platforms.
  2. If a feature exists on all platforms but with limitations or different run-time guarantees, it is considered mostly agnostic. It is exposed as a Sandbox method on all platforms, with any platform-specific caveats recorded in the API documentation.
  3. If a feature exists only on some platforms with no reasonable equivalent, it is considered platform specific. It is exposed via a separate impl block or SandboxExt trait guarded by a #[cfg(platform)] attribute.

We should strive to maximize feature sets 1 and 2 as much as possible and only expose feature set 3 if the feature in question is supported by all first-class platforms (see PLATFORM.md). For example, mounting tmpfs filesystems is supported on all platforms except macOS, which is considered a second-class platform, so it is a good candidate for exposing as a platform-specific feature in the future. Other examples include user, PID, and network namespace separation, both of which are also supported on all platforms except for macOS (further investigation is still needed to verify this is the case).