8000 build Jazzer as non-root user · CodeIntelligenceTesting/oss-fuzz@2a13629 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a13629

Browse files
committed
build Jazzer as non-root user
This is a requirement for one dependency. Otherwise, we get the error: "The current user is root, please run as non-root when using the hermetic Python interpreter. See bazel-contrib/rules_python#713."
1 parent a2d113b commit 2a13629

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

infra/base-images/base-builder-jvm/Dockerfile

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,38 @@ ENV JVM_LD_LIBRARY_PATH $JAVA_HOME/lib/server
2121
ENV PATH $PATH:$JAVA_HOME/bin
2222
ENV JAZZER_API_PATH "/usr/local/lib/jazzer_api_deploy.jar"
2323

24-
RUN install_java.sh
24+
RUN install_java.sh
25+
26+
RUN chmod 777 /usr/local/bin && chmod 777 /usr/local/lib
27+
28+
RUN useradd -m jazzer_user
29+
30+
USER jazzer_user
31+
32+
WORK 10000 DIR $SRC
33+
34+
RUN git clone https://github.com/CodeIntelligenceTesting/jazzer && \
35+
cd jazzer && \
36+
git checkout e219dfe2c3299b315aaebe19951e7799a3105794
37+
38+
WORKDIR $SRC/jazzer
39+
40+
RUN echo "build --java_runtime_version=local_jdk_15" >> .bazelrc \
41+
&& echo "build --cxxopt=-stdlib=libc++" >> .bazelrc \
42+
&& echo "build --linkopt=-lc++" >> .bazelrc
43+
44+
RUN bazel build \
45+
//src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar \
46+
//deploy:jazzer-api \
47+
//launcher:jazzer
48+
49+
RUN cp $(bazel cquery --output=files //src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar) /usr/local/bin/jazzer_agent_deploy.jar && \
50+
cp $(bazel cquery --output=files //launcher:jazzer) /usr/local/bin/jazzer_driver && \
51+
cp $(bazel cquery --output=files //deploy:jazzer-api) $JAZZER_API_PATH
52+
53+
USER root
54+
55+
RUN rm -rf /home/jazzer_user/.cache/bazel /home/jazzer_user/.cache/bazelisk && \
56+
rm -rf $SRC/jazzer
57+
58+
RUN chmod 755 /usr/local/bin && chmod 755 /usr/local/lib

infra/base-images/base-builder/install_java.sh

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,3 @@ mkdir -p $JAVA_HOME
2222
tar -xz --strip-components=1 -f openjdk-15.0.2_linux-x64_bin.tar.gz --directory $JAVA_HOME && \
2323
rm -f openjdk-15.0.2_linux-x64_bin.tar.gz
2424
rm -rf $JAVA_HOME/jmods $JAVA_HOME/lib/src.zip
25-
26-
# Install the latest Jazzer in $OUT.
27-
# jazzer_api_deploy.jar is required only at build-time, the agent and the
28-
# drivers are copied to $OUT as they need to be present on the runners.
29-
cd $SRC/
30-
git clone https://github.com/CodeIntelligenceTesting/jazzer && \
31-
cd jazzer && \
32-
33-
# Latest fix followig a depedency issue: (https://github.com/CodeIntelligenceTesting/jazzer/issues/896)
34-
git checkout 96205feebc7135075ffa48aae3f22e38cae5dc45
35-
cat << 'EOF' >> .bazelrc
36-
build --java_runtime_version=local_jdk_15
37-
build --cxxopt=-stdlib=libc++
38-
build --linkopt=-lc++
39-
EOF
40-
41-
bazel build //src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar //deploy:jazzer-api //launcher:jazzer
42-
cp $(bazel cquery --output=files //src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar) /usr/local/bin/jazzer_agent_deploy.jar
43-
cp $(bazel cquery --output=files //launcher:jazzer) /usr/local/bin/jazzer_driver
44-
cp $(bazel cquery --output=files //deploy:jazzer-api) $JAZZER_API_PATH
45-
rm -rf ~/.cache/bazel ~/.cache/bazelisk
46-
rm -rf $SRC/jazzer

0 commit comments

Comments
 (0)
0