Skip to content

Improve DL3009 rule to properly handle all apt-based package managers#1074

Merged
m-ildefons merged 1 commit intohadolint:masterfrom
PeterDaveHello:Improve-DL3009-#1073
Aug 13, 2025
Merged

Improve DL3009 rule to properly handle all apt-based package managers#1074
m-ildefons merged 1 commit intohadolint:masterfrom
PeterDaveHello:Improve-DL3009-#1073

Conversation

@PeterDaveHello
Copy link
Copy Markdown
Contributor

@PeterDaveHello PeterDaveHello commented Mar 3, 2025

What I did

Improved DL3009 rule to properly handle all apt-based package managers:

  • Added support for apt and aptitude in hasUpdate function
  • Updated error message to be more specific about tools and path

How I did it

  1. Enhanced the hasUpdate function to detect update operations from apt and aptitude commands
  2. Updated the error message to clearly specify which package managers it applies to and the exact path that needs cleaning

How to verify it

Create a test Dockerfile with different apt-based package managers:

FROM ubuntu:20.04

# This will trigger DL3009 (apt-get)
RUN apt-get update && apt-get install -y python3

# This will also trigger DL3009 now (apt)
RUN apt update && apt install -y curl

# This will also trigger DL3009 now (aptitude)
RUN aptitude update && aptitude install -y wget

# This will not trigger DL3009 (proper cleanup)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

Run hadolint on the file:

hadolint Dockerfile

The first three RUN instructions should now trigger the DL3009 warning with the updated message.

Fix #1073

- Add support for apt and aptitude in hasUpdate function
- Update error message to be more specific about tools and path

Fix hadolint#1073
@PeterDaveHello
Copy link
Copy Markdown
Contributor Author

We need #1063 to be merged first to pass the CI 😅

@m-ildefons m-ildefons merged commit 540378d into hadolint:master Aug 13, 2025
1 of 2 checks passed
@m-ildefons
Copy link
Copy Markdown
Member

Thanks for the PR.
No idea why the tests didn't pass.
I rebased the commit onto master HEAD and ran cabal test successfully locally.

@PeterDaveHello PeterDaveHello deleted the Improve-DL3009-#1073 branch August 13, 2025 12:15
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.

DL3009 not triggered after apt update when apt is used instead of apt-get

2 participants