DEV Community

PRATYAY MUSTAFI
PRATYAY MUSTAFI

Posted on Originally published at Medium on

Ensor: A Fast, Interactive CLI for Detecting and Redacting Secrets from Codebase

Ensor: A Fast, Interactive CLI for Detecting and Redacting Secrets from Codebase
Ensor: A Fast, Interactive CLI for Detecting and Redacting Secrets from Codebase

The Problem with Hardcoded Secrets

We’ve all been there accidentally committing an API key, token, or credential into a repo. It’s one of the most common yet dangerous mistakes developers make. Secrets exposed in code can lead to data breaches, unauthorized access, and significant security incidents.

Ensor is a lightweight, easy to use CLI tool designed to automatically censor hard coded secrets from your codebase with proper reference management, It bridges a critical gap between secret detection and secret managers.

What Makes Ensor Different?

Ensor is powered by the robust scanning backend of betterleaks/gitleaks , two well established tools in the security community. Currently, it operates on files to catch potential leaks before they become permanent fixtures in your repository history.

Intelligent Environment Variable Mapping

If you have a .env file with valid KEY=VALUE pairs, Ensor automatically finds those values scattered throughout your codebase and replaces them with their respective KEY references. This means instead of having api_key="sk-abc123xyz hardcoded in your source files, Ensor transforms it into api_key = process.env.API_KEY or your language’s equivalent — keeping your secrets secure.

Interactive Codebase Censoring

Ensor doesn’t just blindly replace secrets. When it detects raw secrets, it either auto suggests a randomized name or interactively prompts the user for a custom SECRET_NAME to replace the hard coded value. This gives full control over how secrets are managed while maintaining code readability.

yolo

Interactive mode feels slow? ensor also covers you, by running

ensor --yolo
or 
ensor -y
Enter fullscreen mode Exit fullscreen mode

Ensor automatically replaces secrets with their respective references .

Conversion among Secret Files

Need to convert .env files into different formats? Ensor also covers you. Using

ensor convert
Enter fullscreen mode Exit fullscreen mode

You can seamlessly translate environment files between dotenv, YAML, TOML, and JSON formats interchangeably. No more manual conversion.

Installation

Ensor is available through multiple package managers, making it easy to get started regardless of your Operating system.

Homebrew


brew trust — cask pratyay360/tap/ensor
brew install pratyay360/tap/ensor
Enter fullscreen mode Exit fullscreen mode

Mise


mise use github:pratyay360/ensor@latest
Enter fullscreen mode Exit fullscreen mode

Scoop (Windows)


scoop bucket add pratyay360 https://github.com/pratyay360/scoop-bucket
scoop install pratyay360/ensor
Enter fullscreen mode Exit fullscreen mode

cURL (Automated Install Script)


curl -sSL https://raw.githubusercontent.com/Pratyay360/ensor/main/install.sh | sh

or, 

curl -sf http://goblin.run/github.com/pratyay360/ensor | PREFIX=~/.local/bin sh

Enter fullscreen mode Exit fullscreen mode

Go Install


go install github.com/Pratyay360/ensor@latest

Enter fullscreen mode Exit fullscreen mode

Prebuilt binaries and packages ( .deb , .rpm , .apk) are also available for Linux, macOS, Windows, and FreeBSD on the Releases page.

Final Thoughts

Ensor is going to be a valuable addition to your current workflow. It’s fast, interactive, and designed with real world workflows in mind. Whether working on a small side project or a large production codebase, Ensor ensures that secrets stay secret.

Repository: https://github.com/pratyay360/ensor

GitHub - Pratyay360/ensor: A fast, interactive CLI for finding and redacting secrets from codebase.


Top comments (0)