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/linter: check for nil linter in linter functions #4996

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

jsternberg
Copy link
Collaborator

@jsternberg jsternberg commented Jun 5, 2024

During parsing, the linter can be nil and linter rules won't succeed at running due to a nil dereference. Instead of checking for nil everywhere, this modifies the linter to automatically disable itself if the linter is nil.

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

An alternative to #4984.

@@ -209,7 +207,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 == "" {
Copy link
Member

Choose a reason for hiding this comment

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

This looks inconsistent with other lines

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. It wasn't near the other ones so I didn't see it.

During parsing, the linter can be nil and linter rules won't succeed at
running due to a nil dereference. Instead of checking for nil
everywhere, this modifies the linter to automatically disable itself if
the linter is nil.

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

Co-authored-by: Paweł Gronowski <[email protected]>
Signed-off-by: Jonathan A. Sternberg <[email protected]>
@thompson-shaun thompson-shaun added this to the v0.14.0 milestone Jun 5, 2024
@tonistiigi tonistiigi merged commit c1f5352 into moby:master Jun 5, 2024
76 checks passed
@jsternberg jsternberg deleted the linter-nilcheck branch June 5, 2024 20:38
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.

4 participants