-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add .toString() methods on all private classes #104
Comments
Hey Jonas! Can you provide more info to solve? Is it in specific section of code? |
Agree on the part - "user doesn't need to know about imo providing the key with the hash function would be a pretty bad idea (option 1) over concerns of inspection at runtime by malicious actors. I am yet to find credible evidence of cases where the knowledge of the hash function alone, by Eve could be an issue. Even if we double down on option 2, the output that the user will see is I would like to avoid this for two reasons:
I agree on the solution |
Hey @devenderbutani21 this is a WIP, can you please select other open issues, would be happy to assist you in one. Thanks a lot. For context of this issue please check the following gist - https://gist.github.com/HamdaanAliQuatil/bd32945af3091ff7ba72071386ff4de7 |
@HamdaanAliQuatil Should I work on #105 this issue? |
Yes, that'd be great. Tysm for contributing 🚀 |
@devenderbutani21 Feel free to ping me I'm jonasfj88 on discord, see |
The hash function isn't exactly secret, and we anyone who can do runtime inspection has probably won. Like that's exactly what we're trying to protect against. More like we attempt to protect against mistakes. |
It's sad when
print(HmacSecretKey.generateKey(Hash.sha256))
showsInstance of '_HmacSecretKey'
.Perhaps we should override the
toString()
method on all the private classes.The user doesn't need to know about
_HmacSecretKey
, since it's a private class.And we could probably display something more useful for debugging purposes.
I haven't figured this out yet, but we could do something like:
HmacSecretKey(hash: Hash.sha256, key: ***)
HmacSecretKey(Hash.sha256)
Instance of 'HmacSecretKey with Hash.sha256'
Instance of 'HmacSecretKey'
HmacSecretKey with sha256
It could be useful if print was helpful when debugging stuff :D
On the flip side, the
HmacSecretKey
doesn't have ahash
property, so if you have an instance ofHmacSecretKey
and you want to know what hash it uses, the only thing you can do is:HmacSecretKey.toString().contains('sha256')
, if we added a fancy variant oftoString()
.I imagine that we'd prefer to avoid using doing (b). Not necessarily be adding a
hash
property they don't need, but by forcing them to do (a) 🤣I think the point I'm trying to make is that, if we add to much information in
toString()
, then maybe people will use to inspect an object at runtime and rely on the behavior oftoString()
.And I don't think we want people to rely on the behavior of
toString()
.So maybe it's safest to just do:
macSecretKey.generateKey(Hash.sha256).toString() == "Instance of 'HmacSecretKey'"
It's boring, it's simple, but it doesn't leak any information that could lure a user into misusing
toString()
.I could ofcourse be convinced otherwise.
The text was updated successfully, but these errors were encountered: