Generic Sandbox worker

The generic sandbox worker that launches the executable given in its config with the provided arguments when a message or event is received.

Configuration options

class vxsandbox.worker.SandboxConfig(config_data, static=False)[source]

Configuration options:

Parameters:
  • amqp_prefetch_count (int) – The number of messages fetched concurrently from each AMQP queue by each worker instance.
  • transport_name (str) – The name this application instance will use to create its queues.
  • send_to (dict) – ‘send_to’ configuration dict.
  • sandbox (dict) – Dictionary of resources to provide to the sandbox. Keys are the names of resources (as seen inside the sandbox). Values are dictionaries which must contain a cls key that gives the full name of the class that provides the resource. Other keys are additional configuration for that resource.
  • executable (str) – Full path to the executable to run in the sandbox.
  • args (list) – List of arguments to pass to the executable (not including the path of the executable itself).
  • path (str) – Current working directory to run the executable in.
  • env (dict) – Custom environment variables for the sandboxed process.
  • timeout (int) – Length of time the subprocess is given to process a message.
  • recv_limit (int) – Maximum number of bytes that will be read from a sandboxed process’ stdout and stderr combined.
  • rlimits (dict) – Dictionary of resource limits to be applied to sandboxed processes. Defaults are fairly restricted. Keys maybe names or values of the RLIMIT constants in Python resource module. Values should be appropriate integers.
  • logging_resource (str) – Name of the logging resource to use to report errors detected in sandboxed code (e.g. lines written to stderr, unexpected process termination). Set to null to disable and report these directly using Twisted logging instead.
  • sandbox_id (str) – This is set based on individual messages.

Worker class

class vxsandbox.worker.Sandbox(options, config=None)[source]

Sandbox application worker.

CONFIG_CLASS

alias of SandboxConfig

sandbox_id_for_message(msg_or_event)[source]

Return a sandbox id for a message or event.

This implementation simply returns msg_or_event['sandbox_id']. Sub-classes may override this to retrieve a more appropriate id.

sandbox_protocol_for_message(msg_or_event, config)[source]

Return a sandbox protocol for a message or event.

This implementation ignores msg_or_event and returns a sandbox protocol based on the given config. Sub-classes may override this to retrieve a custom protocol if needed.