-
-
Notifications
You must be signed in to change notification settings - Fork 843
[client] Shorten peer public key in connection logs #4283
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,5 @@ | ||||||||||||||
package peer | ||||||||||||||
|
||||||||||||||
func shortenKey(pubKey string) string { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function doesn't handle cases where the input string is shorter than 7 characters, which will cause a runtime panic. Add a length check:
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to make it wrapped ( As an example I currently have a general Base64 regex of length 44 that occasionally even matches file paths with specific lengths due to large scope of Base64 character set:
This is not much of an issue for 44 characters that consist a WireGuard Public Key, but will very likely return too much false positives for just a 7 character key. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's at least make it clear in the function's documentation that this is meant to be wrapped if it were to be used anywhere else There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about we shorten it the way I do my markdown notes? A few leading characters, some form of ellipsis and a few trailing characters:
would be both readable, easy to identify explicitly and search for PS: I just put triple dots there, but we could use UTF ellipsis https://www.compart.com/en/unicode/U+2026 |
||||||||||||||
return pubKey[:7] | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The magic number 7 is hardcoded without explanation. Consider adding a named constant like
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function lacks documentation explaining its purpose, parameters, and behavior. Add a comment describing that it returns the first 7 characters of a public key for logging purposes.
Copilot uses AI. Check for mistakes.