class LittleGhost::Sandbox::Capabilities
Describes the operations, network modes, and isolation mechanism a Sandbox backend implements. process_spawn permits child creation, process_spawn_denial means the backend can prohibit it for one session, and process_tree_ownership means descendants remain owned through cleanup. Capabilities are immutable and safe to expose to tools, but are not a security certification of the surrounding deployment.
Attributes
Operation names implemented by the backend.
Descriptive isolation mechanism, such as :none or :container.
Network modes the backend can enforce.
Public Class Methods
# File lib/little_ghost/sandbox/capabilities.rb, line 28 def initialize(features: DEFAULT_FEATURES, network_modes: [:inherit], isolation: :none) @features = Array(features).map(&:to_sym).uniq.freeze @network_modes = Array(network_modes).map(&:to_sym).uniq.freeze invalid_modes = @network_modes - NETWORK_MODES raise ArgumentError, "unsupported network modes: #{invalid_modes.to_a.join(", ")}" unless invalid_modes.empty? @isolation = isolation.to_sym freeze end
Builds a capability report from feature names and supported network modes. isolation is descriptive and does not itself grant an operation or establish a complete trust boundary.
Public Instance Methods
Source
# File lib/little_ghost/sandbox/capabilities.rb, line 59 def intersect(other) self.class.new( features: features & other.features, network_modes: network_modes & other.network_modes, isolation: ) end
Produces a capability set no broader than both operands.
# File lib/little_ghost/sandbox/capabilities.rb, line 47 def supports?(feature, value = nil) feature = self.class.normalize(feature) return network_modes.include?(value.to_sym) if feature == :network && value return !network_modes.empty? if feature == :network features.include?(feature) end
Indicates whether feature is available. For :network, value selects the requested mode.