-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] What does "hashed_secrets" stands for in the output? #175
Comments
I agree it is one of the more confusing things in the codebase, Succinctly it is the
It does not include line number of the secret, since that would cause the hash to change all the time. The way
|
'hashed_secret': self.secret_hash, |
->
self.secret_hash = self.hash_secret(secret) |
->
detect-secrets/detect_secrets/core/potential_secret.py
Lines 56 to 63 in 38b559c
def hash_secret(secret): | |
"""This offers a way to coherently test this class, | |
without mocking self.secret_hash. | |
:type secret: string | |
:rtype: string | |
""" | |
return hashlib.sha1(secret.encode('utf-8')).hexdigest() |
->
detect-secrets/detect_secrets/core/potential_secret.py
Lines 88 to 94 in 38b559c
def __hash__(self): | |
return hash( | |
tuple( | |
getattr(self, x) | |
for x in self.fields_to_compare | |
), | |
) |
->
self.fields_to_compare = ['filename', 'secret_hash', 'type'] |
This fields_to_compare
part is especially important, e.g. one time we changed a secret type and it broke all the baselines 😁
Something we definitely didn't want to happen is create a file with all secrets from a repository extracted. This way, you wouldn't be able to share these baselines around, because you'd be just contributing to the problem (secrets in source code). The |
Thank you for your answers! |
There is no documentation about this and the name is not really self-explanatory.
The text was updated successfully, but these errors were encountered: