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

[infra] Upgrade Python to 3.10.14 in base-builder & base-runner Images #12027

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a9fc958
[infra] Upgrade Python to 3.10.14 in base-builder & base-runner Images
DaveLak Jun 4, 2024
0f004a4
Merge branch 'master' of github.com:/DaveLak/oss-fuzz into upgrade-py…
DaveLak Jun 21, 2024
e1a6e9f
Fix coverage builds on Python 3.10
DaveLak Jun 22, 2024
8624580
Merge branch 'master' of github.com:/DaveLak/oss-fuzz into upgrade-py…
DaveLak Aug 7, 2024
72b1206
Merge branch 'master' of github.com:/DaveLak/oss-fuzz into upgrade-py…
DaveLak Aug 13, 2024
3e3fa52
Fix compatibility issue with pysecsan hooks in Python 3.10
DaveLak Aug 13, 2024
e6fc52c
Upgrade Python Dependencies in Base Builder for Python 3.10
DaveLak Aug 13, 2024
9a666fc
Replace deprecated setup.py install method with direct pip equivalent
DaveLak Aug 13, 2024
15ddae5
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Aug 13, 2024
6e04b72
Merge branch 'master' of github.com:/DaveLak/oss-fuzz into upgrade-py…
DaveLak Aug 20, 2024
8b056dc
Bump Python Version from 3.8 to 3.10 in GitHub Actions
DaveLak Aug 20, 2024
c4957f5
Specify Python Version as Strings
DaveLak Aug 20, 2024
26a5c01
Bump google-github-actions/setup-gcloud from v0 to v2
DaveLak Aug 20, 2024
98bec38
Revert change to atheris version constraint
DaveLak Aug 20, 2024
de241d9
Use `python -m pip` to invoke pip install command
DaveLak Aug 20, 2024
0ea6b5c
Revert CI Python Version Bumps
DaveLak Aug 21, 2024
72c5ae9
Revert "Use `python -m pip` to invoke pip install command"
DaveLak Aug 21, 2024
2c3f94d
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Aug 21, 2024
cd86abc
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Aug 21, 2024
9db721e
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Aug 22, 2024
b076c35
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Aug 28, 2024
4f6e007
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Aug 28, 2024
83c8ec1
Merge branch 'master' into upgrade-python-to-3-10-14
DaveLak Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions infra/base-images/base-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ FROM gcr.io/oss-fuzz-base/base-clang
COPY install_deps.sh /
RUN /install_deps.sh && rm /install_deps.sh

# Build and install latest Python 3 (3.8.3).
ENV PYTHON_VERSION 3.8.3
RUN export PYTHON_DEPS="\
# Build and install latest Python 3.10.
ENV PYTHON_VERSION 3.10.14
RUN PYTHON_DEPS="\
zlib1g-dev \
libncurses5-dev \
libgdbm-dev \
Expand All @@ -39,12 +39,14 @@ RUN export PYTHON_DEPS="\
tar -xvf Python-$PYTHON_VERSION.tar.xz && \
cd Python-$PYTHON_VERSION && \
./configure --enable-optimizations --enable-shared && \
make -j install && \
make -j$(nproc) install && \
ldconfig && \
ln -s /usr/bin/python3 /usr/bin/python && \
ln -s /usr/local/bin/python3 /usr/local/bin/python && \
cd .. && \
rm -r /tmp/Python-$PYTHON_VERSION.tar.xz /tmp/Python-$PYTHON_VERSION && \
rm -rf /usr/local/lib/python3.8/test && \
rm -rf /usr/local/lib/python${PYTHON_VERSION%.*}/test && \
python3 -m ensurepip && \
python3 -m pip install --upgrade pip && \
apt-get remove -y $PYTHON_DEPS # https:/google/oss-fuzz/issues/3888

# Install six for Bazel rules.
Expand Down
4 changes: 2 additions & 2 deletions infra/base-images/base-builder/compile_python_fuzzer
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [[ $SANITIZER = *introspector* ]]; then
# we enter the virtual environment in the following lines because we need
# to use the same python environment that installed the fuzzer dependencies.
python3 /fuzz-introspector/frontends/python/prepare_fuzz_imports.py $fuzzer_path isossfuzz

# We must ensure python3.9, this is because we use certain
# AST logic from there.
# The below should probably be refined
Expand Down Expand Up @@ -84,7 +84,7 @@ then
if [[ ! -d "/pysecsan" ]];
then
pushd /usr/local/lib/sanitizers/pysecsan
python3 setup.py install
python3 -m pip install .
popd
fi

