Missing Dnf Clean All
- Query id: 295acb63-9246-4b21-b441-7c1f1fb62dc0
- Query name: Missing Dnf Clean All
- Platform: Dockerfile
- Severity: Medium
- Category: Supply-Chain
- URL: Github
Description¶
Cached package data should be cleaned after installation to reduce image size
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - dockerfile file
FROM fedora:27
RUN set -uex && \
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo && \
sed -i 's/\$releasever/26/g' /etc/yum.repos.d/docker-ce.repo && \
dnf install -vy docker-ce
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1
Code samples without security vulnerabilities¶
Negative test num. 1 - dockerfile file
FROM fedora:27
RUN set -uex && \
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo && \
sed -i 's/\$releasever/26/g' /etc/yum.repos.d/docker-ce.repo && \
dnf install -vy docker-ce && \
dnf clean all
HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1