Your own values, not lookalikes · Staged, tracked or in the history · Offline, never printed
Quick start · Git hooks · CI · Docker · Configuration · Changelog · Security
Illustrative: omerta names the variable, never the value.
Pattern scanners such as gitleaks and TruffleHog find what looks like a key; omerta finds your keys. It reads the values of your env files and fails when one is in git, as written or encoded in URLs, JSON and base64, so it catches secrets of any format: a small provider's key, a cloud bucket's name, an organisation ID. It runs entirely offline.
uvx omerta check --all # every tracked file
uvx omerta history # every commit, tag and message
uvx omerta docker # what your Dockerfiles' builds would copyuv brings its own Python; with pip, pip install omerta. Values that are not secrets, such as DB_HOST=localhost and DB_USER=postgres, are found too: leave them out in .omerta.toml:
ignore = ["DB_HOST", "DB_USER"]omerta check searches the staged changes. With pre-commit:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/shcherbak-ai/omerta
rev: v0.2.0
hooks:
- id: omertaThe hook runs on pre-commit's own Python, which must be 3.11 or later: install pre-commit with uv tool install pre-commit or Homebrew, not from Ubuntu 22.04's apt or into macOS's system Python.
If you give the hook args, end them with a double dash, as its own do. The staged files come after them, and a file named -h would otherwise be read as the option.
- id: omerta
args: [--json, --]Husky, Lefthook, a plain git hook, or omerta pinned in your lockfile
#!/bin/sh
# .husky/pre-commit, or .git/hooks/pre-commit (made executable)
uvx omerta@0.2.0 check# lefthook.yml
pre-commit:
commands:
omerta:
run: uvx omerta@0.2.0 checkIn a Python project, uv add --dev omerta, and a local pre-commit hook:
repos:
- repo: local
hooks:
- id: omerta
name: omerta
entry: uv run omerta check
args: [--]
language: system
types: []
types_or: [file, symlink]CI has no .env to take values from, so there omerta finds the env files that were committed:
# .github/workflows/omerta.yml
name: omerta
on: [push, pull_request]
permissions:
contents: read
jobs:
omerta:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # all of the history
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- run: uvx omerta@0.2.0 check --all
- run: uvx omerta@0.2.0 historyDocker reads .dockerignore, not .gitignore: without a line for it, COPY . . copies the .env that git ignores into the image. omerta docker fails when an env file is in the build context of a Dockerfile, matching .dockerignore as Docker's BuildKit does, whatever git makes of either: tracked, untracked or ignored. It needs no Docker and builds nothing.
$ omerta docker
.env: in the build context of Dockerfile
A Dockerfile (Dockerfile, Dockerfile.* or *.Dockerfile) is taken to be built from its own folder, as docker build . beside it builds it, and its own <name>.dockerignore comes before the folder's .dockerignore, as in Docker. For one built from another folder, name it:
# .omerta.toml
docker-contexts = { "docker/Dockerfile" = "." }As a pre-commit hook, beside omerta; it checks the whole repository at each commit:
hooks:
- id: omerta
- id: omerta-dockerA CI checkout has no .env until a job writes one: there, run uvx omerta@0.2.0 docker after writing it and before docker build.
omerta check # the staged changes, as git holds them
omerta check PATH # the tracked files at or under PATH
omerta check --all # every tracked file
omerta history # every file version and message reachable from a branch, a tag or HEAD
omerta docker # the env files in the build context of each Dockerfile- Values come from
.envand.env.*at the root that git does not track. Templates (*.example,*.sample,*.template) are skipped. - A tracked env file is a leak in itself.
- Each value is searched as written, percent-encoded, JSON-escaped and base64-encoded, in text, binary files and file names.
historyreports a value at the commit where it enters a file.- A rotated key is no longer in your
.env, sohistoryno longer looks for it. To find the old one, put it in another untracked env file, such as.env.old: findings then say(from .env.old). - Values under 8 characters (
true,5432) are skipped. For a shorter secret, lowermin-chars, andignorewhat then matches ordinary text.
src/client.py:12: OPENAI_API_KEY (from .env) # check
<commit> src/client.py: OPENAI_API_KEY (from .env) # history
<commit> (message): OPENAI_API_KEY (from .env) # a commit or tag message
infra/<BUCKET>.json (path): BUCKET (from .env) # a value in a name
.env.production: tracked env file
.env: in the build context of Dockerfile # docker
A value is never printed: in a name, its variable stands in its place. The exit code is 0 when nothing is found, 1 when something is, and 2 on an error. --json writes JSON Lines, with the form each value was found in.
Settings go in .omerta.toml at the root of the repository, or in [tool.omerta] of pyproject.toml:
# .omerta.toml
env-files = [".env.local", ".env.*.local"]
ignore = ["DB_HOST", "DB_USER"]Each setting has an option, which overrides it for one run, except --ignore, which adds to it. -C PATH goes before the command, as in git:
omerta check --all --ignore DB_HOST --ignore DB_USER
omerta -C ../api history --env-file .env.local --json| Option | Setting and default | What it does |
|---|---|---|
--env-file PATTERN |
env-files = [".env", ".env.*"] |
The env files to take values from |
--ignore NAME |
ignore = [] |
Variables not searched for |
--min-chars N |
min-chars = 8 |
The shortest value searched for |
--encoded,--no-encoded |
encoded = true |
Also search URL, JSON and base64 forms |
docker-contexts = {} |
Dockerfiles built from another folder than their own | |
--json |
Findings as JSON Lines | |
-q, --quiet |
Only the exit code and errors | |
-C PATH |
Run as if started in PATH |
--env-file and --ignore can be given more than once. Patterns are relative to the root of the repository, and ** matches any folders.
A project that commits an env file on purpose (Symfony's .env, Vite's .env.production, dotenvx) lists in env-files only those that hold its secrets, as in the example above.
- git 2.31 or later on
PATH, and 2.45 in a partial clone, the first that can be kept from fetching. A CI container whose user does not own the checkout needsgit config --global --add safe.directory "$PWD". - Python 3.11 or later, which
uvxbrings along. On Windows on ARM, use an x64 Python: hyperscan, which omerta searches with, has no wheels for Windows on ARM. - Security: its two dependencies are pinned to exact versions, and git is run by its absolute path, never from inside the repository it checks, and is never given a value on its command line. See SECURITY.md.
| Structured extraction from documents with LLMs. | |
| License compatibility checks for dependency trees, fast enough for CI. | |
| Runtime network egress control for Python. |
Questions or collaboration ideas? Reach out on LinkedIn or X. Built with ❤️ in Oslo, Norway.