Secrets filter leaves the tail of a secret when another secret is its prefix

Open Beginner friendly
#18 0 comments 0 reactions 0 assignees View on GitHub

@RaphaelFakhri is already working on this.

Since Nov 4, 2026.

  • #19 by @RaphaelFakhri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ruby
Domain
security

Research direction

Start by locating Lemans::SecretsFilter and its tests, then read how it builds the Regexp.union from secret values. Add coverage for a shorter secret that prefixes a longer one, including the stated expected output, and run the focused filter tests. Done means the full longer value is redacted regardless of secret order.

Written by the indexing model from the issue text.

Description

Lemans::SecretsFilter builds one Regexp.union over the secret values in the order ENV lists them. Regexp alternation takes the first alternative that matches at a position, so when one secret is a prefix of another, a shorter secret listed first wins. Only the shared prefix is redacted, and the rest of the longer secret is written to result.json and the run artifacts.

Reproduce

filter = Lemans::SecretsFilter.new([ "tok-0123456789", "tok-0123456789-extended-secret" ])
filter.filter("a=tok-0123456789-extended-secret")
# => "a=<filtered>-extended-secret"

Expected

# => "a=<filtered>"

This happens with SecretsFilter.default whenever two *_KEY/*_TOKEN/*_SECRET/*_JWT variables hold values where one starts with the other, and the shorter one comes first in ENV.

Dominant language
Ruby
Stars
99
Forks
11
Avg merge
3d 9h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/lemans

All issues in rails/lemans

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.