-
Notifications
You must be signed in to change notification settings - Fork 93
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
fix: replace api key with SendKey before transmission #1404
base: main
Are you sure you want to change the base?
Conversation
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.
Looks good. Left some suggestions to improve clarity and add return error to IsAccepted
if a.AcceptOnlyListedKeys && !slices.Contains(a.ReceiveKeys, apiKey) { | ||
err := fmt.Errorf("api key %s not found in list of authorized keys", a.sanitize(apiKey)) | ||
return "", err | ||
func (a *AccessKeyConfig) IsAccepted(key string) bool { |
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.
I think this could be a little clearer, maybe something like IsValid
instead? We should add a function description too as it's public function.
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.
Also, we create similar errors when this returns false so we could update this func to return the error and check if it's nil when calling it.
SendKeyMode: tt.fields.SendKeyMode, | ||
AcceptOnlyListedKeys: tt.fields.AcceptOnlyListedKeys, | ||
} | ||
if got := a.IsAccepted(tt.key); got != tt.want { |
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.
This isn't very clear, let's separate it out a little:
if got := a.IsAccepted(tt.key); got != tt.want { | |
got := a.IsAccepted(tt.key) | |
if got != tt.want { |
@@ -13,7 +13,7 @@ import ( | |||
|
|||
// for generating request IDs | |||
func init() { | |||
rand.Seed(time.Now().UnixNano()) | |||
rand.New(rand.NewSource(time.Now().UnixNano())) |
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.
What's the change for?
Which problem is this PR solving?
Replacing API key with the configured SendKey in the router causes peer communication to fail due to api key validation on both peer and incoming traffic.
To resolve this issue, this PR adjusts the replacement logic to occur immediately before transmission.
Short description of the changes
sendTraces