為什么你需要更小巧的容器?
漏洞掃描器往往有很多誤報(bào)
一些報(bào)告的發(fā)現(xiàn)已經(jīng)可以在上游和后端修復(fù)
有些可能完全不相關(guān),因?yàn)樗鼈兲囟ㄓ谀承┥願(yuàn)W的架構(gòu)
在鏡像倉庫(例如Docker Hub)中,官方基礎(chǔ)鏡像從不(或很少)更新
隨著容器使用的增加,為操作系統(tǒng)打補(bǔ)丁的負(fù)擔(dān)實(shí)際上從管理員和操作人員轉(zhuǎn)移到了開發(fā)人員身上
但并不是每個(gè)開發(fā)者都意識(shí)到這一點(diǎn)
有些人建議在每個(gè)Dockerfile的開頭添加RUN apt-get update &&?apt-get -y upgrade,我嘗試了一下,在完全成熟的Debian 10發(fā)行版中,它提供了非常小的效果
但其他人反駁說,這會(huì)導(dǎo)致不可復(fù)制的構(gòu)建,以及由于反向端口改變依賴的默認(rèn)行為而導(dǎo)致的潛在風(fēng)險(xiǎn)
這導(dǎo)致了一個(gè)公平的控制源存儲(chǔ)庫的建議
當(dāng)然,這會(huì)讓事情變得更復(fù)雜
這就是為什么最典型的解決方案似乎是簡(jiǎn)單的,忽略了這個(gè)問題
盡管掃描結(jié)果很好,但Alpine鏡像并不總是很好
因?yàn)閾?jù)報(bào)道m(xù)usl libc比glibc慢,并不是每個(gè)依賴庫都為這個(gè)平臺(tái)提供構(gòu)建

#?latest?stable?at?the?time
FROM?python:3.9
RUN?pip?install?Flask
COPY?server.py?server.py
ENV?FLASK_APP=server.py
ENV?FLASK_RUN_PORT=5000
ENV?FLASK_RUN_HOST=0.0.0.0
EXPOSE?5000
CMD?["flask",?"run"]
Testing?python-flask...
??Low?severity?vulnerability?found?in?unbound/libunbound8
??Description:?Improper?Input?Validation
??Info:?https://snyk.io/vuln/SNYK-DEBIAN10-UNBOUND-534899
??Introduced?through:?mysql-defaults/[email protected]
??From:?mysql-defaults/[email protected]?>?mariadb-10.3/libmariadb-dev-compat@1:10.3.27-0+deb10u1?>?mariadb-10.3/libmariadb-dev@1:10.3.27-0+deb10u1?>?gnutls28/[email protected]+deb10u6?>?gnutls28/[email protected]+deb10u6?>?unbound/[email protected]+deb10u2
??Low?severity?vulnerability?found?in?tiff/libtiff5
??Description:?Out-of-Bounds
??Info:?https://snyk.io/vuln/SNYK-DEBIAN10-TIFF-1079067
??Introduced?through:?imagemagick@8:6.9.10.23+dfsg-2.1+deb10u1,?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1
??From:?imagemagick@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/imagemagick-6.q16@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-6@8:6.9.10.23+dfsg-2.1+deb10u1?>?tiff/[email protected]+git191117-2~deb10u2
??From:?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?tiff/[email protected]+git191117-2~deb10u2?>?tiff/[email protected]+git191117-2~deb10u2
??From:?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?tiff/[email protected]+git191117-2~deb10u2?>?tiff/[email protected]+git191117-2~deb10u2?>?tiff/[email protected]+git191117-2~deb10u2
??and?3?more...
...
??High?severity?vulnerability?found?in?gcc-8
??Description:?Insufficient?Entropy
??Info:?https://snyk.io/vuln/SNYK-DEBIAN10-GCC8-469413
??Introduced?through:?gcc-defaults/g++@4:8.3.0-1,[email protected],?imagemagick@8:6.9.10.23+dfsg-2.1+deb10u1,?meta-common-packages@meta
??From:?gcc-defaults/g++@4:8.3.0-1?>[email protected]
??From:[email protected]?>[email protected]
??From:?gcc-defaults/g++@4:8.3.0-1?>?gcc-8/[email protected]?>[email protected]
??and?23?more...
??High?severity?vulnerability?found?in?djvulibre/libdjvulibre21
??Description:?NULL?Pointer?Dereference
??Info:?https://snyk.io/vuln/SNYK-DEBIAN10-DJVULIBRE-481572
??Introduced?through:?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1
??From:?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?djvulibre/[email protected]?>?djvulibre/[email protected]
??From:?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-6-extra@8:6.9.10.23+dfsg-2.1+deb10u1?>?djvulibre/[email protected]
??From:?imagemagick/libmagickcore-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?imagemagick/libmagickcore-6.q16-dev@8:6.9.10.23+dfsg-2.1+deb10u1?>?djvulibre/[email protected]
??and?1?more...
??High?severity?vulnerability?found?in?bluez/libbluetooth3
??Description:?Double?Free
??Info:?https://snyk.io/vuln/SNYK-DEBIAN10-BLUEZ-1018718
??Introduced?through:?bluez/[email protected]~deb10u1
??From:?bluez/[email protected]~deb10u1?>?bluez/[email protected]~deb10u1
??From:?bluez/[email protected]~deb10u1
Package?manager:???deb
Project?name:??????docker-image|python-flask
Docker?image:??????python-flask
Platform:??????????linux/amd64
Tested?431?dependencies?for?known?vulnerabilities,?found?358?vulnerabilities.
For?more?free?scans?that?keep?your?images?secure,?sign?up?to?Snyk?at?https://dockr.ly/3ePqVcp

