Skip to content

Commit 472ccba

Browse files
authored
Attempt to fix cel-cpp build (#14321)
We've swapped over to using bzlmod primarily and at some point broke workspace dependencies support (and bazel < 7).
1 parent 261e9e8 commit 472ccba

File tree

6 files changed

+49
-15
lines changed

6 files changed

+49
-15
lines changed

projects/cel-cpp/.bazelrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
build --action_env=CC=clang
1919
build --action_env=CXX=clang++
2020

21-
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_engine
21+
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:oss_fuzz
2222
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine_instrumentation=oss-fuzz
2323
build:oss-fuzz --@rules_fuzzing//fuzzing:cc_engine_sanitizer=none
24+
build:oss-fuzz --cxxopt=-stdlib=libc++
25+
build:oss-fuzz --linkopt=-lc++
26+
build:oss-fuzz --verbose_failures
27+
build:oss-fuzz --spawn_strategy=standalone

projects/cel-cpp/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ RUN apt-get update && apt-get install python3 openjdk-11-jdk -y
2020
RUN git clone --depth 1 https://github.com/google/cel-cpp/
2121
COPY build.sh $SRC/
2222
RUN mkdir $SRC/cel-cpp/fuzz/
23+
COPY build.sh $SRC/cel-cpp
2324
COPY BUILD fuzz*.cc $SRC/cel-cpp/fuzz/
24-
COPY WORKSPACE .bazelrc $SRC/
25-
RUN cat WORKSPACE >> $SRC/cel-cpp/WORKSPACE
25+
COPY MODULE.bazel .bazelrc $SRC/
26+
RUN cat MODULE.bazel >> $SRC/cel-cpp/MODULE.bazel
2627
RUN cat .bazelrc >> $SRC/cel-cpp/.bazelrc
27-
RUN echo "4.1.0" > $SRC/cel-cpp/.bazelversion
2828
WORKDIR $SRC/cel-cpp
2929
# This is to fix Fuzz Introspector build by using LLVM old pass manager
3030
# re https://github.com/ossf/fuzz-introspector/issues/305
31-
ENV OLD_LLVMPASS 1
31+
ENV OLD_LLVMPASS=1

projects/cel-cpp/MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
bazel_dep(name = "rules_fuzzing", version = "0.6.0")

projects/cel-cpp/build.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,34 @@
1414
# limitations under the License.
1515
#
1616
################################################################################
17-
export USE_BAZEL_VERSION=5.4.0
18-
bazel_build_fuzz_tests
17+
export USE_BAZEL_VERSION="7.3.2"
18+
export CC=${CC:-clang}
19+
export CXX=${CXX:-clang++}
20+
21+
# modified version of bazel_build_fuzz_tests to work around issues with
22+
# bzlmod dependency on rules_fuzzing
23+
24+
bazel build -c opt --config=oss-fuzz //fuzz:fuzz_parse_oss_fuzz
25+
26+
for oss_fuzz_archive in $(find bazel-bin/ -name "*oss_fuzz.tar"); do
27+
tar --no-same-owner -xvf "${oss_fuzz_archive}" -C "${OUT}"
28+
done
29+
30+
if [ "$SANITIZER" = "coverage" ]; then
31+
echo "Collecting the repository source files for coverage tracking."
32+
declare -r COVERAGE_SOURCES="${OUT}/proc/self/cwd"
33+
mkdir -p "${COVERAGE_SOURCES}"
34+
declare -r RSYNC_FILTER_ARGS=(
35+
"--include" "*.h"
36+
"--include" "*.cc"
37+
"--include" "*.hpp"
38+
"--include" "*.cpp"
39+
"--include" "*.c"
40+
"--include" "*.inc"
41+
"--include" "*/"
42+
"--exclude" "*"
43+
)
44+
rsync -avLk "${RSYNC_FILTER_ARGS[@]}" \
45+
"$(bazel info execution_root)/" \
46+
"${COVERAGE_SOURCES}/"
47+
fi

projects/cel-cpp/fuzz_parse.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
#include "parser/options.h"
2020
#include "parser/parser.h"
2121

22-
#define MAX_RECURSION 0x100
23-
2422
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
2523
std::string str (reinterpret_cast<const char*>(data), size);
2624
google::api::expr::parser::ParserOptions options;
27-
options.max_recursion_depth = MAX_RECURSION;
25+
options.max_recursion_depth = 128;
26+
options.expression_size_codepoint_limit = 1 << 20;
2827
try {
2928
auto parse_status = google::api::expr::parser::Parse(str, "fuzzinput", options);
3029
if (!parse_status.ok()) {
31-
parse_status.status().message();
30+
static_cast<void>(parse_status.status().message());
3231
}
3332
} catch (const std::exception& e) {
3433
return 0;

projects/cel-cpp/project.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
homepage: "https://opensource.google/projects/cel"
1+
homepage: "https://cel.dev"
22
language: c++
3-
primary_contact: "kyessenov@gmail.com"
3+
primary_contact: "tswadell@google.com"
44
auto_ccs :
5-
- "tswadell@google.com"
5+
- "jdtatum@google.com"
6+
- "kyessenov@google.com"
67
- "p.antoine@catenacyber.fr"
78

89
sanitizers:
@@ -13,7 +14,6 @@ main_repo: 'https://github.com/google/cel-cpp'
1314
file_github_issue: True
1415

1516
fuzzing_engines:
16-
- afl
1717
- honggfuzz
1818
- libfuzzer
1919

0 commit comments

Comments
 (0)