Class: LittleGhost::Sandboxes::Native
Overview
Selects the operating system's built-in LittleGhost isolation backend.
Selection fails closed on unsupported platforms and never falls back to
unrestricted host execution.
Instance Attribute Summary
#limits, #policy, #workspace
Class Method Summary
collapse
Instance Method Summary
collapse
#allows?, #execute, providers, register_provider, resolve_provider, #supports?, #writable?
Constructor Details
#initialize(workspace:, platform: RUBY_PLATFORM, **options) ⇒ Native
Selects Seatbelt on macOS or Bubblewrap on Linux and builds that backend
around workspace.
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/little_ghost/sandboxes/native.rb', line 24
def initialize(workspace:, platform: RUBY_PLATFORM, **options)
implementation = if platform.include?("darwin")
Seatbelt
elsif platform.include?("linux")
Bubblewrap
else
raise UnsupportedPlatformError, "native sandboxing is unavailable on #{platform}"
end
@backend = implementation.new(workspace:, platform:, **options)
super(workspace:, policy: @backend.policy, limits: @backend.limits)
end
|
Class Method Details
.probe(platform: RUBY_PLATFORM, **options) ⇒ Object
Reports whether the native backend for platform is available and
returns its capabilities.
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/little_ghost/sandboxes/native.rb', line 11
def self.probe(platform: RUBY_PLATFORM, **options)
implementation = if platform.include?("darwin")
Seatbelt
elsif platform.include?("linux")
Bubblewrap
else
return {available: false, reason: "native sandboxing is unavailable on #{platform}", capabilities: Capabilities.new(features: [], network_modes: [])}
end
implementation.probe(platform:, **options)
end
|
Instance Method Details
#capabilities ⇒ Object
37
|
# File 'lib/little_ghost/sandboxes/native.rb', line 37
def capabilities = @backend.capabilities
|
#close ⇒ Object
39
|
# File 'lib/little_ghost/sandboxes/native.rb', line 39
def close = @backend.close
|
#effective_policy ⇒ Object
36
|
# File 'lib/little_ghost/sandboxes/native.rb', line 36
def effective_policy = @backend.effective_policy
|
#execute_program ⇒ Object
44
|
# File 'lib/little_ghost/sandboxes/native.rb', line 44
def execute_program(...) = @backend.execute_program(...)
|
#list ⇒ Object
41
|
# File 'lib/little_ghost/sandboxes/native.rb', line 41
def list(...) = @backend.list(...)
|
#open(run: nil) ⇒ Object
38
|
# File 'lib/little_ghost/sandboxes/native.rb', line 38
def open(run: nil) = @backend.open(run:)
|
#read ⇒ Object
40
|
# File 'lib/little_ghost/sandboxes/native.rb', line 40
def read(...) = @backend.read(...)
|
#replace ⇒ Object
43
|
# File 'lib/little_ghost/sandboxes/native.rb', line 43
def replace(...) = @backend.replace(...)
|
#scope ⇒ Object
46
|
# File 'lib/little_ghost/sandboxes/native.rb', line 46
def scope(...) = @backend.scope(...)
|
#start_program ⇒ Object
45
|
# File 'lib/little_ghost/sandboxes/native.rb', line 45
def start_program(...) = @backend.start_program(...)
|
#write ⇒ Object
42
|
# File 'lib/little_ghost/sandboxes/native.rb', line 42
def write(...) = @backend.write(...)
|