FROM?python:3.9-slim
RUN?pip?install?Flask
COPY?server.py?server.py
ENV?FLASK_APP=server.py
ENV?FLASK_RUN_PORT=5000
ENV?FLASK_RUN_HOST=0.0.0.0
EXPOSE?5000
CMD?["flask",?"run"]
Package?manager:???deb
Project?name:??????docker-image|python-flask-slim
Docker?image:??????python-flask-slim
Platform:??????????linux/amd64
Tested?94?dependencies?for?known?vulnerabilities,?found?69?vulnerabilities.

FROM?python:3.9-alpine
RUN?pip?install?Flask
COPY?server.py?server.py
ENV?FLASK_APP=server.py
ENV?FLASK_RUN_PORT=5000
ENV?FLASK_RUN_HOST=0.0.0.0
EXPOSE?5000
CMD?["flask",?"run"]
Package?manager:???apk
Project?name:??????docker-image|python-flask-alpine
Docker?image:??????python-flask-alpine
Platform:??????????linux/amd64
??Tested?37?dependencies?for?known?issues,?no?vulnerable?paths?found.



#?Build?image
FROM?python:3.7-slim?AS?build-env
RUN?python?-m?pip?install?Flask
#?Runtime?image
FROM?gcr.io/distroless/python3
COPY?--from=build-env?/usr/local/bin/flask?/usr/local/bin/flask
COPY?--from=build-env?/usr/local/lib/python3.7/site-packages?/usr/local/lib/python3.7/site-packages
WORKDIR?/app
COPY?server.py?server.py
#?Important?line!
ENV?PYTHONPATH=/usr/local/lib/python3.7/site-packages
ENV?FLASK_APP=server.py
ENV?FLASK_RUN_PORT=5000
ENV?FLASK_RUN_HOST=0.0.0.0
EXPOSE?5000
CMD?["/usr/local/bin/flask",?"run"]
Package?manager:???deb
Project?name:??????docker-image|python-flask-distroless
Docker?image:??????python-flask-distroless
Platform:??????????linux/amd64
Tested?25?dependencies?for?known?vulnerabilities,?found?37?vulnerabilities.

FROM?scratch
COPY?hello?/
CMD?["/hello"]
Testing?go-scratch...
Package?manager:???linux
Project?name:??????docker-image|go-scratch
Docker?image:??????go-scratch
Platform:??????????linux/amd64
??Tested?go-scratch?for?known?vulnerabilities,?no?vulnerable?paths?found.


推薦閱讀
