百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

hoosegow

> 编程语言
开源

用于运行不受信任的 Ruby 代码的临时 Docker 监狱

348 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

用于运行不受信任的 Ruby 代码的临时 Docker 监狱

Hoosegow

Ephemeral Docker jails for running untrusted Ruby code.

Hoosegow runs both in your code and in a Docker container. When you call a method on a Hoosegow instance, it proxies the method call to another instance of Hoosegow running inside a Docker container.

Security

Hoosegow is intended to add a layer of security to projects that need to run code that is not fully trusted/audited. Because the untrusted code is running inside a Docker container, an attacker who manages to exploit a vulnerability in the code must also break out of the Docker container before gaining any access to the host system.

This means that Hoosegow is only as strong as Docker. Docker employs Kernel namespaces, capabilities, and cgroups to contain processes running inside a container. This is not true virtualization though, and a process running as root inside the container can compromise the host system. Any privilege escalation bugs in the host Kernel could also be used to become root and compromise the host machine. Further hardening of the base Ubuntu image, along with tools like AppArmor or SE-Linux can improve the security posture of an application relying on Hoosegow/Docker.

The following are some useful resources regarding the security of Docker:

  • The Docker Security article from Docker.io.
  • The LXC, Docker, Security slides from Jérôme Petazzoni.
  • The series of Docker security articles from Daniel J. Walsh (one, two).

Installing

Gems are available from the releases page. Download a gem to your app's vendor/cache directory, and add this to your Gemfile:

gem "hoosegow"

Defining Methods to Proxy

You need to define the methods you want to have run in the Docker container. To do this, you need to create a inmate.rb file that defines a Hoosegow::Inmate module. Any methods on this module will be available on Hoosegow instances and will be proxied to the Docker container. Here is an example inmate.rb file:

ruby
class Hoosegow
  module Inmate
    def reverse(input)
      input.reverse
    end
  end
end

The inmate.rb file should be in its own folder, with an optional Gemfile to specify dependencies. This directory will be copied to the Docker container at build time so your methods are available to be proxied to. You specify the location of the directory containing the inmate.rb file when instantiating a Hoosegow object:

ruby
hoosegow = Hoosegow.new :inmate_dir => File.join(RAILS_ROOT, "hoosegow_deps")
hoosegow.reverse "foobar"
#=> "raboof"

Building the Docker Image

Before you can start using Hoosegow, you need to build the Docker image that Hoosegow will proxy method calls to. This can be done in a rake task or bootstrap script:

ruby
hoosegow = Hoosegow.new :inmate_dir => File.join(RAILS_ROOT, "hoosegow_deps")
hoosegow.build_image
hoosegow.image_name
#=> "hoosegow:2f8f155e72828ddab9bd8bd0e355c47fb01a5323"

The image will need to be rebuilt with any changes to Hoosegow or the inmate.rb file. If the image is built ahead of time (by a rake task or bootstrap script), you can pass the name of the image to use when instantiating a Hoosegow instance:

ruby
ENV['HOOSEGOW_IMAGE']
#=> "hoosegow:2f8f155e72828ddab9bd8bd0e355c47fb01a5323"
hoosegow = Hoosegow.new :inmate_dir => File.join(RAILS_ROOT, "hoosegow_deps")
                        :image_name => ENV['HOOSEGOW_IMAGE']

Configuring the Connection to Docker

By default Docker's API listens locally on a Unix socket. If you are running Docker with it's default configuration, you don't need to worry about configuring Hoosegow.

Configure Hoosegow to connect to a non-standard Unix socket.

ruby
Hoosegow.new :socket => '/path/to/socket'

Configure Hoosegow to connect to a Docker daemon running on another computer.

ruby
Hoosegow.new :host => '192.168.1.192', :port => 4243

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言