class LittleGhost::Sandbox::Limits
Bounded file and process output sizes applied by Sandbox tools.
Attributes
Maximum entries returned by one directory listing.
Maximum bytes captured from each child output stream.
Maximum bytes returned by one filesystem read.
Maximum bytes accepted by one filesystem write.
Public Class Methods
Source
# File lib/little_ghost/sandbox/limits.rb, line 15 def self.coerce(value) return value if value.is_a?(self) raise PolicyError, "sandbox limits must be a Hash" unless value.respond_to?(:to_h) new(**value.to_h.transform_keys(&:to_sym)) end
Returns value unchanged or builds limits from a Hash.
Source
# File lib/little_ghost/sandbox/limits.rb, line 23 def initialize(**values) unknown = values.keys - DEFAULTS.keys raise PolicyError, "unknown sandbox limits: #{unknown.join(", ")}" unless unknown.empty? DEFAULTS.merge(values).each do |name, value| value = Integer(value) raise PolicyError, "sandbox #{name} must be positive" unless value.positive? instance_variable_set("@#{name}", value) rescue ArgumentError, TypeError raise PolicyError, "sandbox #{name} must be an integer" end freeze end
Builds positive file and process output limits.