Skip to content

Commit 0d224dc

Browse files
authored
Fix/docker python vulnerabilities (#6320)
* fix python vulnerabilities in Docker images * upgrade pip and setuptools * Removing unused source directory * upgrading packages from root directory * cleaning up default python3.11
1 parent bf49770 commit 0d224dc

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

Dockerfile-api

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ RUN apt-get update && \
3030
RUN apt-get update && \
3131
apt-get upgrade -y && \
3232
cd /usr/src && \
33-
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tar.xz && \
34-
tar -xf Python-3.8.12.tar.xz && \
33+
wget https://www.python.org/ftp/python/3.8.20/Python-3.8.20.tar.xz && \
34+
tar -xf Python-3.8.20.tar.xz && \
3535
apt-get install -y build-essential sudo zlib1g-dev libssl3 libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev && \
36-
cd Python-3.8.12 && \
36+
cd Python-3.8.20 && \
3737
./configure --enable-optimizations --enable-shared && \
3838
make && \
3939
make altinstall && \
40-
ldconfig /usr/src/Python-3.8.12 && \
41-
ln -s /usr/local/bin/python3.8 /usr/bin/python3
40+
ldconfig /usr/src/Python-3.8.20 && \
41+
ln -sf /usr/local/bin/python3.8 /usr/bin/python3
4242

4343
RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" && \
4444
dpkg -i /tmp/tini.deb && \
@@ -55,13 +55,16 @@ RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/downlo
5555
HOME=/tmp npm install argon2 --build-from-source --unsafe-perm=true --allow-root && \
5656
./bin/docker/preinstall.sh && \
5757
bash /opt/countly/bin/scripts/detect.init.sh && \
58+
python3.8 -m pip install --upgrade pip setuptools && \
5859
\
5960
# cleanup & chown
6061
npm remove -y --no-save mocha nyc should supertest && \
62+
apt-get purge -y python3 python3-pip python3-distutils python3-setuptools && \
6163
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 wget && \
6264
apt-get install -y libgbm-dev libgbm1 gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils && \
6365
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
64-
rm -rf test /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm && \
66+
apt-get autoremove -y && \
67+
rm -rf test /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm /usr/local/lib/python3.8/ensurepip/_bundled/*.whl /usr/src/Python* /var/lib/dpkg/info/python3* && \
6568
\
6669
# temporary to remove npm bug message
6770
mkdir /.npm && chown -R 1001:0 /.npm && \
@@ -76,4 +79,4 @@ USER 1001:0
7679

7780
ENTRYPOINT ["/usr/bin/tini", "-v", "--"]
7881

79-
CMD ["/opt/countly/bin/docker/cmd.sh"]
82+
CMD ["/opt/countly/bin/docker/cmd.sh"]

Dockerfile-frontend

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ RUN apt-get update && \
2626
RUN apt-get update && \
2727
apt-get upgrade -y && \
2828
cd /usr/src && \
29-
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tar.xz && \
30-
tar -xf Python-3.8.12.tar.xz && \
29+
wget https://www.python.org/ftp/python/3.8.20/Python-3.8.20.tar.xz && \
30+
tar -xf Python-3.8.20.tar.xz && \
3131
apt-get install -y build-essential sudo zlib1g-dev libssl3 libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev && \
32-
cd Python-3.8.12 && \
32+
cd Python-3.8.20 && \
3333
./configure --enable-optimizations --enable-shared && \
3434
make && \
3535
make altinstall && \
36-
ldconfig /usr/src/Python-3.8.12 && \
37-
ln -s /usr/local/bin/python3.8 /usr/bin/python3
36+
ldconfig /usr/src/Python-3.8.20 && \
37+
ln -sf /usr/local/bin/python3.8 /usr/bin/python3
3838

3939
RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" && \
4040
dpkg -i /tmp/tini.deb && \
@@ -52,14 +52,17 @@ RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/downlo
5252
HOME=/tmp npm install argon2 --build-from-source --unsafe-perm=true --allow-root && \
5353
./bin/docker/preinstall.sh && \
5454
bash /opt/countly/bin/scripts/detect.init.sh && \
55-
countly update sdk-web && \
55+
python3.8 -m pip install --upgrade pip setuptools && \
56+
countly update sdk-web && \
5657
\
5758
# cleanup & chown
5859
npm remove -y --no-save mocha nyc should supertest puppeteer && \
59-
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 wget && \
60+
apt-get purge -y python3 python3-pip python3-distutils python3-setuptools && \
61+
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 wget && \
6062
apt-get autoremove -y && \
6163
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
62-
rm -rf test /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm && \
64+
apt-get autoremove -y && \
65+
rm -rf test /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm /usr/local/lib/python3.8/ensurepip/_bundled/*.whl /usr/src/Python* /var/lib/dpkg/info/python3* && \
6366
\
6467
# temporary to remove npm bug message
6568
mkdir /.npm && chown -R 1001:0 /.npm && \

0 commit comments

Comments
 (0)