Expand Down
2 changes: 1 addition & 1 deletion infra/base-images/base-builder/install_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ echo "ATHERIS INSTALL"
unset CFLAGS CXXFLAGS
# PYI_STATIC_ZLIB=1 is needed for installing pyinstaller 5.0
export PYI_STATIC_ZLIB=1
LIBFUZZER_LIB=$( echo /usr/local/lib/clang/*/lib/x86_64-unknown-linux-gnu/libclang_rt.fuzzer_no_main.a ) pip3 install -v --no-cache-dir "atheris>=2.1.1" "pyinstaller==5.0.1" "setuptools==42.0.2" "coverage==6.3.2"
LIBFUZZER_LIB=$( echo /usr/local/lib/clang/*/lib/x86_64-unknown-linux-gnu/libclang_rt.fuzzer_no_main.a ) pip3 install -v --no-cache-dir "atheris>=2.3.0" "pyinstaller==6.10.0" "setuptools==72.1.0" "coverage==6.3.2"
rm -rf /tmp/*
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def hook_pre_exec_os_system(cmd):
'Command injection')


def hook_pre_exec_eval(cmd):
def hook_pre_exec_eval(cmd, *args, **kwargs):
"""Hook for eval. Experimental atm."""
res = check_code_injection_match(cmd, check_unquoted=True)
if res is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import functools
import subprocess
import traceback
import importlib
import importlib.util

from typing import Any, Callable, Optional
from pysecsan import command_injection, redos, yaml_deserialization
Expand Down Expand Up @@ -54,7 +54,7 @@ def sanitizer_log_always(msg, log_prefix=True):
def is_module_present(mod_name):
"""Identify if module is importable."""
# pylint: disable=deprecated-method
return importlib.find_loader(mod_name) is not None
return importlib.util.find_spec(mod_name) is not None


def _log_bug(bug_title):
Expand Down
22 changes: 21 additions & 1 deletion infra/base-images/base-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ RUN cargo install rustfilt
FROM gcr.io/oss-fuzz-base/base-clang AS base-clang
FROM gcr.io/oss-fuzz-base/base-builder-ruby AS base-ruby

# The base builder image compiles a specific Python version. Using a multi-stage build
# to copy that same Python interpreter into the runner image saves build time and keeps
# the Python versions in sync.
FROM gcr.io/oss-fuzz-base/base-builder AS base-builder

# Real image that will be used later.
FROM gcr.io/oss-fuzz-base/base-image

Expand All @@ -36,6 +41,18 @@ COPY --from=base-clang /usr/local/bin/llvm-cov \
/usr/local/bin/llvm-symbolizer \
/usr/local/bin/

# Copy the pre-compiled Python binaries and libraries
COPY --from=base-builder /usr/local/bin/python3.10 /usr/local/bin/python3.10
COPY --from=base-builder /usr/local/lib/libpython3.10.so.1.0 /usr/local/lib/libpython3.10.so.1.0
COPY --from=base-builder /usr/local/include/python3.10 /usr/local/include/python3.10
COPY --from=base-builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
COPY --from=base-builder /usr/local/bin/pip3 /usr/local/bin/pip3

# Create symbolic links to ensure compatibility
RUN ldconfig && \
ln -s /usr/local/bin/python3.10 /usr/local/bin/python3 && \
ln -s /usr/local/bin/python3.10 /usr/local/bin/python

COPY install_deps.sh /
RUN /install_deps.sh && rm /install_deps.sh

Expand All @@ -46,8 +63,11 @@ RUN git clone https://chromium.googlesource.com/chromium/src/tools/code_coverage
cd /opt/code_coverage && \
git checkout edba4873b5e8a390e977a64c522db2df18a8b27d && \
pip3 install wheel && \
# If version "Jinja2==2.10" is in requirements.txt, bump it to a patch version that
# supports upgrading its MarkupSafe dependency to a Python 3.10 compatible release:
sed -i 's/Jinja2==2.10/Jinja2==2.10.3/' requirements.txt && \
pip3 install -r requirements.txt && \
pip3 install MarkupSafe==0.23 && \
pip3 install MarkupSafe==2.0.1 && \
pip3 install coverage==6.3.2

# Default environment options for various sanitizers.
Expand Down
4 changes: 1 addition & 3 deletions infra/base-images/base-runner/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
apt-get update && apt-get install -y \
binutils \
file \
ca-certificates \
fonts-dejavu \
git \
libcap2 \
python3 \
python3-pip \
python3-setuptools \
rsync \
unzip \
wget \
Expand Down
Loading