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
httputil: work around NPE in signer.Add() #1999
base: main
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
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.
Ah, good catch.
I'd prefer if the conditional were the other way, to keep it consistent with the other checks in that function. With that change, LGTM
@hdonnay Hello, could you please clarify about "conditionals being other way"?
? |
If
auth
section is empty in config file, instance ofSigner
is initialized with default field values:https://github.com/quay/clair/blob/v4.7.3/internal/httputil/signer.go#L29
Later e.g. in
report
command processing if configuration is used, methodAdd
is used as "marks the authority in uri as one that expects signed requests":https://github.com/quay/clair/blob/v4.7.3/cmd/clairctl/report.go#L145
In this method an entry is being added to
use
field ofsigner
receiver no matter what. But ifauth
section was missing in config,use
has default value of nil and producesassignment to entry in nil map
.This patch fixes internal logic, but I decided to keep URI parsing before actually checking for nil to give faster feedback to user if uri is e.g. malformed. Feel free to suggest change in such a flow.
Method
Add
is called from multiple commands, so I changed it inside the method, not pre-checking the calls.Other
Signer
fields seem to be safe (ranging overnil
map is ok).There is no test file for signer,
so I did not create a new test caseI added one