Skip to content
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

configfile: Initialize nil AuthConfigs #4418

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

Danial-Gharib
Copy link
Contributor

@Danial-Gharib Danial-Gharib commented Jul 12, 2023

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@bsousaa
Copy link
Contributor

bsousaa commented Jul 13, 2023

Thank you for contributing! It appears your commit message is missing a DCO sign-off,
causing the DCO check to fail.

We require all commit messages to have a Signed-off-by line with your name
and e-mail (see "Sign your work"
in the CONTRIBUTING.md in this repository), which looks something like:

Signed-off-by: YourFirsName YourLastName <yourname@example.org>

There is no need to open a new pull request, but to fix this (and make CI pass),
you need to amend the commit(s) in this pull request, and "force push" the amended
commit.

Unfortunately, it's not possible to do so through GitHub's web UI, so this needs
to be done through the git commandline.

You can find some instructions in the output of the DCO check (which can be found
in the "checks" tab on this pull request), as well as in the Moby contributing guide.

Steps to do so "roughly" come down to:

  1. Set your name and e-mail in git's configuration:

    git config --global user.name "YourFirstName YourLastName"
    git config --global user.email "yourname@example.org"

    (Make sure to use your real name (not your GitHub username/handle) and e-mail)

  2. Clone your fork locally

  3. Check out the branch associated with this pull request

  4. Sign-off and amend the existing commit(s)

    git commit --amend --no-edit --signoff

    If your pull request contains multiple commits, either squash the commits (if
    needed) or sign-off each individual commit.

  5. Force push your branch to GitHub (using the --force or --force-with-lease flags) to update the pull request.

Sorry for the hassle (I wish GitHub would make this a bit easier to do), and let me know if you need help or more detailed instructions!

Copy link
Collaborator

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!
In addition to the missing DCO, I have one suggestion.

Comment on lines 56 to 58
if authConfigs == nil {
authConfigs = make(map[string]types.AuthConfig)
}
Copy link
Collaborator

@vvoland vvoland Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't save the auth in the ConfigFile because we create a completely new map here.

Instead of doing the nil check on caller side, we need to solve this issue in the GetAuthConfigs directly:

// GetAuthConfigs returns the mapping of repo to auth configuration
func (configFile *ConfigFile) GetAuthConfigs() map[string]types.AuthConfig {
return configFile.AuthConfigs
}

This way we also won't have to do the nil check in all the places GetAuthConfigs is called (there are currently no other places which break with nil value though).

@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2023

Codecov Report

Merging #4418 (9a4552d) into master (803d4a9) will increase coverage by 0.43%.
The diff coverage is 40.00%.

❗ Current head 9a4552d differs from pull request most recent head ad43df5. Consider uploading reports for the commit ad43df5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4418      +/-   ##
==========================================
+ Coverage   58.97%   59.40%   +0.43%     
==========================================
  Files         286      288       +2     
  Lines       24771    24780       +9     
==========================================
+ Hits        14608    14721     +113     
+ Misses       9276     9173     -103     
+ Partials      887      886       -1     

Initialize AuthConfigs map if it's nil before returning it.
This fixes fileStore.Store nil dereference panic when adding a new key
to the map.

Signed-off-by: Danial Gharib <danial.mail.gh@gmail.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the fix-issue-4414-Danial-Gharib branch from 9a4552d to ad43df5 Compare July 19, 2023 13:36
Copy link
Collaborator

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and applied my suggestion as we'd like to get this in for the next patch release.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

we should look at some of the follow-ups as well, but this fixes the immediate issue

@thaJeztah thaJeztah added this to the 25.0.0 milestone Jul 19, 2023
@thaJeztah thaJeztah merged commit 4f67ff8 into docker:master Jul 19, 2023
147 checks passed
@vvoland vvoland changed the title Fix nil pointer dereference issue (#4414) configfile: Initialize nil AuthConfigs Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nil pointer dereference on loading the config file
6 participants