Socket
Book a DemoInstallSign in
Socket

trapdoor

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trapdoor

0.4.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

trapdoor

trapdoor monkeypatches ENV so any secret values are available when asked for by name (i.e. ENV['SOME_SECRET']) but are hidden when requested in bulk (i.e. ENV.to_h, ENV.inspect, iterators). This was designed to be a drop in replacement for codebases that use ENV to hold secrets but also use developer tools that may cause these values to be accidentally logged.

Installation

  • Add to your Gemfile and install with bundle, or gem install trapdoor
  • require 'trapdoor'

Walkthrough

Let's start by inspecting the environment in the repl. We can see SECRET_API_TOKEN and its value.

> ENV
 => {... "SECRET_API_TOKEN"=>"987tfghjo0987yt"}

After loading trapdoor, let's tell it to hide this specific value then inspect the environment again.

> ENV.hide "SECRET_API_TOKEN"
> ENV
 => {... "SECRET_API_TOKEN"=>"**REDACTED**"}

But we can see this value can still be accessed just like before:

 > ENV['SECRET_API_TOKEN']
 => "987tfghjo0987yt"

Additionally, we can call ENV.start_smuggling to start redacting all new environment variables. This can be useful if you insert sensitive variables into the environment afterwards so that any non-pre loaded values are redacted.

FAQs

Package last updated on 22 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.