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

dockerfile/parse: Fix nil dereference of a linter #4984

Closed
wants to merge 1 commit into from

Conversation

vvoland
Copy link
Collaborator

@vvoland vvoland commented Jun 3, 2024

Fix a nil dereference panic happening when parsing ENV and LABEL commands without a linter introduced by 6cfa459.

Signed-off-by: Paweł Gronowski pawel.gronowski@docker.com

Fix a nil dereference panic happening when parsing `ENV` and `LABEL`
commands without a linter introduced by
6cfa459.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@@ -209,7 +209,7 @@ func parseKvps(args []string, cmdName string, location []parser.Range, lint *lin
return nil, errBlankCommandNames(cmdName)
}
name, value, sep := args[j], args[j+1], args[j+2]
if sep == "" {
if lint != nil && sep == "" {
msg := linter.RuleLegacyKeyValueFormat.Format(cmdName)
lint.Run(&linter.RuleLegacyKeyValueFormat, location, msg)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe safer to do this check in the lint.Run() method, but that can be future follow-up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably find a way to make it so calling linter methods is always valid. I think this is good to just take care of the current issue though.

@@ -209,7 +209,7 @@ func parseKvps(args []string, cmdName string, location []parser.Range, lint *lin
return nil, errBlankCommandNames(cmdName)
}
name, value, sep := args[j], args[j+1], args[j+2]
if sep == "" {
if lint != nil && sep == "" {
msg := linter.RuleLegacyKeyValueFormat.Format(cmdName)
lint.Run(&linter.RuleLegacyKeyValueFormat, location, msg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably find a way to make it so calling linter methods is always valid. I think this is good to just take care of the current issue though.

vvoland added a commit to vvoland/moby that referenced this pull request Jun 4, 2024
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@tonistiigi tonistiigi closed this Jun 5, 2024
@thompson-shaun thompson-shaun removed this from the v0.14.0 milestone Jun 5, 2024
@thompson-shaun
Copy link
Collaborator

Replaced by #4996

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.

5 participants