Skip to content

DL3038, DL3040, DL3041: Add support for microdnf#764

Merged
lorenzo merged 1 commit intohadolint:masterfrom
Lunkentuss:feature-microdnf
Feb 25, 2022
Merged

DL3038, DL3040, DL3041: Add support for microdnf#764
lorenzo merged 1 commit intohadolint:masterfrom
Lunkentuss:feature-microdnf

Conversation

@Lunkentuss
Copy link
Copy Markdown
Contributor

@Lunkentuss Lunkentuss commented Jan 16, 2022

What I did

Added so all rules concerning dnf (DL3038, DL3040, DL3041) works analogously for microdnf as well, which closes #742. Note that I have not updated any documentation for the corresponding rule changes, since I wasn't sure if and how this should be done.

How I did it

Added utility function cmdsHaveArgs :: [Text.Text] -> [Text.Text] -> Command -> Bool in Shell.hs, which is a generalized version of the function cmdHasArgs. The function has been used to check for the rules concerned in this PR.

How to verify it

Test cases have been added so running the tests should be good enough. One can also run hadolint with the following file:

FROM centos:1.0    
    
RUN microdnf install test-1.0.0 && microdnf clean all # Missing -y flag    
RUN microdnf install -y test-1.0.0 # Missing microdnf clean all    
RUN microdnf install -y test && microdnf clean all # Missing version of package test    
RUN microdnf -y install test-1.0.0 && microdnf clean all # Passes all rules 

which outputs:

Dockerfile:3 DL3038 warning: Use the -y switch to avoid manual input `dnf install -y <package`
Dockerfile:4 DL3040 warning: `dnf clean all` missing after dnf command.
Dockerfile:5 DL3041 warning: Specify version with `dnf install -y <package>-<version>`.

Note that all warnings says dnf and not microdnf.

@lorenzo
Copy link
Copy Markdown
Member

lorenzo commented Feb 25, 2022

thanks!

@lorenzo lorenzo merged commit a124098 into hadolint:master Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make dnf rules apply to microdnf

2 participants