-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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"?
? |
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.
Sorry for letting this languish.
I think the test's error message is backwards.
With that changed, this just needs a rebase and sign-off (git commit -s
).
rebase steps
Just adding a note here in case you're unfamiliar with a rebase workflow.
Conceptually, you're just taking your commits and applying the diff to the current main
instead of where they were originally committed.
Assuming origin
is the quay/claircore
repo, and fork
is your fork:
git checkout BRANCH_NAME
git fetch origin
git rebase origin/main
git push --force-with-lease fork
If you get a merge conflict in the rebase
step, just replace the conflict block with the code you think should be there. If something's wrong, we'll catch it. If it's for an autogenerated file like go.sum
, just recreate it.
If we asked you to change a commit message, add the -i
flag to the rebase
command and use the reword
command.
t.Error("signer initialization with empty config should succeed") | ||
} | ||
if signer.use != nil { | ||
t.Error("signed request authority map should be non-initialized") |
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.
t.Error("signed request authority map should be non-initialized") | |
t.Error("signed request authority map should be initialized") |
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