perf(loki.secretfilter): Change secretfilter implementation to use Gitleaks#5503
Conversation
a7b3f0d to
9915b07
Compare
🔍 Dependency ReviewNo existing dependency versions were upgraded in this PR. The changes to go.mod files only add new (mostly indirect) dependencies and make one existing dependency (github.com/BurntSushi/toml v1.5.0) indirect in the root module without changing its version. Per the review rules, net‑new dependencies are not assessed for upgrade impact. Therefore, there are no upgrade-related code changes required for existing dependencies. 🗒️ Notes
If you intended to review upgrade impacts, please include diffs that change versions (old → new) for existing dependencies. |
This component experimental so it's fine to make breaking changes. But if you plan to add back a all of a sub-set of the config I feel like there must be a better solution. If we merge this and the follow up work is not finished until next release we would make a release with breaking changes and then potentially add them back in a later release. That don't feel great for people using it. As I said it's fine to make breaking changes but try to only do that if you have too. One option while not great is to keep the arguments for now and don't do anything. At least that won't break existing config even though the component internally have breaking changes |
kelnage
left a comment
There was a problem hiding this comment.
Lots of comments - keeping the ability to specify a customer Gitleaks config is the key change, and replacing the Redact function with one that supports more of the secretfilter's functionality would also be a good idea
Better to reimplement again all features to maintain feature parity than risk a broken release
…ilter-gitleaks-implementation' into kleimkuhler/secretfilter-gitleaks-implementation
|
💻 Deploy preview deleted (perf(loki.secretfilter): Change secretfilter implementation to use Gitleaks). |
kelnage
left a comment
There was a problem hiding this comment.
Much better! A couple of minor points, I also noticed there was also a large reduction in the size of the unit tests, but I also noted the total code coverage increased, so I don't believe this is an issue.
There was a problem hiding this comment.
Note for other reviewers: this file is no longer required as it will take the default configuration (if used) directly from the Gitleaks package - so updating the github.com/zricethezav/gitleaks/v8 dependency will automatically update the default config to the latest version.
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
…ter-gitleaks-implementation
clayton-cornell
left a comment
There was a problem hiding this comment.
Doc changes look OK to me
…tleaks (#5503) This PR refactors the `loki.secretfilter` component to use the [Gitleaks](https://github.com/gitleaks/gitleaks) library instead of a custom implementation. ### Changes - Replaced custom regex-based secret detection with Gitleaks' `detect.Detector` - **Arguments:** - Kept: - `forward_to` - `origin_label` - `gitleaks_config` (path to custom Gitleaks TOML) - `redact_with` (template with `$SECRET_NAME` / `$SECRET_HASH`) - Added: - `redact_percent` (1–100, default 80; Gitleaks-style partial redaction) - Removed: - `partial_mask` (replaced with `redact_percent`) - `allowlist` (controlled with custom gitleaks config) - `enable_entropy` (always enabled) - `include_generic` (controlled with custom gitleaks config) - `types` (controlled with custom gitleaks config) - **Redaction:** If `redact_with` is set, it is used as the placeholder; otherwise redaction is percentage-based via `redact_percent` (default 80%; 100% = full `"REDACTED"`) - **Metrics:** keeping `secrets_redacted_total`, `secrets_redacted_by_rule_total`, `secrets_redacted_by_origin` (when `origin_label` is set), `processing_duration_seconds`. Removed `secrets_allowlisted_total` and `secrets_skipped_entropy_by_rule_total` as they are not efficient to determine with new library. - **Docs:** Reference updated for the new arguments and metrics BREAKING-CHANGE: Some config options are removed entirely: - `partial_mask` (replaced with `redact_percent`) - `allowlist` (now controlled with custom gitleaks config) - `enable_entropy` - `include_generic` (now controlled with custom gitleaks config) - `types` (now controlled with custom gitleaks config)
This PR refactors the
loki.secretfiltercomponent to use the Gitleaks library instead of a custom implementation.Changes
detect.Detectorforward_toorigin_labelgitleaks_config(path to custom Gitleaks TOML)redact_with(template with$SECRET_NAME/$SECRET_HASH)redact_percent(1–100, default 80; Gitleaks-style partial redaction)partial_mask(replaced withredact_percent)allowlist(controlled with custom gitleaks config)enable_entropy(always enabled)include_generic(controlled with custom gitleaks config)types(controlled with custom gitleaks config)redact_withis set, it is used as the placeholder; otherwise redaction is percentage-based viaredact_percent(default 80%; 100% = full"REDACTED")secrets_redacted_total,secrets_redacted_by_rule_total,secrets_redacted_by_origin(whenorigin_labelis set),processing_duration_seconds. Removedsecrets_allowlisted_totalandsecrets_skipped_entropy_by_rule_totalas they are not efficient to determine with new library.BREAKING-CHANGE: Some config options are removed entirely:
partial_mask(replaced withredact_percent)allowlist(now controlled with custom gitleaks config)enable_entropyinclude_generic(now controlled with custom gitleaks config)types(now controlled with custom gitleaks config)BEGIN_COMMIT_OVERRIDE
feat(loki.secretfilter)!: Change secretfilter implementation to use Gitleaks (#5503)
BREAKING-CHANGE: Some config options are removed entirely:
partial_mask(replaced withredact_percent)allowlist(now controlled with custom gitleaks config)enable_entropyinclude_generic(now controlled with custom gitleaks config)types(now controlled with custom gitleaks config)END_COMMIT_OVERRIDE