Skip to content

Commit 8787305

Browse files
nss: enable replayable build (#13492)
Adds replayable script for nss. Nss performs two builds: - https://hg-edge.mozilla.org/projects/nss/file/tip/automation/ossfuzz/build.sh#l33 - https://hg-edge.mozilla.org/projects/nss/file/tip/automation/ossfuzz/build.sh#l46 Because the second build overwrites the first builds cache (the actual build cache, not OSS-Fuzz's internal caching stuff) we can only capture the replay of the second build, which includes the fuzzing harnesses: `dtls-client`, `dtls-server`, `tls-client` and `tls-server`. Performance: ``` nss: Compile times: Vanilla=61; Replay=1; ``` --------- Signed-off-by: David Korczynski <david@adalogics.com>
1 parent 5a93114 commit 8787305

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

projects/nss/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ RUN apt-get update && apt-get install -y make mercurial zlib1g-dev gyp ninja-bui
2020
RUN hg clone https://hg.mozilla.org/projects/nspr nspr
2121
RUN hg clone https://hg.mozilla.org/projects/nss nss
2222
RUN git clone --depth 1 https://github.com/MozillaSecurity/nss-fuzzing-corpus.git nss-corpus
23-
24-
WORKDIR nss
25-
COPY build.sh $SRC/
23+
COPY build.sh replay_build.sh $SRC/
24+
WORKDIR $SRC/nss

projects/nss/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#
1616
################################################################################
1717

18+
if [[ -n ${CAPTURE_REPLAY_SCRIPT-} ]]; then
19+
# Make sure we don't remove cached directory
20+
sed -i 's/rm -rf/#rm -rf/g' automation/ossfuzz/build.sh
21+
fi
1822

1923
# Build NSS with fuzzers.
2024
./automation/ossfuzz/build.sh

projects/nss/replay_build.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash -eu
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
# This script is useful for OSS-Fuzz infrastructure which is used to rebuild
19+
# code from cached images. This is to support various ongoing efforts in
20+
# OSS-Fuzz.
21+
22+
# List of targets disabled for oss-fuzz.
23+
declare -A disabled=()
24+
# List of targets we want to fuzz in TLS and non-TLS mode.
25+
declare -A tls_targets=([tls-client]=1 [tls-server]=1 [dtls-client]=1 [dtls-server]=1)
26+
# Helper function that copies a fuzzer binary and its seed corpus.
27+
copy_fuzzer()
28+
{
29+
local fuzzer=$1
30+
local name=$2
31+
# Copy the binary.
32+
cp ../dist/Debug/bin/$fuzzer $OUT/$name
33+
}
34+
35+
# Rebuild the library using most recent cache
36+
cd $SRC/nss
37+
ninja -C /src/nss/out/Debug -v
38+
39+
# Copy dual mode targets in TLS mode.
40+
for name in "${!tls_targets[@]}"; do
41+
if [ -z "${disabled[$name]:-}" ]; then
42+
copy_fuzzer nssfuzz-$name $name
43+
fi
44+
done

0 commit comments

Comments
 (0)