-
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
dockerfile/parse: Fix nil dereference of a linter #4984
Conversation
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) |
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.
Maybe safer to do this check in the lint.Run()
method, but that can be future follow-up.
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.
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) |
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.
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.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Replaced by #4996 |
Fix a nil dereference panic happening when parsing
ENV
andLABEL
commands without a linter introduced by 6cfa459.Signed-off-by: Paweł Gronowski pawel.gronowski@docker.com