Text-Redact-Secrets
Find secrets in text by gitleaks' rules, and redact them.
Text that might hold a secret, such as a dump written to a log, should
be safe to write. Text::Redact::Secrets puts *REDACTED* in place of
each secret it finds in a string, with redact, or reports each, with
find, by the rules of gitleaks:
a maintained set of regexes, keywords, entropies and allowlists,
carried over from gitleaks unchanged. Beside them are rules of its
own, for secrets gitleaks has no rule for, such as a password in a
URL like postgres://user:password@host/db.
use Text::Redact::Secrets qw(find redact);
# The text with each secret in it replaced by *REDACTED*.
print {$log} redact($text);
# Each secret in the text, with the rule that found it.
for my $found (find($text)) {
say "$found->{rule} at $found->{offset}";
}
Installing
From CPAN:
cpanm Text::Redact::Secrets
Or the latest from GitHub:
cpanm https://github.com/nukopian/Text-Redact-Secrets.git
It needs Perl 5.36 or later, and nothing beyond its core modules.
Licence
Copyright (c) 2026 by Iain Campbell. This is free software; you can
redistribute it and/or modify it under the same terms as the Perl 5
programming language system itself, except for gitleaks' rules, which
are under gitleaks' MIT licence, in LICENSE-gitleaks. See the file
LICENSE.
Acknowledgements
Designed and created by Iain Campbell, in collaboration with Claude, Anthropic's AI model. The rules for finding secrets are gitleaks', by Zachary Rice and its contributors, but for the module's own, which are Iain's and Claude's.