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

CKV_DOCKER_9 fires when apt appears as an argument (e.g. to rm -rf ) #6310

Open
jeffcasavant opened this issue May 15, 2024 · 2 comments
Open
Labels
checks Check additions or changes

Comments

@jeffcasavant
Copy link

Describe the issue
CKV_DOCKER_9 correctly pushes me to use apt-get instead of apt. In my current Dockerfile, I am installing several packages with apt-get, and then I do the following:

cd /var/lib && rm -rf apt dpkg cache log

This causes CKV_DOCKER_9 to fire.

Examples

FROM ubuntu

RUN apt-get update && \
    apt-get install --yes --no-install-recommends \
        git && \
    apt-get clean autoclean && \
    apt-get autoremove --yes && \
    cd /var/lib && \
    rm -rf apt dpkg cache log

Version (please complete the following information):

  • 3.2.92
@jeffcasavant jeffcasavant added the checks Check additions or changes label May 15, 2024
@jeffcasavant jeffcasavant changed the title CKV_DOCKER_9 fires when apt appears as an argument (e.g. to rm -rf CKV_DOCKER_9 fires when apt appears as an argument (e.g. to rm -rf ) May 15, 2024
@naveednawazkhan
Copy link
Contributor

naveednawazkhan commented May 17, 2024

Thank you for reaching out, we'll look into this but as a workaround try the following code to avoid alert.

FROM ubuntu

RUN apt-get update && \
    apt-get install --yes --no-install-recommends \
        git && \
    apt-get clean autoclean && \
    apt-get autoremove --yes && \
    cd /var/lib && \
    rm -rf /var/lib/{apt,dpkg,cache,log}

@jeffcasavant
Copy link
Author

That was my original formulation, but hadolint was complaining that the bracket expansion thing isn't POSIX.

Combined with SHELL /bin/bash that should work, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checks Check additions or changes
Projects
None yet
Development

No branches or pull requests

2 participants