feat: add secret redaction feature to replace sensitive values#14
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-out-by-default secret redaction layer so code hunks sent to Bucketeer don’t leak credential-like values, while keeping flag matching based on the original (unredacted) source lines.
Changes:
- Add a configurable redactor (built-in patterns + YAML extensibility) and apply it during hunk creation.
- Wire redaction into matcher construction via a new
--redactSecretsoption (defaulttrue) plus YAML fields for extra patterns/keywords. - Update docs/tests and include
.ldignorein ignore-file processing.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| search/search.go | Copies hunk lines before mutation and applies optional redaction before truncation/hash generation. |
| search/search_test.go | Updates expectations for hunks when context lines are disabled. |
| search/redact.go | Implements the redaction engine and built-in credential patterns. |
| search/redact_test.go | Adds unit/integration tests for redaction behavior and hunk redaction. |
| search/matcher.go | Instantiates the redactor based on options and attaches it to Matcher. |
| search/files.go | Adds .ldignore to the list of ignore files. |
| options/options.go | Adds redaction-related options and validates user-provided regex patterns. |
| options/flags.go | Introduces the --redactSecrets CLI flag (default true). |
| docs/CONFIGURATION.md | Documents secret redaction configuration and YAML extensions. |
| README.md | Adds a documentation link to the secret redaction section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@Ubisoft-potato, it will be safer and more stable to use OSS, which is focused on scanning sensitive info. Reference: While GitLeaks is more popular, Titus covers almost 3 times as much as GitLeaks, but it is still a bit new. |
|
This one is from the same author of GitLeaks. It's more accurate and faster.
Is also developed in Go. We can try it! |
21c653b to
dbf5485
Compare
The previous golangci-lint v1.62.2 was built with Go 1.23 and fails on the go 1.25.0 directive required by betterleaks. Migrate .golangci.yml to the v2 config format (dead linters dropped by the migration tool), keep gating parity by disabling linters introduced after v1.62 and restricting staticcheck to SA checks, and fix the one new prealloc finding.
62b269a to
db01487
Compare
The keyword-assignment regexes matched any [:=]+ run, so comparisons like `if authType == "OAuth2.0"` or `token == expectedToken123` were redacted. Spell the separator out as :=, =, or : and forbid a leading = in unquoted values so the tail of == never matches.
godoc was split out of x/tools into its own module and frozen as v0.1.0-deprecated. Inline its small IsText check instead.
An empty (or empty-matching, e.g. "a*") pattern inserts [REDACTED] between every character of every scanned line. Reject such patterns in both options validation and newRedactor, and document the 6-character floor for quoted keyword assignments.
What
Redacts secret-looking values from the code lines sent to Bucketeer, replacing them with
[REDACTED]so credentials near a flag reference don't leak into the dashboard or CSV output.How
--redactSecrets, defaulttrue); disable with--redactSecrets=falseorBUCKETEER_REDACT_SECRETS=false.github.com/zricethezav/gitleaks/v8, MIT), covering hundreds of vendor credential formats with entropy checks.Authorizationheader values, passwords in URLs (postgres://user:pass@host), and quoted or unquoted assignments to secret-keyword variables (apikey,secret,token,passwd,password,credential,auth). Unquoted values must be 12+ chars mixing letters and digits, so code likeapiKey := opts.APIKeystays untouched; this also covers~/.aws/credentials-style key pairs..bucketeer/coderefs.yaml:redactPatterns(extra regexes) andredactKeywords(extra variable-name keywords). Invalid patterns fail fast at startup.ContentHashconsistent; flag matching runs on the original lines.Also included
godirective bumped to 1.25.0; vendor tree updated.Example
Docs: Secret redaction.