loki.secretfilter: Change the way the secret is hashed #2529
+39
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
This PR changes the way the secret is hashed in the experimental component
loki.secretfilter
.In this context, the hash of the secret is used to be able to identify the redacted secret more easily, without revealing too much information about it in the logs. It's the reason why an algorithm with a shorter output was used (SHA1): it doesn't need to be collision resistant as it is used as an identifier for the redacted secret, not as a signature.
But I thought of a different approach to keep the hash relatively short: hash it with SHA256 and output only the first half of the hash. This approach should help keep the information about the secret minimal, while relying on a more recent hashing algorithm that is more likely to be available to someone investigating a leaked secret in their logs. I believe the first half of a SHA256 hash is unique enough to help identify the secret that leaked without ambiguity, and short enough not to add too much information about the underlying secret in the logs.
@kelnage happy to have your opinion on this!
Which issue(s) this PR fixes
Notes to the Reviewer
PR Checklist